Class: Mongory::Matchers::NotMatcher
- Inherits:
-
LiteralMatcher
- Object
- AbstractMatcher
- LiteralMatcher
- Mongory::Matchers::NotMatcher
- Defined in:
- lib/mongory/matchers/not_matcher.rb
Overview
NotMatcher implements the $not
logical operator.
It returns true if the wrapped matcher fails, effectively inverting the result.
It delegates to LiteralMatcher and simply negates the outcome.
This allows constructs like: { age: { :$not => { :$gte => 30 } } }
Constant Summary
Constants inherited from AbstractMatcher
AbstractMatcher::KEY_NOT_FOUND
Instance Attribute Summary
Attributes inherited from AbstractMatcher
Instance Method Summary collapse
-
#raw_proc ⇒ Proc
Creates a raw Proc that performs the not-matching operation.
Methods inherited from LiteralMatcher
#array_record_matcher, #check_validity!, #dispatched_matcher, #render_tree
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
#raw_proc ⇒ Proc
Creates a raw Proc that performs the not-matching operation. The Proc inverts the result of the wrapped matcher.
25 26 27 28 29 30 31 |
# File 'lib/mongory/matchers/not_matcher.rb', line 25 def raw_proc super_proc = super Proc.new do |record| !super_proc.call(record) end end |