Class: HTTParty::Response
- Inherits:
- BasicObject
- Defined in:
- lib/httparty/response.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Headers
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#parsed_response ⇒ Object
readonly
Returns the value of attribute parsed_response.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #class ⇒ Object
- #code ⇒ Object
-
#initialize(response, parsed_response) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(response, parsed_response) ⇒ Response
Returns a new instance of Response.
33 34 35 36 37 38 |
# File 'lib/httparty/response.rb', line 33 def initialize(response, parsed_response) @response = response @body = response.body @parsed_response = parsed_response @headers = Headers.new(response.to_hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/httparty/response.rb', line 52 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 |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
31 32 33 |
# File 'lib/httparty/response.rb', line 31 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
31 32 33 |
# File 'lib/httparty/response.rb', line 31 def headers @headers end |
#parsed_response ⇒ Object (readonly)
Returns the value of attribute parsed_response.
31 32 33 |
# File 'lib/httparty/response.rb', line 31 def parsed_response @parsed_response end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
31 32 33 |
# File 'lib/httparty/response.rb', line 31 def response @response end |
Instance Method Details
#class ⇒ Object
40 41 42 |
# File 'lib/httparty/response.rb', line 40 def class Object.instance_method(:class).bind(self).call end |
#code ⇒ Object
44 45 46 |
# File 'lib/httparty/response.rb', line 44 def code response.code.to_i end |
#inspect ⇒ Object
48 49 50 |
# File 'lib/httparty/response.rb', line 48 def inspect %(<#{self.class} @response=#{response.inspect}>) end |