Class: Ryext::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/ryext/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#queryObject (readonly)

Returns the value of attribute query.



3
4
5
# File 'lib/ryext/response.rb', line 3

def query
  @query
end

Instance Method Details

#codeObject



14
15
16
# File 'lib/ryext/response.rb', line 14

def code
  @code ||= @raw_response.code
end

#collectionObject



18
19
20
# File 'lib/ryext/response.rb', line 18

def collection
  data[query.parent_klass::COLLECTION_KEY]
end

#dataObject



10
11
12
# File 'lib/ryext/response.rb', line 10

def data
  @data ||= JSON.parse(@raw_response)
end