Class: Candid::Internal::ItemIterator
- Inherits:
-
Object
- Object
- Candid::Internal::ItemIterator
- Includes:
- Enumerable
- Defined in:
- lib/candid/internal/iterators/item_iterator.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#each(&block) ⇒ NilClass
Iterates over each item returned by the API.
-
#get_next ⇒ Object
Retrieves the next item from the API.
-
#has_next? ⇒ Boolean
Whether another item will be available from the API.
Instance Method Details
#each(&block) ⇒ NilClass
Iterates over each item returned by the API.
12 13 14 15 16 |
# File 'lib/candid/internal/iterators/item_iterator.rb', line 12 def each(&block) while (item = get_next) block.call(item) end end |
#get_next ⇒ Object
Retrieves the next item from the API.
32 33 34 35 36 37 38 |
# File 'lib/candid/internal/iterators/item_iterator.rb', line 32 def get_next item = next_item_from_cached_page return item if item load_next_page next_item_from_cached_page end |
#has_next? ⇒ Boolean
Whether another item will be available from the API.
21 22 23 24 25 26 27 28 29 |
# File 'lib/candid/internal/iterators/item_iterator.rb', line 21 def has_next? load_next_page if @page.nil? return false if @page.nil? return true if any_items_in_cached_page load_next_page any_items_in_cached_page end |