9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/sequel/paginate/realization.rb', line 9
def self.extended(base)
class << base
def paginate_per(count = 20)
@paginate_per ||= count
end
end
base.class_eval do
dataset_module do
define_method(:page) do |*args, &block|
begin
page_per = args[1][:page_per]
rescue
page_per = nil
end
page_no = args[0].to_i
page_no = page_no > 0 ? page_no : 1
where.extension(:pagination).paginate(page_no.to_i, page_per || self.model.paginate_per)
end
end
end
end
|