Skip to content

Commit e5c52d8

Browse files
Zaimwa9claude
andauthored
fix: respect rule type for sub-rules in segment evaluation (#101)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 87bd746 commit e5c52d8

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "spec/engine-test-data"]
22
path = spec/engine-test-data
33
url = git@github.com:Flagsmith/engine-test-data.git
4-
branch = v3.5.0
4+
branch = v3.7.0

lib/flagsmith/engine/segments/evaluator.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def traits_match_segment_rule(identity_traits, rule, segment_id, identity_id)
9393
end
9494

9595
matches_conditions &&
96-
rule.rules.all? { |r| traits_match_segment_rule(identity_traits, r, segment_id, identity_id) }
96+
rule.rules.send(rule.matching_function) { |r| traits_match_segment_rule(identity_traits, r, segment_id, identity_id) }
9797
end
9898
# rubocop:enable Metrics/MethodLength
9999

@@ -137,9 +137,10 @@ def evaluate_conditions_from_context(rule, segment_key, context)
137137
def evaluate_sub_rules_from_context(rule, segment_key, context)
138138
return true if rule[:rules].nil? || rule[:rules].empty?
139139

140-
rule[:rules].all? do |sub_rule|
140+
sub_rule_results = rule[:rules].map do |sub_rule|
141141
traits_match_segment_rule_from_context(sub_rule, segment_key, context)
142142
end
143+
evaluate_rule_conditions(rule[:type], sub_rule_results)
143144
end
144145

145146
# Evaluates a single segment condition using context

0 commit comments

Comments
 (0)