Module: Folio::WillPaginate::ActiveRecord::Pagination
- Includes:
- Ordinal
- Defined in:
- lib/folio/will_paginate/active_record.rb
Constant Summary
Constants included from Folio
Instance Method Summary collapse
- #build_page ⇒ Object
-
#default_per_page ⇒ Object
don’t try and look at Class (ActiveRecord::Base.class, etc.) for defaults.
-
#fill_page(page) ⇒ Object
load the results and place them in the page.
- #paginate_with_wp_count(options = {}) ⇒ Object
Methods included from Ordinal
Methods included from Folio
#configure_pagination, #paginate
Methods included from PerPageIncluder
Methods included from PerPage
Instance Method Details
#build_page ⇒ Object
48 49 50 |
# File 'lib/folio/will_paginate/active_record.rb', line 48 def build_page Folio::Ordinal::Page.create end |
#default_per_page ⇒ Object
don’t try and look at Class (ActiveRecord::Base.class, etc.) for defaults
60 61 62 |
# File 'lib/folio/will_paginate/active_record.rb', line 60 def default_per_page Folio.per_page end |
#fill_page(page) ⇒ Object
load the results and place them in the page
53 54 55 56 |
# File 'lib/folio/will_paginate/active_record.rb', line 53 def fill_page(page) page.replace self.find(:all, offset: page.offset, limit: page.per_page) page end |
#paginate_with_wp_count(options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/folio/will_paginate/active_record.rb', line 37 def paginate_with_wp_count(={}) unless .has_key?(:total_entries) page = (.fetch(:page) { 1 }).to_i per_page = (.fetch(:per_page) { self.per_page }).to_i offset = (page - 1) * per_page [:total_entries] = wp_count({}, [:all, {offset: offset, limit: per_page}], 'find') end paginate_without_wp_count() end |