Module: Transit::Model::Paginator::ClassMethods

Defined in:
lib/transit/model/paginator.rb

Instance Method Summary collapse

Instance Method Details

#deliver_per_page(*opts) ⇒ Object

Sets the default number of items per-page. Allows setting the option for both “admin” / management pages as well as a default for front-end pages.

Examples:

Set a default of 10, with a default of 20 for admin pages

per_page 10, admin: 20

Set a global default of 10

per_page 10


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/transit/model/paginator.rb', line 25

def deliver_per_page(*opts)
  options = opts.extract_options!
  if options.empty?
    pagination_options.merge!(default: opts.first, admin: opts.first)
  else
    pagination_options.merge!(options)
  end
  unless opts.empty?
    pagination_options.merge!(default: opts.first) unless opts.first.nil?
  end
end

#pagination_optionsObject



37
38
39
# File 'lib/transit/model/paginator.rb', line 37

def pagination_options
  @_pagination_options ||= { default: 10, admin: 20 }
end