Class: CursorResponseCollection
Constant Summary
ResponseCollection::DEFAULT_NO_THREADS
Instance Attribute Summary collapse
#load_more_call, #paged_objects, #per_page
Instance Method Summary
collapse
Constructor Details
Returns a new instance of CursorResponseCollection.
5
6
7
8
9
10
|
# File 'lib/bright/cursor_response_collection.rb', line 5
def initialize(options = {})
@collected_objects = [options[:seed_page]].flatten
@per_page = options[:per_page].to_i
@load_more_call = options[:load_more_call]
@next_cursor = options[:next_cursor]
end
|
Instance Attribute Details
#collected_objects ⇒ Object
Returns the value of attribute collected_objects.
3
4
5
|
# File 'lib/bright/cursor_response_collection.rb', line 3
def collected_objects
@collected_objects
end
|
Instance Method Details
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/bright/cursor_response_collection.rb', line 12
def each
while (!@next_cursor.blank?) do
objects_hsh = load_more_call.call(@next_cursor)
objects = objects_hsh[:objects]
@next_cursor = objects_hsh[:next_cursor]
objects.each do |obj|
yield obj
end
@collected_objects += objects
end
end
|
#empty? ⇒ Boolean
41
42
43
|
# File 'lib/bright/cursor_response_collection.rb', line 41
def empty?
self.to_a.empty?
end
|
24
25
26
27
|
# File 'lib/bright/cursor_response_collection.rb', line 24
def last
self.to_a
return @collected_objects.last
end
|
#loaded_results ⇒ Object
29
30
31
|
# File 'lib/bright/cursor_response_collection.rb', line 29
def loaded_results
@collected_objects.flatten
end
|
#total ⇒ Object
Also known as:
size, length
33
34
35
36
|
# File 'lib/bright/cursor_response_collection.rb', line 33
def total
self.to_a
self.loaded_results.size
end
|