Skip to content

Commit c1d0561

Browse files
committed
Deprecate use of == and != for Redis::Future
1 parent d3526cc commit c1d0561

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/redis.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
class Redis
77

8+
def self.deprecate(message, trace = caller[0])
9+
$stderr.puts "\n#{message} (in #{trace})"
10+
end
11+
812
def self.current
913
@current ||= Redis.new
1014
end

lib/redis/pipeline.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,20 @@ class Future < BasicObject
132132

133133
attr_reader :timeout
134134

135-
# Avoid allowing people to use == inside a pipelined
136-
undef :==
137-
138135
def initialize(command, transformation, timeout)
139136
@command = command
140137
@transformation = transformation
141138
@timeout = timeout
142139
@object = FutureNotReady
143140
end
144141

142+
def ==(*)
143+
message = "The method == and != is deprecated for Redis::Future and will be removed in 4.2.0"
144+
message << " - You probably meant to call .value == or .value !="
145+
::Redis.deprecate(message)
146+
super
147+
end
148+
145149
def inspect
146150
"<Redis::Future #{@command.inspect}>"
147151
end

test/pipelining_commands_test.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,6 @@ def test_futures_raise_when_trying_to_access_their_values_too_early
126126
end
127127
end
128128

129-
def test_futures_raise_when_trying_to_compare_their_value_too_early
130-
r.pipelined do
131-
assert_raises(NoMethodError) do
132-
r.sadd("foo", 1) == 1
133-
end
134-
end
135-
end
136-
137129
def test_futures_raise_when_command_errors_and_needs_transformation
138130
assert_raises(Redis::CommandError) do
139131
r.pipelined do

0 commit comments

Comments
 (0)