1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

lib/net/imap.rb: use &blk instead of Kernel#proc with no block

[Bug #16488]
This commit is contained in:
Yusuke Endoh 2020-01-09 08:21:42 +09:00
parent 1d09acd82b
commit 65c2c75e16

View file

@ -903,8 +903,9 @@ module Net
# end # end
# } # }
# #
def add_response_handler(handler = Proc.new) def add_response_handler(handler = nil, &block)
@response_handlers.push(handler) raise ArgumentError, "two Procs are passed" if handler && block
@response_handlers.push(block || handler)
end end
# Removes the response handler. # Removes the response handler.
@ -959,7 +960,7 @@ module Net
put_string("#{tag} IDLE#{CRLF}") put_string("#{tag} IDLE#{CRLF}")
begin begin
add_response_handler(response_handler) add_response_handler(&response_handler)
@idle_done_cond = new_cond @idle_done_cond = new_cond
@idle_done_cond.wait(timeout) @idle_done_cond.wait(timeout)
@idle_done_cond = nil @idle_done_cond = nil
@ -1267,7 +1268,7 @@ module Net
@logout_command_tag = tag @logout_command_tag = tag
end end
if block if block
add_response_handler(block) add_response_handler(&block)
end end
begin begin
return get_tagged_response(tag, cmd) return get_tagged_response(tag, cmd)