Class: Noiseless::Pagination::KeysetResult
- Inherits:
-
Object
- Object
- Noiseless::Pagination::KeysetResult
- Includes:
- Enumerable
- Defined in:
- lib/noiseless/pagination.rb
Overview
Keyset paginated result
Instance Attribute Summary collapse
-
#has_more ⇒ Object
readonly
Returns the value of attribute has_more.
-
#next_cursor ⇒ Object
readonly
Returns the value of attribute next_cursor.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(records, next_cursor: nil, has_more: false) ⇒ KeysetResult
constructor
A new instance of KeysetResult.
-
#pagination_metadata ⇒ Object
JSON serialization for API responses.
- #to_a ⇒ Object
Constructor Details
#initialize(records, next_cursor: nil, has_more: false) ⇒ KeysetResult
Returns a new instance of KeysetResult.
102 103 104 105 106 |
# File 'lib/noiseless/pagination.rb', line 102 def initialize(records, next_cursor: nil, has_more: false) @records = records @next_cursor = next_cursor @has_more = has_more end |
Instance Attribute Details
#has_more ⇒ Object (readonly)
Returns the value of attribute has_more.
100 101 102 |
# File 'lib/noiseless/pagination.rb', line 100 def has_more @has_more end |
#next_cursor ⇒ Object (readonly)
Returns the value of attribute next_cursor.
100 101 102 |
# File 'lib/noiseless/pagination.rb', line 100 def next_cursor @next_cursor end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
100 101 102 |
# File 'lib/noiseless/pagination.rb', line 100 def records @records end |
Instance Method Details
#each ⇒ Object
108 109 110 |
# File 'lib/noiseless/pagination.rb', line 108 def each(&) records.each(&) end |
#pagination_metadata ⇒ Object
JSON serialization for API responses
123 124 125 126 127 128 |
# File 'lib/noiseless/pagination.rb', line 123 def { has_more: has_more, next_cursor: next_cursor&.encode } end |
#to_a ⇒ Object
114 115 116 |
# File 'lib/noiseless/pagination.rb', line 114 def to_a records end |