Module: Kaminari::Sequel::PageMethod

Included in:
DatasetExtension, ModelExtensionMethods::ClassMethods
Defined in:
lib/kaminari/sequel/page_method.rb

Instance Method Summary collapse

Instance Method Details

#page_method(num) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kaminari/sequel/page_method.rb', line 6

def page_method(num)
  per_page =
    if max_per_page && (default_per_page > max_per_page)
      max_per_page
    else
      default_per_page
    end

  limit(per_page)
    .offset(per_page * ((num = num.to_i - 1) < 0 ? 0 : num))
    .with_extend(
      Kaminari::Sequel::DatasetMethods,
      Kaminari::PageScopeMethods
    )
end