Sha256: 117e10ce73069e35dd8a93f36ed28eb0ff85ea655ebb7bb1d21099674bdc668f

Contents?: true

Size: 902 Bytes

Versions: 201

Compression:

Stored size: 902 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  # This module handles behaviour for defining scopes on classes.
  class Scope
    attr_reader :conditions, :extensions

    # Create the new +Scope+. If a block is passed in, this Scope will store
    # the block for future calls to #extend.
    #
    # @example Create a new scope.
    #   Scope.new(:title => "Sir")
    #
    # @param [ Hash ] conditions The scoping limitations.
    def initialize(conditions = {}, &block)
      @conditions = conditions
      @extensions = Module.new(&block) if block_given?
    end

    # Extend a supplied criteria.
    #
    # @example Extend the criteria.
    #   scope.extend(criteria)
    #
    # @param [ Criteria } criteria A mongoid criteria to extend.
    #
    # @return [ Criteria ] The new criteria object.
    def extend(criteria)
      extensions ? criteria.extend(extensions) : criteria
    end
  end
end

Version data entries

201 entries across 109 versions & 6 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/scope.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/scope.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/scope.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/scope.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/scope.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/scope.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/scope.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/scope.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/scope.rb
mongoid-2.8.1 lib/mongoid/scope.rb
mongoid-2.8.0 lib/mongoid/scope.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/scope.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/scope.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/scope.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/scope.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/scope.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/scope.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/scope.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/scope.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/scope.rb