Class: Cygnet::PaginatedCollection

Inherits:
MappedCollection show all
Defined in:
lib/cygnet/collections.rb

Overview

Easy API for paginated collections

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder, records, pagination = {}) ⇒ PaginatedCollection

Returns a new instance of PaginatedCollection.



18
19
20
21
22
23
24
25
26
# File 'lib/cygnet/collections.rb', line 18

def initialize(builder, records, pagination = {})
  paginated = records.paginate(pagination)

  @total_pages = paginated.total_pages
  @current_page = paginated.current_page
  @total_entries = paginated.total_entries

  super builder, paginated
end

Instance Attribute Details

#current_pageObject

Returns the value of attribute current_page.



16
17
18
# File 'lib/cygnet/collections.rb', line 16

def current_page
  @current_page
end

#total_entriesObject

Returns the value of attribute total_entries.



16
17
18
# File 'lib/cygnet/collections.rb', line 16

def total_entries
  @total_entries
end

#total_pagesObject

Returns the value of attribute total_pages.



16
17
18
# File 'lib/cygnet/collections.rb', line 16

def total_pages
  @total_pages
end