Class: Pina::RestAdapter::Response
- Inherits:
-
Object
- Object
- Pina::RestAdapter::Response
- Defined in:
- lib/pina/rest_adapter.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(status_code, body) ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(status_code, body) ⇒ Response
Returns a new instance of Response.
69 70 71 72 73 74 |
# File 'lib/pina/rest_adapter.rb', line 69 def initialize(status_code, body) raise Pina::ConnectionError if status_code == 0 @status_code = status_code @body = body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
67 68 69 |
# File 'lib/pina/rest_adapter.rb', line 67 def body @body end |
#status_code ⇒ Object
Returns the value of attribute status_code.
67 68 69 |
# File 'lib/pina/rest_adapter.rb', line 67 def status_code @status_code end |
Instance Method Details
#ok? ⇒ Boolean
76 77 78 |
# File 'lib/pina/rest_adapter.rb', line 76 def ok? status_code == 200 || status_code == 201 end |
#to_hash ⇒ Object
80 81 82 |
# File 'lib/pina/rest_adapter.rb', line 80 def to_hash JSON.parse(body) end |