From a6759452a897911d69ca8b05645cf7a31ceaffac Mon Sep 17 00:00:00 2001 From: Matt Larraz Date: Fri, 23 Aug 2024 15:26:32 -0400 Subject: [PATCH] Forward blocks on Redis#call This matches the behavior of RedisClient#call --- lib/redis/commands.rb | 4 ++-- test/redis/client_test.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/redis/commands.rb b/lib/redis/commands.rb index ddf264d95..179c2200a 100644 --- a/lib/redis/commands.rb +++ b/lib/redis/commands.rb @@ -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) diff --git a/test/redis/client_test.rb b/test/redis/client_test.rb index bec97431c..cad913077 100644 --- a/test/redis/client_test.rb +++ b/test/redis/client_test.rb @@ -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