Class: ActiveItem::Pagination::PaginatedResult
- Inherits:
-
Object
- Object
- ActiveItem::Pagination::PaginatedResult
- Includes:
- Enumerable
- Defined in:
- lib/active_item/pagination.rb
Overview
Enumerable wrapper around a page of results with cursor metadata.
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#next_cursor ⇒ Object
readonly
Returns the value of attribute next_cursor.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
Instance Method Summary collapse
- #each ⇒ Object
- #empty? ⇒ Boolean
- #has_more? ⇒ Boolean
-
#initialize(items:, next_cursor:, per_page:) ⇒ PaginatedResult
constructor
A new instance of PaginatedResult.
- #length ⇒ Object (also: #size, #count)
- #pagination_metadata ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(items:, next_cursor:, per_page:) ⇒ PaginatedResult
Returns a new instance of PaginatedResult.
32 33 34 35 36 |
# File 'lib/active_item/pagination.rb', line 32 def initialize(items:, next_cursor:, per_page:) @items = items @next_cursor = next_cursor @per_page = per_page end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
30 31 32 |
# File 'lib/active_item/pagination.rb', line 30 def items @items end |
#next_cursor ⇒ Object (readonly)
Returns the value of attribute next_cursor.
30 31 32 |
# File 'lib/active_item/pagination.rb', line 30 def next_cursor @next_cursor end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
30 31 32 |
# File 'lib/active_item/pagination.rb', line 30 def per_page @per_page end |
Instance Method Details
#each ⇒ Object
46 |
# File 'lib/active_item/pagination.rb', line 46 def each(&) = items.each(&) |
#empty? ⇒ Boolean
50 |
# File 'lib/active_item/pagination.rb', line 50 def empty? = items.empty? |
#has_more? ⇒ Boolean
38 39 40 |
# File 'lib/active_item/pagination.rb', line 38 def has_more? !next_cursor.nil? end |
#length ⇒ Object Also known as: size, count
47 |
# File 'lib/active_item/pagination.rb', line 47 def length = items.length |
#pagination_metadata ⇒ Object
42 43 44 |
# File 'lib/active_item/pagination.rb', line 42 def { next_cursor: next_cursor, has_more: has_more?, per_page: per_page } end |
#to_a ⇒ Object
51 |
# File 'lib/active_item/pagination.rb', line 51 def to_a = items |