Class: Mongory::Matchers::NeMatcher

Inherits:
AbstractMatcher show all
Defined in:
lib/mongory/matchers/ne_matcher.rb

Overview

NeMatcher implements the $ne (not equal) operator.

It returns true if the record is not equal to the condition.

This matcher inherits its logic from AbstractMatcher and uses Ruby's != operator for comparison.

Examples:

matcher = NeMatcher.build(42)
matcher.match?(41)  #=> true
matcher.match?(42)  #=> false

See Also:

Constant Summary

Constants inherited from AbstractMatcher

AbstractMatcher::KEY_NOT_FOUND

Instance Attribute Summary

Attributes inherited from AbstractMatcher

#condition, #context

Instance Method Summary collapse

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_procProc

Creates a raw Proc that performs the not-equal comparison. The Proc uses the != operator to compare values.

Returns:

  • (Proc)

    A proc that performs not-equal comparison



23
24
25
26
27
28
29
# File 'lib/mongory/matchers/ne_matcher.rb', line 23

def raw_proc
  condition = @condition

  Proc.new do |record|
    record != condition
  end
end