Sha256: 26aa21876eff590db6bb1768a55a7013a2046b1ca801fe5759401d5b185335c5

Contents?: true

Size: 869 Bytes

Versions: 12

Compression:

Stored size: 869 Bytes

Contents

require 'kaminari/models/mongoid_criteria_methods'

module Kaminari
  module MongoidExtension
    module Criteria
      extend ActiveSupport::Concern

      included do
        class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{Kaminari.config.page_method_name}(*args)
            super(*args).criteria.merge(self)
          end
        RUBY
      end
    end

    module Document
      extend ActiveSupport::Concern
      include Kaminari::ConfigurationMethods

      included do
        # Fetch the values at the specified page number
        #   Model.page(5)
        scope Kaminari.config.page_method_name, 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
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
kaminari-0.15.1 lib/kaminari/models/mongoid_extension.rb
kaminari-0.15.0 lib/kaminari/models/mongoid_extension.rb
kaminari-rails4-0.15.0 lib/kaminari/models/mongoid_extension.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/kaminari-0.14.1/lib/kaminari/models/mongoid_extension.rb
kaminari-0.14.1 lib/kaminari/models/mongoid_extension.rb
kaminari-0.14.0 lib/kaminari/models/mongoid_extension.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/kaminari-0.13.0/lib/kaminari/models/mongoid_extension.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/kaminari-0.13.0/lib/kaminari/models/mongoid_extension.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/kaminari-0.13.0/lib/kaminari/models/mongoid_extension.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/kaminari-0.13.0/lib/kaminari/models/mongoid_extension.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/kaminari-0.13.0/lib/kaminari/models/mongoid_extension.rb
kaminari-0.13.0 lib/kaminari/models/mongoid_extension.rb