Class: Noiseless::Pagination::KeysetResult

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/noiseless/pagination.rb

Overview

Keyset paginated result

Instance Attribute Summary collapse

Instance Method Summary collapse

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_moreObject (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_cursorObject (readonly)

Returns the value of attribute next_cursor.



100
101
102
# File 'lib/noiseless/pagination.rb', line 100

def next_cursor
  @next_cursor
end

#recordsObject (readonly)

Returns the value of attribute records.



100
101
102
# File 'lib/noiseless/pagination.rb', line 100

def records
  @records
end

Instance Method Details

#eachObject



108
109
110
# File 'lib/noiseless/pagination.rb', line 108

def each(&)
  records.each(&)
end

#pagination_metadataObject

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_aObject



114
115
116
# File 'lib/noiseless/pagination.rb', line 114

def to_a
  records
end