Class: Yamori::Rest::QueryResult
- Inherits:
-
Object
- Object
- Yamori::Rest::QueryResult
- Defined in:
- lib/yamori/rest/query_result.rb
Instance Method Summary collapse
- #done? ⇒ Boolean (also: #completed?)
-
#initialize(api_response) ⇒ QueryResult
constructor
A new instance of QueryResult.
- #next_records_url ⇒ Object
- #to_records(model_class: nil) ⇒ Object
- #total_size ⇒ Object
Constructor Details
#initialize(api_response) ⇒ QueryResult
Returns a new instance of QueryResult.
4 5 6 |
# File 'lib/yamori/rest/query_result.rb', line 4 def initialize(api_response) @response = JSON.parse(api_response) end |
Instance Method Details
#done? ⇒ Boolean Also known as: completed?
12 13 14 |
# File 'lib/yamori/rest/query_result.rb', line 12 def done? @done ||= response['done'] end |
#next_records_url ⇒ Object
18 19 20 |
# File 'lib/yamori/rest/query_result.rb', line 18 def next_records_url @next_records_url ||= response['nextRecordsUrl'] end |
#to_records(model_class: nil) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/yamori/rest/query_result.rb', line 22 def to_records(model_class: nil) records.each_with_object([]) do |h, a| record = prepare_record(h) a << (model_class ? model_class.new(**record) : record) end end |
#total_size ⇒ Object
8 9 10 |
# File 'lib/yamori/rest/query_result.rb', line 8 def total_size @total_size ||= response['totalSize'] end |