1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

change scope to class method

This commit is contained in:
Yuriy Kolodovskyy 2013-09-12 00:49:34 +03:00
parent 6471b9343e
commit 92052eedf0

View file

@ -6,14 +6,16 @@ module Kaminari
included do
self.send(:include, Kaminari::ConfigurationMethods)
end
module ClassMethods
# Fetch the values at the specified page number
# Model.page(5)
self.scope Kaminari.config.page_method_name, Proc.new {|num|
limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1))
} do
include Kaminari::ActiveRecordRelationMethods
include Kaminari::PageScopeMethods
define_method(Kaminari.config.page_method_name) do |num = nil|
limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1)).extending do
include Kaminari::ActiveRecordRelationMethods
include Kaminari::PageScopeMethods
end
end
end
end