Class: Cygnet::PaginatedCollection
- Inherits:
-
MappedCollection
- Object
- Array
- MappedCollection
- Cygnet::PaginatedCollection
- Defined in:
- lib/cygnet/collections.rb
Overview
Easy API for paginated collections
Instance Attribute Summary collapse
-
#current_page ⇒ Object
Returns the value of attribute current_page.
-
#total_entries ⇒ Object
Returns the value of attribute total_entries.
-
#total_pages ⇒ Object
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#initialize(builder, records, pagination = {}) ⇒ PaginatedCollection
constructor
A new instance of PaginatedCollection.
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_page ⇒ Object
Returns the value of attribute current_page.
16 17 18 |
# File 'lib/cygnet/collections.rb', line 16 def current_page @current_page end |
#total_entries ⇒ Object
Returns the value of attribute total_entries.
16 17 18 |
# File 'lib/cygnet/collections.rb', line 16 def total_entries @total_entries end |
#total_pages ⇒ Object
Returns the value of attribute total_pages.
16 17 18 |
# File 'lib/cygnet/collections.rb', line 16 def total_pages @total_pages end |