Sha256: 1b837cc8accd62c66557c5bc92b586568d3577677af9218978d1537ec6e82b0e

Contents?: true

Size: 719 Bytes

Versions: 1

Compression:

Stored size: 719 Bytes

Contents

require 'kaminari/mongoid/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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kaminari-mongoid-0.1.0 lib/kaminari/mongoid/mongoid_extension.rb