class DynamicScaffold::List::Pagination

Attributes

end_buttons[R]
gap_buttons[R]
highlight_current[R]
kaminari_options[R]
neighbor_buttons[R]
param_name[R]
per_page[R]
total_count[R]

Public Class Methods

new(options) click to toggle source
# File lib/dynamic_scaffold/list/pagination.rb, line 14
def initialize(options)
  options = {
    per_page: 25,
    window: 0,                # kaminari options
    outer_window: 0,          # kaminari options
    left: 0,                  # kaminari options
    right: 0,                 # kaminari options
    param_name: :page,        # kaminari options
    total_count: true,        # Whether to display total count on active page like `2 / 102`
    end_buttons: true,        # Whether to display buttons to the first and last page.
    neighbor_buttons: true,   # Whether to display buttons to the next and prev page.
    gap_buttons: false,       # Whether to display gap buttons.
    highlight_current: false # Whether to highlight the current page.
  }.merge(options)
  @kaminari_options = options.extract!(:window, :outer_window, :left, :right, :param_name)
  @param_name = @kaminari_options[:param_name]
  options.each {|name, value| instance_variable_set("@#{name}", value) }
end

Public Instance Methods

page_class(page, _records) click to toggle source
# File lib/dynamic_scaffold/list/pagination.rb, line 39
def page_class(page, _records)
  if page.inside_window?
    'inner'
  elsif page.left_outer?
    'left-outer'
  elsif page.right_outer?
    'right-outer'
  end
end
page_number(page, records) click to toggle source
# File lib/dynamic_scaffold/list/pagination.rb, line 33
def page_number(page, records)
  return page unless total_count

  "#{page} / #{records.total_pages}"
end