class Pragma::Decorator::Pagination::Adapter::WillPaginate

This adapter provides support for retrieving pagination information from collections paginated with {github.com/mislav/will_paginate will_paginate}.

@api private

Public Class Methods

supports?(collection) click to toggle source

Returns whether this adapter supports the given collection.

Esnures that the WillPaginate constant is defined and that the collection responds to #previous_page.

@return [Boolean] whether the adapter supports the given collection

@see Adapter.load_adaptor

# File lib/pragma/decorator/pagination/adapter/will_paginate.rb, line 23
def supports?(collection)
  Object.const_defined?('WillPaginate') && collection.respond_to?(:previous_page)
end

Public Instance Methods

current_page() click to toggle source

Returns the number of the current page.

@return [Integer] the number of the current page

# File lib/pragma/decorator/pagination/adapter/will_paginate.rb, line 59
def current_page
  collection.current_page
end
next_page() click to toggle source

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/will_paginate.rb, line 66
def next_page
  collection.next_page
end
per_page() click to toggle source

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/will_paginate.rb, line 38
def per_page
  collection.per_page
end
previous_page() click to toggle source

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/will_paginate.rb, line 52
def previous_page
  collection.previous_page
end
total_entries() click to toggle source

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/will_paginate.rb, line 31
def total_entries
  collection.total_entries
end
total_pages() click to toggle source

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/will_paginate.rb, line 45
def total_pages
  collection.total_pages
end