class Nuvemshop::Response
Attributes
body[R]
code[R]
formatter[R]
headers[R]
parsed_response[R]
response[R]
Public Class Methods
new(response, formatter = nil)
click to toggle source
# File lib/nuvemshop/response.rb, line 5 def initialize(response, formatter = nil) @response = response @code = response.code @body = response.body @headers = response.headers @parsed_response = response.parsed_response @formatter = formatter end
Public Instance Methods
format()
click to toggle source
# File lib/nuvemshop/response.rb, line 14 def format return unless formatter @parsed_response = if parsed_response.is_a?(Array) parsed_response.map { |pr| formatter.new(pr) } else formatter.new(parsed_response) end end
inspect()
click to toggle source
# File lib/nuvemshop/response.rb, line 32 def inspect inspect_id = ::Kernel.format '%x', (object_id * 2) %(#<#{self.class}:0x#{inspect_id} code, @response=#{response.inspect}, @headers=#{headers.inspect}>) end
pretty_print(pp)
click to toggle source
Calls superclass method
# File lib/nuvemshop/response.rb, line 37 def pretty_print(pp) format if !parsed_response.nil? && parsed_response.respond_to?(:pretty_print) parsed_response.pretty_print(pp) else super end end
respond_to_missing?(name, *args)
click to toggle source
Calls superclass method
# File lib/nuvemshop/response.rb, line 47 def respond_to_missing?(name, *args) return true if super parsed_response.respond_to?(name) || response.respond_to?(name) end
to_s()
click to toggle source
# File lib/nuvemshop/response.rb, line 24 def to_s if !response.nil? && !response.body.nil? && response.body.respond_to?(:to_s) response.body.to_s else inspect end end
Protected Instance Methods
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/nuvemshop/response.rb, line 55 def method_missing(name, *args, &block) if parsed_response.respond_to?(name) parsed_response.send(name, *args, &block) elsif response.respond_to?(name) response.send(name, *args, &block) else super end end