@@ -25,13 +25,18 @@ def match?(args)
2525 rule_based_segment = @rule_based_segments_repository . get_rule_based_segment ( @segment_name )
2626 return false if rule_based_segment . nil?
2727
28- return false if rule_based_segment [ :excluded ] [ :keys ] . include? ( [ args [ :value ] ] )
28+ if args [ :value ] . nil? or args [ :value ] . empty?
29+ key = args [ :matching_key ]
30+ else
31+ key = args [ :value ]
32+ end
33+ return false if rule_based_segment [ :excluded ] [ :keys ] . include? ( key )
2934
3035 rule_based_segment [ :excluded ] [ :segments ] . each do |segment |
31- return false if segment [ :type ] == 'standard' and @segments_repository . in_segment? ( segment [ :name ] , args [ :value ] )
36+ return false if segment [ :type ] == 'standard' and @segments_repository . in_segment? ( segment [ :name ] , key )
3237
3338 if segment [ :type ] == 'rule-based'
34- return true if match_rbs ( @rule_based_segments_repository . get_rule_based_segment ( segment [ :name ] ) [ :conditions ] , args )
39+ return false if match_rbs ( @rule_based_segments_repository . get_rule_based_segment ( segment [ :name ] ) , args )
3540 end
3641 end
3742
@@ -49,18 +54,13 @@ def match?(args)
4954
5055 private
5156
52- def match_rbs ( conditions , args )
53- conditions . each do |condition |
54- next if condition . empty?
55-
56- return true if Helpers ::EvaluatorHelper ::matcher_type ( SplitIoClient ::Condition . new ( condition , @config ) ,
57- @segments_repository , @rule_based_segments_repository ) . match? (
58- matching_key : args [ :matching_key ] ,
59- bucketing_key : args [ :value ] ,
60- attributes : args [ :attributes ]
57+ def match_rbs ( rule_based_segment , args )
58+ rbs_matcher = RuleBasedSegmentMatcher . new ( @segments_repository , @rule_based_segments_repository , rule_based_segment [ :name ] , @config )
59+ return rbs_matcher . match? (
60+ matching_key : args [ :matching_key ] ,
61+ bucketing_key : args [ :value ] ,
62+ attributes : args [ :attributes ]
6163 )
62- end
63- return false
6464 end
6565 end
6666end
0 commit comments