Class: ActiveItem::Pagination::PaginatedResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items:, next_cursor:, per_page:) ⇒ PaginatedResult

Returns a new instance of PaginatedResult.



29
30
31
32
33
# File 'lib/active_item/pagination.rb', line 29

def initialize(items:, next_cursor:, per_page:)
  @items = items
  @next_cursor = next_cursor
  @per_page = per_page
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



27
28
29
# File 'lib/active_item/pagination.rb', line 27

def items
  @items
end

#next_cursorObject (readonly)

Returns the value of attribute next_cursor.



27
28
29
# File 'lib/active_item/pagination.rb', line 27

def next_cursor
  @next_cursor
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



27
28
29
# File 'lib/active_item/pagination.rb', line 27

def per_page
  @per_page
end

Instance Method Details

#each(&block) ⇒ Object



43
# File 'lib/active_item/pagination.rb', line 43

def each(&block) = items.each(&block)

#empty?Boolean

Returns:

  • (Boolean)


47
# File 'lib/active_item/pagination.rb', line 47

def empty? = items.empty?

#has_more?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/active_item/pagination.rb', line 35

def has_more?
  !next_cursor.nil?
end

#lengthObject Also known as: size, count



44
# File 'lib/active_item/pagination.rb', line 44

def length = items.length

#pagination_metadataObject



39
40
41
# File 'lib/active_item/pagination.rb', line 39

def 
  { next_cursor: next_cursor, has_more: has_more?, per_page: per_page }
end

#to_aObject



48
# File 'lib/active_item/pagination.rb', line 48

def to_a = items