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

32 lines
770 B
Ruby
Raw Normal View History

require File.join(File.dirname(__FILE__), 'mongoid_criteria_methods')
2011-04-19 03:05:18 -04:00
2011-02-16 01:23:41 -05:00
module Kaminari
module MongoidExtension
module Criteria
extend ActiveSupport::Concern
included do
def page(*args)
self.klass.page(*args).criteria.merge(self)
end
end
end
module Document
extend ActiveSupport::Concern
include Kaminari::ConfigurationMethods
included do
# Fetch the values at the specified page number
# Model.page(5)
scope :page, Proc.new {|num|
limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1))
} do
include Kaminari::MongoidCriteriaMethods
include Kaminari::PageScopeMethods
end
end
end
2011-02-16 01:23:41 -05:00
end
end