Skip to content

Commit dfb1da1

Browse files
committed
Future-proof sentinel commands.
1 parent db77f32 commit dfb1da1

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/redis.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,18 +2590,17 @@ def pfmerge(dest_key, *source_key)
25902590
def sentinel(subcommand, *args)
25912591
subcommand = subcommand.to_s.downcase
25922592
synchronize do |client|
2593-
if subcommand == 'master'
2594-
client.call([:sentinel, subcommand] + args, &_hashify)
2595-
elsif subcommand == 'get-master-addr-by-name'
2596-
client.call([:sentinel, subcommand] + args)
2597-
else
2598-
client.call([:sentinel, subcommand] + args) do |reply|
2593+
client.call([:sentinel, subcommand] + args) do |reply|
2594+
case subcommand
2595+
when "get-master-addr-by-name"
2596+
reply
2597+
else
25992598
if reply.kind_of?(Array)
2600-
new_reply = Array.new
2601-
reply.each do |r|
2602-
new_reply << _hashify.call(r)
2599+
if reply[0].kind_of?(Array)
2600+
reply.map(&_hashify)
2601+
else
2602+
_hashify.call(reply)
26032603
end
2604-
new_reply
26052604
else
26062605
reply
26072606
end

0 commit comments

Comments
 (0)