Sha256: 7d53ad7466efb0fc967602bec223b907efa272614de4662df9f5c40054f25808

Contents?: true

Size: 609 Bytes

Versions: 8

Compression:

Stored size: 609 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  class Scope #:nodoc:

    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.
    #
    # Options:
    #
    # conditions: A +Hash+ of conditions.
    # block:      A +block+ of extension methods (optional)
    #
    def initialize(conditions = {}, &block)
      @conditions = conditions
      @extensions = Module.new(&block) if block_given?
    end

    def extend(criteria)
      @extensions ? criteria.extend(@extensions) : criteria
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongoid-2.0.0.beta.20 lib/mongoid/scope.rb
mongoid-2.0.0.beta.19 lib/mongoid/scope.rb
mongoid-2.0.0.beta.18 lib/mongoid/scope.rb
mongoid-2.0.0.beta.17 lib/mongoid/scope.rb
mongoid-2.0.0.beta.16 lib/mongoid/scope.rb
mongoid-2.0.0.beta.15 lib/mongoid/scope.rb
mongoid-2.0.0.beta.14 lib/mongoid/scope.rb
mongoid-2.0.0.beta.13 lib/mongoid/scope.rb