Module: Mongoid::Criteria::Queryable::Mergeable
- Included in:
- Mongoid::Criteria::Queryable
- Defined in:
- lib/mongoid/criteria/queryable/mergeable.rb
Overview
Contains behavior for merging existing selection with new selection.
Instance Attribute Summary collapse
-
#strategy ⇒ Object
Returns the value of attribute strategy.
- #strategy The name of the current strategy.(Thenameofthecurrentstrategy.) ⇒ Object
Instance Method Summary collapse
-
#and_with_operator(criterion, operator) ⇒ Criteria
Merge criteria with operators using the and operator.
-
#intersect ⇒ Mergeable
Instruct the next mergeable call to use intersection.
-
#override ⇒ Mergeable
Instruct the next mergeable call to use override.
-
#reset_strategies! ⇒ Criteria
Clear the current strategy and negating flag, used after cloning.
-
#union ⇒ Mergeable
Instruct the next mergeable call to use union.
Instance Attribute Details
#strategy ⇒ Object
Returns the value of attribute strategy.
9 10 11 |
# File 'lib/mongoid/criteria/queryable/mergeable.rb', line 9 def strategy @strategy end |
#strategy The name of the current strategy.(Thenameofthecurrentstrategy.) ⇒ Object
9 |
# File 'lib/mongoid/criteria/queryable/mergeable.rb', line 9 attr_accessor :strategy |
Instance Method Details
#and_with_operator(criterion, operator) ⇒ Criteria
Merge criteria with operators using the and operator.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mongoid/criteria/queryable/mergeable.rb', line 59 def and_with_operator(criterion, operator) crit = self if criterion criterion.each_pair do |field, value| val = prepare(field, operator, value) # The prepare method already takes the negation into account. We # set negating to false here so that ``and`` doesn't also apply # negation and we have a double negative. crit.negating = false crit = crit.and(field => val) end end crit end |
#intersect ⇒ Mergeable
Instruct the next mergeable call to use intersection.
17 18 19 |
# File 'lib/mongoid/criteria/queryable/mergeable.rb', line 17 def intersect use(:__intersect__) end |
#override ⇒ Mergeable
Instruct the next mergeable call to use override.
27 28 29 |
# File 'lib/mongoid/criteria/queryable/mergeable.rb', line 27 def override use(:__override__) end |
#reset_strategies! ⇒ Criteria
Clear the current strategy and negating flag, used after cloning.
47 48 49 50 51 |
# File 'lib/mongoid/criteria/queryable/mergeable.rb', line 47 def reset_strategies! self.strategy = nil self.negating = nil self end |
#union ⇒ Mergeable
Instruct the next mergeable call to use union.
37 38 39 |
# File 'lib/mongoid/criteria/queryable/mergeable.rb', line 37 def union use(:__union__) end |