Skip to content

Commit d3526cc

Browse files
committed
Remove method == from Redis::Future
This helps to have a more consistent errors when operating with Redis::Future inside a pipelined block
1 parent a2c562c commit d3526cc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/redis/pipeline.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class Future < BasicObject
132132

133133
attr_reader :timeout
134134

135+
# Avoid allowing people to use == inside a pipelined
136+
undef :==
137+
135138
def initialize(command, transformation, timeout)
136139
@command = command
137140
@transformation = transformation

test/pipelining_commands_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ 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+
129137
def test_futures_raise_when_command_errors_and_needs_transformation
130138
assert_raises(Redis::CommandError) do
131139
r.pipelined do

0 commit comments

Comments
 (0)