Class: Koala::HTTPService::Response
- Inherits:
-
Object
- Object
- Koala::HTTPService::Response
- Defined in:
- lib/koala/http_service/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(status, body, headers) ⇒ Response
constructor
Creates a new Response object, which standardizes the response received by Facebook for use within Koala.
Constructor Details
#initialize(status, body, headers) ⇒ Response
Creates a new Response object, which standardizes the response received by Facebook for use within Koala.
7 8 9 10 11 |
# File 'lib/koala/http_service/response.rb', line 7 def initialize(status, body, headers) @status = status @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/koala/http_service/response.rb', line 4 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
4 5 6 |
# File 'lib/koala/http_service/response.rb', line 4 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/koala/http_service/response.rb', line 4 def status @status end |
Instance Method Details
#data ⇒ Object
13 14 15 16 17 |
# File 'lib/koala/http_service/response.rb', line 13 def data # quirks_mode is needed because Facebook sometimes returns a raw true or false value -- # in Ruby 2.4 we can drop that. @data ||= JSON.parse(body, quirks_mode: true) unless body.empty? end |