Module: Neo4j::WillPaginate::Pagination
- Includes:
- WillPaginate::CollectionMethods
- Defined in:
- lib/neo4j-will_paginate.rb
Overview
The module provides the common interface for the pagination on any Enumerable class. By including the module, #paginate method will be available.
Instance Method Summary collapse
-
#paginate(options = {}) ⇒ Object
Paginates the Enumerable and returns WillPaginate::Collection instance.
Instance Method Details
#paginate(options = {}) ⇒ Object
Paginates the Enumerable and returns WillPaginate::Collection instance.
27 28 29 30 31 32 33 34 35 |
# File 'lib/neo4j-will_paginate.rb', line 27 def paginate(={}) page = ([:page] || 1).to_i per_page = ([:per] || [:per_page] || [:limit] || ::WillPaginate.per_page).to_i ::WillPaginate::Collection.create(page, per_page) do |pager| res = ::Neo4j::Paginated.create_from(self, page, per_page) pager.replace res.to_a pager.total_entries = res.total unless pager.total_entries end end |