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