Class: Mongory::Matchers::EqMatcher
- Inherits:
-
AbstractMatcher
- Object
- AbstractMatcher
- Mongory::Matchers::EqMatcher
- Defined in:
- lib/mongory/matchers/eq_matcher.rb
Overview
This matcher is also used as the fallback for non-operator literal values,
such as { name: "Alice" }
, when no other specialized matcher is applicable.
Equality behavior depends on how ==
is implemented for the given objects.
EqMatcher matches values using the equality operator ==
.
It inherits from AbstractMatcher and defines its operator as :==
.
Used for conditions like:
- { age: { '$eq' => 30 } }
- { name: "Alice" } (implicit fallback)
This matcher supports any Ruby object that implements #==
.
Constant Summary
Constants inherited from AbstractMatcher
AbstractMatcher::KEY_NOT_FOUND
Instance Attribute Summary
Attributes inherited from AbstractMatcher
Instance Method Summary collapse
- #priority ⇒ Object
-
#raw_proc ⇒ Proc
Creates a raw Proc that performs the equality check.
Methods inherited from AbstractMatcher
#cached_proc, #check_validity!, #debug_proc, define_matcher, #initialize, #match, #match?, #render_tree, #uniq_key
Methods included from Utils
included, included_classes, #is_blank?, #is_present?
Constructor Details
This class inherits a constructor from Mongory::Matchers::AbstractMatcher
Instance Method Details
#priority ⇒ Object
39 40 41 |
# File 'lib/mongory/matchers/eq_matcher.rb', line 39 def priority 1 end |
#raw_proc ⇒ Proc
Creates a raw Proc that performs the equality check.
The Proc uses the ==
operator to compare values.
31 32 33 34 35 36 37 |
# File 'lib/mongory/matchers/eq_matcher.rb', line 31 def raw_proc condition = @condition Proc.new do |record| record == condition end end |