Class: Pragma::Decorator::Pagination::Adapter::Kaminari Private
- Defined in:
- lib/pragma/decorator/pagination/adapter/kaminari.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This adapter provides support for retireving pagination information from collections paginated with Kaminari.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.supports?(collection) ⇒ Boolean
private
Returns whether this adapter supports the given collection.
Instance Method Summary collapse
-
#current_page ⇒ Integer
private
Returns the number of the current page.
-
#next_page ⇒ Integer|NilClass
private
Returns the number of the next page, if any.
-
#per_page ⇒ Integer
private
Returns the number of entries per page in the collection.
-
#previous_page ⇒ Integer|NilClass
private
Returns the number of the previous page, if any.
-
#total_entries ⇒ Integer
private
Returns the total number of entries in the collection.
-
#total_pages ⇒ Integer
private
Returns the total number of pages in the collection.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Pragma::Decorator::Pagination::Adapter::Base
Class Method Details
.supports?(collection) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether this adapter supports the given collection.
Esnures that the Kaminari
constant is defined and that the collection responds to #prev_page
.
21 22 23 |
# File 'lib/pragma/decorator/pagination/adapter/kaminari.rb', line 21 def supports?(collection) Object.const_defined?('Kaminari') && collection.respond_to?(:prev_page) end |
Instance Method Details
#current_page ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the number of the current page.
57 58 59 |
# File 'lib/pragma/decorator/pagination/adapter/kaminari.rb', line 57 def current_page collection.current_page end |
#next_page ⇒ Integer|NilClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the number of the next page, if any.
64 65 66 |
# File 'lib/pragma/decorator/pagination/adapter/kaminari.rb', line 64 def next_page collection.next_page end |
#per_page ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the number of entries per page in the collection.
36 37 38 |
# File 'lib/pragma/decorator/pagination/adapter/kaminari.rb', line 36 def per_page collection.limit_value end |
#previous_page ⇒ Integer|NilClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the number of the previous page, if any.
50 51 52 |
# File 'lib/pragma/decorator/pagination/adapter/kaminari.rb', line 50 def previous_page collection.prev_page end |
#total_entries ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the total number of entries in the collection.
29 30 31 |
# File 'lib/pragma/decorator/pagination/adapter/kaminari.rb', line 29 def total_entries collection.total_count end |
#total_pages ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the total number of pages in the collection.
43 44 45 |
# File 'lib/pragma/decorator/pagination/adapter/kaminari.rb', line 43 def total_pages collection.total_pages end |