mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
e205ab305e
The issue reported on #567 doesn't appear on mongoid 5.0, so we don't need this hack any more. * https://github.com/amatsuda/kaminari/issues/567 * https://github.com/amatsuda/kaminari/issues/646#issuecomment-71754471 fixes #723.
26 lines
718 B
Ruby
26 lines
718 B
Ruby
require 'kaminari/models/mongoid_criteria_methods'
|
|
|
|
module Kaminari
|
|
module MongoidExtension
|
|
module Document
|
|
extend ActiveSupport::Concern
|
|
include Kaminari::ConfigurationMethods
|
|
|
|
included do
|
|
scope Kaminari.config.page_method_name, Proc.new {|num|
|
|
limit(default_per_page).offset(default_per_page * ((num = num.to_i - 1) < 0 ? 0 : num))
|
|
} do
|
|
include Kaminari::MongoidCriteriaMethods
|
|
include Kaminari::PageScopeMethods
|
|
end
|
|
end
|
|
|
|
module ClassMethods
|
|
def inherited(kls)
|
|
super
|
|
kls.send(:include, Kaminari::MongoidExtension::Document.dup)
|
|
end
|
|
end if Mongoid::VERSION < '5.0.0'
|
|
end
|
|
end
|
|
end
|