Class: Pragma::Decorator::Pagination::Adapter::WillPaginate Private

Inherits:
Base
  • Object
show all
Defined in:
lib/pragma/decorator/pagination/adapter/will_paginate.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 will_paginate.

Instance Attribute Summary

Attributes inherited from Base

#collection

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

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 WillPaginate constant is defined and that the collection responds to #previous_page.

Returns:

  • (Boolean)

    whether the adapter supports the given collection

See Also:



21
22
23
# File 'lib/pragma/decorator/pagination/adapter/will_paginate.rb', line 21

def supports?(collection)
  Object.const_defined?('WillPaginate') && collection.respond_to?(:previous_page)
end

Instance Method Details

#current_pageInteger

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.

Returns:

  • (Integer)

    the number of the current page



57
58
59
# File 'lib/pragma/decorator/pagination/adapter/will_paginate.rb', line 57

def current_page
  collection.current_page
end

#next_pageInteger|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.

Returns:

  • (Integer|NilClass)

    the number of the next page, if any



64
65
66
# File 'lib/pragma/decorator/pagination/adapter/will_paginate.rb', line 64

def next_page
  collection.next_page
end

#per_pageInteger

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.

Returns:

  • (Integer)

    the number of entries per page in the collection



36
37
38
# File 'lib/pragma/decorator/pagination/adapter/will_paginate.rb', line 36

def per_page
  collection.per_page
end

#previous_pageInteger|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.

Returns:

  • (Integer|NilClass)

    the number of the previous page, if any



50
51
52
# File 'lib/pragma/decorator/pagination/adapter/will_paginate.rb', line 50

def previous_page
  collection.previous_page
end

#total_entriesInteger

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.

Returns:

  • (Integer)

    the total number of entries in the collection



29
30
31
# File 'lib/pragma/decorator/pagination/adapter/will_paginate.rb', line 29

def total_entries
  collection.total_entries
end

#total_pagesInteger

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.

Returns:

  • (Integer)

    the total number of pages in the collection



43
44
45
# File 'lib/pragma/decorator/pagination/adapter/will_paginate.rb', line 43

def total_pages
  collection.total_pages
end