Skip to content

Commit efbd4c2

Browse files
committed
replace a lambda with a yield
1 parent 9fbb580 commit efbd4c2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/ldclient-rb/evaluation.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ def self.addZeroVersionComponent(v)
5252
}
5353
end
5454

55-
def self.comparator(converter, condition)
55+
def self.comparator(converter)
5656
lambda do |a, b|
5757
av = converter.call(a)
5858
bv = converter.call(b)
59-
!av.nil? && !bv.nil? && condition.call(av <=> bv)
59+
if !av.nil? && !bv.nil?
60+
yield av <=> bv
61+
else
62+
return false
63+
end
6064
end
6165
end
6266

@@ -98,15 +102,15 @@ def self.comparator(converter, condition)
98102
(a.is_a? Numeric) && (a >= b)
99103
end,
100104
before:
101-
comparator(DATE_OPERAND, -> n { n < 0 }),
105+
comparator(DATE_OPERAND) { |n| n < 0 },
102106
after:
103-
comparator(DATE_OPERAND, -> n { n > 0 }),
107+
comparator(DATE_OPERAND) { |n| n > 0 },
104108
semVerEqual:
105-
comparator(SEMVER_OPERAND, -> n { n == 0 }),
109+
comparator(SEMVER_OPERAND) { |n| n == 0 },
106110
semVerLessThan:
107-
comparator(SEMVER_OPERAND, -> n { n < 0 }),
111+
comparator(SEMVER_OPERAND) { |n| n < 0 },
108112
semVerGreaterThan:
109-
comparator(SEMVER_OPERAND, -> n { n > 0 })
113+
comparator(SEMVER_OPERAND) { |n| n > 0 }
110114
}
111115

112116
class EvaluationError < StandardError

0 commit comments

Comments
 (0)