Skip to content

Commit

Permalink
Forward blocks on Redis#call
Browse files Browse the repository at this point in the history
This matches the behavior of RedisClient#call
  • Loading branch information
mlarraz authored and byroot committed Aug 26, 2024
1 parent a1d6f68 commit a675945
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/redis/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ module Commands
# hash, are up to consumers.
#
# Redis error replies are raised as Ruby exceptions.
def call(*command)
send_command(command)
def call(*command, &block)
send_command(command, &block)
end

# Interact with the sentinel command (masters, master, slaves, failover)
Expand Down
5 changes: 5 additions & 0 deletions test/redis/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def test_call_with_arguments
assert_equal result, "OK"
end

def test_with_block
result = r.call("INFO") { |l| l.lines(chomp: true).grep(/uptime_in_days/)[0] }
assert_equal result, "uptime_in_days:0"
end

def test_call_integers
result = r.call("INCR", "foo")
assert_equal result, 1
Expand Down

0 comments on commit a675945

Please sign in to comment.