Class: Mongoid::Matchable::Default
- Inherits:
-
Object
- Object
- Mongoid::Matchable::Default
- Defined in:
- lib/mongoid/matchable/default.rb
Overview
Contains all the default behavior for checking for matching documents given MongoDB expressions.
Direct Known Subclasses
All, And, ElemMatch, Exists, Gt, Gte, In, Lt, Lte, Ne, Nin, Nor, Or, Regexp, Size
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#_matches?(value) ⇒ true, false
Return true if the attribute and value are equal, or if it is an array if the value is included.
-
#initialize(attribute, document = nil) ⇒ Default
constructor
Creating a new matcher only requires the value.
Constructor Details
#initialize(attribute, document = nil) ⇒ Default
Creating a new matcher only requires the value.
19 20 21 |
# File 'lib/mongoid/matchable/default.rb', line 19 def initialize(attribute, document = nil) @attribute, @document = attribute, document end |
Instance Attribute Details
#attribute ⇒ Object
9 10 11 |
# File 'lib/mongoid/matchable/default.rb', line 9 def attribute @attribute end |
#document ⇒ Object
9 10 11 |
# File 'lib/mongoid/matchable/default.rb', line 9 def document @document end |
Instance Method Details
#_matches?(value) ⇒ true, false
Return true if the attribute and value are equal, or if it is an array if the value is included.
34 35 36 |
# File 'lib/mongoid/matchable/default.rb', line 34 def _matches?(value) attribute.is_a?(Array) && !value.is_a?(Array) ? attribute.any? { |_attribute| value === _attribute } : value === attribute end |