Module: Pagination

Defined in:
app/helpers/kit/pagination.rb

Instance Method Summary collapse

Instance Method Details

#paginator_for(page, entries_count, per_page, &to_link) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/kit/pagination.rb', line 2

def paginator_for page, entries_count, per_page, &to_link
  page.must_be >= 1
  return if page == 1 and entries_count < per_page

  opt = {
    current_page: page,
    pages: [], #(go_prev + [current] + go_next),
    to_link: to_link
  }

  opt[:prev] = to_link.call(t(:go_prev), page - 1) if page > 1
  opt[:next] = to_link.call(t(:go_next), page + 1)

  b.paginator opt
end