class Pragma::Decorator::Pagination::Adapter::Kaminari
This adapter provides support for retireving pagination information from collections paginated with {github.com/kaminari/kaminari Kaminari}.
@api private
Public Class Methods
Returns whether this adapter supports the given collection.
Esnures that the Kaminari
constant is defined and that the collection responds to #prev_page
.
@return [Boolean] whether the adapter supports the given collection
@see Adapter.load_adaptor
# File lib/pragma/decorator/pagination/adapter/kaminari.rb, line 21 def supports?(collection) Object.const_defined?('Kaminari') && collection.respond_to?(:prev_page) end
Public Instance Methods
Returns the number of the current page.
@return [Integer] the number of the current page
# File lib/pragma/decorator/pagination/adapter/kaminari.rb, line 57 def current_page collection.current_page end
Returns the number of the next page, if any.
@return [Integer|NilClass] the number of the next page, if any
# File lib/pragma/decorator/pagination/adapter/kaminari.rb, line 64 def next_page collection.next_page end
Returns the number of entries per page in the collection.
@return [Integer] the number of entries per page in the collection
# File lib/pragma/decorator/pagination/adapter/kaminari.rb, line 36 def per_page collection.limit_value end
Returns the number of the previous page, if any.
@return [Integer|NilClass] the number of the previous page, if any
# File lib/pragma/decorator/pagination/adapter/kaminari.rb, line 50 def previous_page collection.prev_page end
Returns the total number of entries in the collection.
@return [Integer] the total number of entries in the collection
# File lib/pragma/decorator/pagination/adapter/kaminari.rb, line 29 def total_entries collection.total_count end
Returns the total number of pages in the collection.
@return [Integer] the total number of pages in the collection
# File lib/pragma/decorator/pagination/adapter/kaminari.rb, line 43 def total_pages collection.total_pages end