class NOMIS::API::ParsedResponse
decorates a Net::HTTP response with a data method, which parses the JSON in the response body
Attributes
body[RW]
data[RW]
raw_response[RW]
status[RW]
Public Class Methods
new(raw_response)
click to toggle source
# File lib/nomis/api/parsed_response.rb, line 10 def initialize(raw_response) self.raw_response = raw_response self.data = parse(raw_response) end
Public Instance Methods
parse(response)
click to toggle source
# File lib/nomis/api/parsed_response.rb, line 19 def parse(response) response.content_type == 'application/json' ? \ JSON.parse(response.body) : response.body end