Class: Hackle::ValueMatcherFactory

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

Instance Method Summary collapse

Constructor Details

#initializeValueMatcherFactory

Returns a new instance of ValueMatcherFactory.



9
10
11
12
13
14
15
16
17
# File 'lib/hackle/internal/evaluation/match/value/value_matcher_factory.rb', line 9

def initialize
  @matchers = {
    ValueType::STRING => StringMatcher.new,
    ValueType::NUMBER => NumberMatcher.new,
    ValueType::BOOLEAN => BooleanMatcher.new,
    ValueType::VERSION => VersionMatcher.new,
    ValueType::JSON => StringMatcher.new
  }.freeze
end

Instance Method Details

#get(value_type) ⇒ ValueMatcher

Parameters:

Returns:

Raises:

  • (ArgumentError)


21
22
23
24
25
26
# File 'lib/hackle/internal/evaluation/match/value/value_matcher_factory.rb', line 21

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

  matcher
end