Class: Mongory::Matchers::GteMatcher

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

Overview

GteMatcher implements the $gte (greater than or equal) operator.

It returns true if the record is greater than or equal to the condition value.

Inherits comparison logic and error safety from AbstractMatcher.

Examples:

matcher = GteMatcher.build(10)
matcher.match?(10)  #=> true
matcher.match?(11)  #=> true
matcher.match?(9)   #=> 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

#priorityObject



34
35
36
# File 'lib/mongory/matchers/gte_matcher.rb', line 34

def priority
  3
end

#raw_procProc

Note:

The proc includes error handling for invalid comparisons

Creates a raw Proc that performs the greater-than-or-equal comparison. The Proc uses the >= operator to compare values.

Returns:

  • (Proc)

    A proc that performs greater-than-or-equal comparison with error handling



24
25
26
27
28
29
30
31
32
# File 'lib/mongory/matchers/gte_matcher.rb', line 24

def raw_proc
  condition = @condition

  Proc.new do |record|
    record >= condition
  rescue StandardError
    false
  end
end