Class: Basecamp::ListEnumerator
- Inherits:
-
Enumerator
- Object
- Enumerator
- Basecamp::ListEnumerator
- Defined in:
- lib/basecamp/list_enumerator.rb
Overview
A lazy Enumerator over paginated items that carries pagination metadata.
Behaves exactly like the plain Enumerator it replaces — each/next/peek/ take/first/lazy all work, and pages beyond the first are fetched only as iteration demands them — while additionally exposing #meta.
The metadata object is shared with the paginator: meta.total_count is populated from the eagerly fetched first page, and meta.truncated is finalized by consuming the enumeration (see ListMeta).
Re-enumerating restarts pagination: the eagerly fetched first page is served from memory on the first pass only, and later passes refetch every page for a consistent snapshot, refreshing meta from their own first-page response — metadata always describes the most recent traversal.
Instance Attribute Summary collapse
-
#meta ⇒ ListMeta
readonly
Pagination metadata.
Instance Method Summary collapse
-
#initialize(meta, &block) ⇒ ListEnumerator
constructor
A new instance of ListEnumerator.
Constructor Details
#initialize(meta, &block) ⇒ ListEnumerator
Returns a new instance of ListEnumerator.
24 25 26 27 |
# File 'lib/basecamp/list_enumerator.rb', line 24 def initialize(, &block) @meta = super(&block) end |
Instance Attribute Details
#meta ⇒ ListMeta (readonly)
Returns pagination metadata.
21 22 23 |
# File 'lib/basecamp/list_enumerator.rb', line 21 def @meta end |