Class: Hackle::OperatorMatcherFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/hackle/internal/evaluation/match/operator/operator_matcher_factory.rb

Instance Method Summary collapse

Constructor Details

#initializeOperatorMatcherFactory

Returns a new instance of OperatorMatcherFactory.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hackle/internal/evaluation/match/operator/operator_matcher_factory.rb', line 9

def initialize
  @matchers = {
    TargetOperator::IN => InMatcher.new,
    TargetOperator::CONTAINS => ContainsMatcher.new,
    TargetOperator::STARTS_WITH => StartsWithMatcher.new,
    TargetOperator::ENDS_WITH => EndsWithMatcher.new,
    TargetOperator::GT => GreaterThanMatcher.new,
    TargetOperator::GTE => GreaterThanOrEqualToMatcher.new,
    TargetOperator::LT => LessThanMatcher.new,
    TargetOperator::LTE => LessThanOrEqualToMatcher.new
  }.freeze
end

Instance Method Details

#get(operator) ⇒ OperatorMatcher

Parameters:

Returns:

Raises:

  • (ArgumentError)


24
25
26
27
28
29
# File 'lib/hackle/internal/evaluation/match/operator/operator_matcher_factory.rb', line 24

def get(operator)
  matcher = @matchers[operator]
  raise ArgumentError, "Unsupported TargetOperator [#{operator}]" unless matcher

  matcher
end