Module: Pagy::CountlessPaginator

Defined in:
lib/pagy/toolbox/paginators/countless.rb

Class Method Summary collapse

Class Method Details

.paginate(collection, options) ⇒ Object

Return the Offset::Countless instance and records



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pagy/toolbox/paginators/countless.rb', line 8

def paginate(collection, options)
  options[:page] ||= options[:request].resolve_page(force_integer: false) # accept nil and strings
  if options[:page].is_a?(String)
    page, last     = options[:page].split.map(&:to_i) # decoded '+' added by the compose_page_url
    options[:page] = page
    options[:last] = last if last&.positive?
  end
  options[:limit] = options[:request].resolve_limit
  pagy            = Offset::Countless.new(**options)
  [pagy, pagy.records(collection)]
end