class GrapeClient::ResponseParser
Public Class Methods
new(response, receiver)
click to toggle source
# File lib/grape_client/response_parser.rb, line 5 def initialize(response, receiver) @response = response @receiver = receiver end
Public Instance Methods
collection()
click to toggle source
# File lib/grape_client/response_parser.rb, line 28 def collection parsed[@receiver.entity_name.pluralize] if parsed.is_a? Hash end
parse()
click to toggle source
# File lib/grape_client/response_parser.rb, line 10 def parse if @receiver.is_a? Class elements = collection if elements.nil? if parsed.present? @receiver.new(parsed) else @response end else Collection.new(@receiver, elements, @receiver.connection.headers) end else @receiver.attributes = parsed end end
Private Instance Methods
parsed()
click to toggle source
# File lib/grape_client/response_parser.rb, line 34 def parsed @parsed ||= JSON.parse @response rescue JSON::ParserError nil end