Skip to content

Commit 2adef6d

Browse files
authored
Make segment operators nil-safe
Avoid `NoMethodError` when evaluating nil trait values
1 parent 046644f commit 2adef6d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/flagsmith/engine/segments/models.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class Condition
4242
LESS_THAN => ->(other_value, self_value) { other_value < self_value },
4343
LESS_THAN_INCLUSIVE => ->(other_value, self_value) { other_value <= self_value },
4444
NOT_EQUAL => ->(other_value, self_value) { other_value != self_value },
45-
CONTAINS => ->(other_value, self_value) { other_value.include? self_value },
45+
CONTAINS => ->(other_value, self_value) { other_value&.include? self_value },
4646

47-
NOT_CONTAINS => ->(other_value, self_value) { !other_value.include? self_value },
48-
REGEX => ->(other_value, self_value) { other_value.match? self_value }
47+
NOT_CONTAINS => ->(other_value, self_value) { !other_value&.include? self_value },
48+
REGEX => ->(other_value, self_value) { other_value&.match? self_value }
4949
}.freeze
5050

5151
def initialize(operator:, value:, property: nil)

0 commit comments

Comments
 (0)