1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00
kaminari--kaminari/lib/kaminari/models/mongoid_extension.rb
Yuki Nishijima e205ab305e Do not re-define the #page method on mongoid 5.0
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.
2016-01-02 15:34:52 +00:00

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