Class: Aviator::Response
- Inherits:
-
Object
- Object
- Aviator::Response
- Extended by:
- Forwardable
- Defined in:
- lib/aviator/core/response.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(response, request) ⇒ Response
constructor
A new instance of Response.
- #to_hash ⇒ Object
Constructor Details
#initialize(response, request) ⇒ Response
Returns a new instance of Response.
10 11 12 13 |
# File 'lib/aviator/core/response.rb', line 10 def initialize(response, request) @response = response @request = request end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
8 9 10 |
# File 'lib/aviator/core/response.rb', line 8 def request @request end |
Instance Method Details
#body ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/aviator/core/response.rb', line 16 def body @body ||= if raw_body.length > 0 if Aviator::Compatibility::RUBY_1_8_MODE clean_body = raw_body.gsub(/\\ /, ' ') else clean_body = raw_body end Hashish.new(JSON.parse(clean_body)) else Hashish.new({}) end end |
#headers ⇒ Object
31 32 33 |
# File 'lib/aviator/core/response.rb', line 31 def headers @headers ||= Hashish.new(@response.headers) end |
#to_hash ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/aviator/core/response.rb', line 36 def to_hash Hashish.new({ :status => status, :headers => headers, :body => body }) end |