Class: Ryext::Response
- Inherits:
-
Object
- Object
- Ryext::Response
- Defined in:
- lib/ryext/response.rb
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #code ⇒ Object
- #collection ⇒ Object
- #data ⇒ Object
-
#initialize(raw_response, query) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(raw_response, query) ⇒ Response
Returns a new instance of Response.
5 6 7 8 |
# File 'lib/ryext/response.rb', line 5 def initialize(raw_response, query) @raw_response = raw_response @query = query end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
3 4 5 |
# File 'lib/ryext/response.rb', line 3 def query @query end |
Instance Method Details
#code ⇒ Object
14 15 16 |
# File 'lib/ryext/response.rb', line 14 def code @code ||= @raw_response.code end |
#collection ⇒ Object
18 19 20 |
# File 'lib/ryext/response.rb', line 18 def collection data[query.parent_klass::COLLECTION_KEY] end |
#data ⇒ Object
10 11 12 |
# File 'lib/ryext/response.rb', line 10 def data @data ||= JSON.parse(@raw_response) end |