Class: Yamori::Rest::QueryResult

Inherits:
Object
  • Object
show all
Defined in:
lib/yamori/rest/query_result.rb

Instance Method Summary collapse

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?

Returns:

  • (Boolean)


12
13
14
# File 'lib/yamori/rest/query_result.rb', line 12

def done?
  @done ||= response['done']
end

#next_records_urlObject



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_sizeObject



8
9
10
# File 'lib/yamori/rest/query_result.rb', line 8

def total_size
  @total_size ||= response['totalSize']
end