Module: Folio::WillPaginate::ActiveRecord::RelationMethods

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

Instance Attribute Summary

Attributes included from Page

#current_page, #first_page, #next_page, #ordinal_pages, #previous_page, #total_entries

Instance Method Summary collapse

Methods included from Ordinal::Page

create, #current_page=, #first_page, #last_page, #next_page, #next_page=, #offset, #ordinal_pages, #out_of_bounds?, #previous_page

Methods included from Page

create, #last_page, #last_page=, #total_pages

Methods included from PerPage

#default_per_page

Instance Method Details

#countObject

overrides WillPaginate’s weird “ignore limit when counting” behavior. I can’t fall back on super in the branch with a limit_value, since that would fall into WillPaginate’s lap, but since there is a limit_value, safe enough to just instantiate and check length



46
47
48
49
50
51
52
# File 'lib/folio/will_paginate/active_record.rb', line 46

def count
  if limit_value
    to_a.size
  else
    super
  end
end

#per_page(*args) ⇒ Object

overrides Folio::Page’s per_page similar to WillPaginate’s version, but uses correct semantics for per_page(nil) (vs. per_page()).



33
34
35
36
37
38
39
40
# File 'lib/folio/will_paginate/active_record.rb', line 33

def per_page(*args)
  if args.size > 0
    raise ArgumentError if args.size > 1
    value ||= @klass.per_page
    limit(value)
  end
  limit_value
end