Class: Deliverhq::Response
- Inherits:
-
Object
- Object
- Deliverhq::Response
- Defined in:
- lib/deliverhq/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
-
#initialize(server_response) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(server_response) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 12 13 14 |
# File 'lib/deliverhq/response.rb', line 6 def initialize(server_response) if server_response.status == 200 @body = server_response.body.strip.length > 0 ? JSON.parse(server_response.body) : server_response.body else raise RequestError, "Server responded with #{server_response.status}: #{server_response.body}" end rescue JSON::ParserError @body = server_response.body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/deliverhq/response.rb', line 4 def body @body end |