Class: RestChain::RestResponse
- Inherits:
-
Object
- Object
- RestChain::RestResponse
- Defined in:
- lib/rest_chain/rest_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
-
#initialize(status, headers, body) ⇒ RestResponse
constructor
A new instance of RestResponse.
- #json(options = {}) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(status, headers, body) ⇒ RestResponse
Returns a new instance of RestResponse.
5 6 7 8 9 |
# File 'lib/rest_chain/rest_response.rb', line 5 def initialize(status, headers, body) @status = status @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
10 11 12 |
# File 'lib/rest_chain/rest_response.rb', line 10 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
10 11 12 |
# File 'lib/rest_chain/rest_response.rb', line 10 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/rest_chain/rest_response.rb', line 10 def status @status end |
Instance Method Details
#json(options = {}) ⇒ Object
16 17 18 |
# File 'lib/rest_chain/rest_response.rb', line 16 def json(={}) JSON.parse(body, ) end |
#success? ⇒ Boolean
12 13 14 |
# File 'lib/rest_chain/rest_response.rb', line 12 def success? (200..299).include?(@status) end |