Class: Mongoid::Scope
Overview
This module handles behaviour for defining scopes on classes.
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
Instance Method Summary collapse
-
#extend(criteria) ⇒ Criteria
Extend a supplied criteria.
-
#initialize(conditions = {}, &block) ⇒ Scope
constructor
Create the new
Scope
.
Constructor Details
#initialize(conditions = {}, &block) ⇒ Scope
Create the new Scope
. If a block is passed in, this Scope will store the block for future calls to #extend.
14 15 16 17 |
# File 'lib/mongoid/scope.rb', line 14 def initialize(conditions = {}, &block) @conditions = conditions @extensions = Module.new(&block) if block_given? end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
5 6 7 |
# File 'lib/mongoid/scope.rb', line 5 def conditions @conditions end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
5 6 7 |
# File 'lib/mongoid/scope.rb', line 5 def extensions @extensions end |
Instance Method Details
#extend(criteria) ⇒ Criteria
Extend a supplied criteria.
27 28 29 |
# File 'lib/mongoid/scope.rb', line 27 def extend(criteria) extensions ? criteria.extend(extensions) : criteria end |