Module: Split::DashboardPaginationHelpers

Defined in:
lib/split/dashboard/pagination_helpers.rb

Instance Method Summary collapse

Instance Method Details

#page_numberObject



12
13
14
# File 'lib/split/dashboard/pagination_helpers.rb', line 12

def page_number
  @page_number ||= (params[:page] || 1).to_i
end

#paginated(collection) ⇒ Object



16
17
18
# File 'lib/split/dashboard/pagination_helpers.rb', line 16

def paginated(collection)
  Split::DashboardPaginator.new(collection, page_number, pagination_per).paginate
end

#pagination(collection) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/split/dashboard/pagination_helpers.rb', line 20

def pagination(collection)
  html = []
  html << first_page_tag if show_first_page_tag?
  html << ellipsis_tag if show_first_ellipsis_tag?
  html << prev_page_tag if show_prev_page_tag?
  html << current_page_tag
  html << next_page_tag if show_next_page_tag?(collection)
  html << ellipsis_tag if show_last_ellipsis_tag?(collection)
  html << last_page_tag(collection) if show_last_page_tag?(collection)
  html.join
end

#pagination_perObject



7
8
9
10
# File 'lib/split/dashboard/pagination_helpers.rb', line 7

def pagination_per
  default_per_page = Split.configuration.dashboard_pagination_default_per_page
  @pagination_per ||= (params[:per] || default_per_page).to_i
end