Skip to content

Commit

Permalink
Make segment operators nil-safe
Browse files Browse the repository at this point in the history
Avoid `NoMethodError` when evaluating nil trait values
  • Loading branch information
rolodato authored Oct 14, 2024
1 parent 046644f commit 2adef6d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/flagsmith/engine/segments/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class Condition
LESS_THAN => ->(other_value, self_value) { other_value < self_value },
LESS_THAN_INCLUSIVE => ->(other_value, self_value) { other_value <= self_value },
NOT_EQUAL => ->(other_value, self_value) { other_value != self_value },
CONTAINS => ->(other_value, self_value) { other_value.include? self_value },
CONTAINS => ->(other_value, self_value) { other_value&.include? self_value },

NOT_CONTAINS => ->(other_value, self_value) { !other_value.include? self_value },
REGEX => ->(other_value, self_value) { other_value.match? self_value }
NOT_CONTAINS => ->(other_value, self_value) { !other_value&.include? self_value },
REGEX => ->(other_value, self_value) { other_value&.match? self_value }
}.freeze

def initialize(operator:, value:, property: nil)
Expand Down

0 comments on commit 2adef6d

Please sign in to comment.