Skip to content

Commit e0918cd

Browse files
committed
Cast nil to false
1 parent 260c5a1 commit e0918cd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/flagsmith/engine/segments/models.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class Condition
3737

3838
MATCHING_FUNCTIONS = {
3939
EQUAL => ->(other_value, self_value) { other_value == self_value },
40-
GREATER_THAN => ->(other_value, self_value) { other_value && other_value > self_value },
41-
GREATER_THAN_INCLUSIVE => ->(other_value, self_value) { other_value && other_value >= self_value },
42-
LESS_THAN => ->(other_value, self_value) { other_value && other_value < self_value },
43-
LESS_THAN_INCLUSIVE => ->(other_value, self_value) { other_value && other_value <= self_value },
40+
GREATER_THAN => ->(other_value, self_value) { (other_value || false) && other_value > self_value },
41+
GREATER_THAN_INCLUSIVE => ->(other_value, self_value) { (other_value || false) && other_value >= self_value },
42+
LESS_THAN => ->(other_value, self_value) { (other_value || false) && other_value < self_value },
43+
LESS_THAN_INCLUSIVE => ->(other_value, self_value) { (other_value || false) && 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 || false) && 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 || false) && !other_value.include?(self_value) },
48+
REGEX => ->(other_value, self_value) { (other_value || false) && other_value.match?(self_value) }
4949
}.freeze
5050

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

0 commit comments

Comments
 (0)