Class: Basecamp::ListMeta
- Inherits:
-
Object
- Object
- Basecamp::ListMeta
- Defined in:
- lib/basecamp/list_meta.rb
Overview
Pagination metadata carried by ListEnumerator.
total_count comes from the X-Total-Count header on the first page (0 when absent) and is available as soon as the list call returns, because the first page is fetched eagerly.
truncated starts false and flips to true when enumeration discovers that items beyond those yielded were available: items dropped by a max_items cap, or a next Link left unfetched when the max_items or max_pages cap stopped pagination. It is final only once enumeration completes; landing exactly on the final item is not truncation.
Instance Attribute Summary collapse
-
#total_count ⇒ Integer
readonly
Total item count from X-Total-Count (0 if absent).
-
#truncated ⇒ Boolean
(also: #truncated?)
readonly
Whether items beyond those yielded were available.
Instance Method Summary collapse
-
#initialize(total_count: 0) ⇒ ListMeta
constructor
A new instance of ListMeta.
-
#mark_truncated! ⇒ Object
private
Records that truncation was discovered during enumeration.
-
#restart!(total_count:) ⇒ Object
private
Re-initializes the metadata when a traversal restarts, so it describes the restarted pass's own snapshot rather than a previous traversal's.
Constructor Details
#initialize(total_count: 0) ⇒ ListMeta
Returns a new instance of ListMeta.
25 26 27 28 |
# File 'lib/basecamp/list_meta.rb', line 25 def initialize(total_count: 0) @total_count = total_count @truncated = false end |
Instance Attribute Details
#total_count ⇒ Integer (readonly)
Returns total item count from X-Total-Count (0 if absent).
17 18 19 |
# File 'lib/basecamp/list_meta.rb', line 17 def total_count @total_count end |
#truncated ⇒ Boolean (readonly) Also known as: truncated?
Returns whether items beyond those yielded were available.
20 21 22 |
# File 'lib/basecamp/list_meta.rb', line 20 def truncated @truncated end |
Instance Method Details
#mark_truncated! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Records that truncation was discovered during enumeration.
32 33 34 |
# File 'lib/basecamp/list_meta.rb', line 32 def mark_truncated! @truncated = true end |
#restart!(total_count:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Re-initializes the metadata when a traversal restarts, so it describes the restarted pass's own snapshot rather than a previous traversal's.
39 40 41 42 |
# File 'lib/basecamp/list_meta.rb', line 39 def restart!(total_count:) @total_count = total_count @truncated = false end |