Module: Folio::WillPaginate::ActiveRecord::Pagination

Includes:
Ordinal
Defined in:
lib/folio/will_paginate/active_record.rb

Constant Summary

Constants included from Folio

VERSION

Instance Method Summary collapse

Methods included from Ordinal

#configure_pagination

Methods included from Folio

#configure_pagination, #paginate

Methods included from PerPageIncluder

#included

Methods included from PerPage

#per_page

Instance Method Details

#build_pageObject



48
49
50
# File 'lib/folio/will_paginate/active_record.rb', line 48

def build_page
  Folio::Ordinal::Page.create
end

#default_per_pageObject

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(options={})
  unless options.has_key?(:total_entries)
    page = (options.fetch(:page) { 1 }).to_i
    per_page = (options.fetch(:per_page) { self.per_page }).to_i
    offset = (page - 1) * per_page
    options[:total_entries] = wp_count({}, [:all, {offset: offset, limit: per_page}], 'find')
  end
  paginate_without_wp_count(options)
end