Module: Split::DashboardPaginationHelpers

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

Instance Method Summary collapse

Instance Method Details

#page_numberObject



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

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

#paginated(collection) ⇒ Object



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

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

#pagination(collection) ⇒ Object



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

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



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

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