Class: Hackle::SegmentConditionMatcher

Inherits:
Object
  • Object
show all
Includes:
ConditionMatcher
Defined in:
lib/hackle/internal/evaluation/match/condition/segment/segment_condition_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(segment_matcher:) ⇒ SegmentConditionMatcher

Returns a new instance of SegmentConditionMatcher.

Parameters:



11
12
13
14
# File 'lib/hackle/internal/evaluation/match/condition/segment/segment_condition_matcher.rb', line 11

def initialize(segment_matcher:)
  # @type [SegmentMatcher]
  @segment_matcher = segment_matcher
end

Instance Method Details

#matches(request, context, condition) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/hackle/internal/evaluation/match/condition/segment/segment_condition_matcher.rb', line 16

def matches(request, context, condition)
  if condition.key.type != TargetKeyType::SEGMENT
    raise ArgumentError, "unsupported TargetKeyType [#{condition.key.type}]"
  end

  matches = condition.match.values.any? { |it| value_matches(request, context, it) }
  TargetMatchType.matches(condition.match.type, matches)
end