class

Polar::PaginatedIterator(T)

Inherits Iterator < Enumerable < Reference < Object

Lazy iterator for paginated API responses

Automatically fetches pages as needed, yielding items one at a time. Implements Crystal's Iterator(T) protocol for full iterator support.

@param T The type of items being iterated

Constants

Log = ::Log.for(self)

Constructors

new(fetcher : Int32 -> Models::ListResource(T), limit : Int32 | Nil = nil)

Creates a new paginated iterator

@param fetcher A proc that fetches a page given a page number @param limit Optional page size (defaults to API default)

Source

Instance methods

next

Returns the next item in the iteration

Automatically fetches the next page when the current page is exhausted. Returns Iterator::Stop when all pages have been consumed.

@return The next item or Iterator::Stop

Source
rewind

Rewinds the iterator to the beginning

This will cause the iterator to start fetching from page 1 again.

Source