2011-06-08 11:37:26 -04:00
|
|
|
require 'kaminari/models/mongoid_criteria_methods'
|
2011-04-19 03:05:18 -04:00
|
|
|
|
2011-02-16 01:23:41 -05:00
|
|
|
module Kaminari
|
2011-02-18 00:52:17 -05:00
|
|
|
module MongoidExtension
|
2011-02-17 18:07:23 -05:00
|
|
|
module Document
|
|
|
|
extend ActiveSupport::Concern
|
2011-02-19 23:04:18 -05:00
|
|
|
include Kaminari::ConfigurationMethods
|
2011-02-17 18:07:23 -05:00
|
|
|
|
|
|
|
included do
|
2014-12-15 00:05:47 -05:00
|
|
|
scope Kaminari.config.page_method_name, Proc.new {|num|
|
2014-12-26 07:29:16 -05:00
|
|
|
limit(default_per_page).offset(default_per_page * ((num = num.to_i - 1) < 0 ? 0 : num))
|
2014-12-15 00:05:47 -05:00
|
|
|
} do
|
|
|
|
include Kaminari::MongoidCriteriaMethods
|
|
|
|
include Kaminari::PageScopeMethods
|
|
|
|
end
|
2015-02-11 01:34:35 -05:00
|
|
|
end
|
2014-12-15 00:03:16 -05:00
|
|
|
|
2015-02-11 01:34:35 -05:00
|
|
|
module ClassMethods
|
|
|
|
def inherited(kls)
|
|
|
|
super
|
|
|
|
kls.send(:include, Kaminari::MongoidExtension::Document.dup)
|
|
|
|
end
|
2014-12-15 00:03:16 -05:00
|
|
|
end
|
2011-02-17 18:07:23 -05:00
|
|
|
end
|
2011-02-16 01:23:41 -05:00
|
|
|
end
|
|
|
|
end
|