[前][次][番号順一覧][スレッド一覧]

ruby-changes:60042

From: Yusuke <ko1@a...>
Date: Thu, 13 Feb 2020 15:23:15 +0900 (JST)
Subject: [ruby-changes:60042] 48f324e92f (ruby_2_7): lib/net/imap.rb: use `&blk` instead of Kernel#proc with no block

https://git.ruby-lang.org/ruby.git/commit/?id=48f324e92f

From 48f324e92f9b36edc267f9871e35039cbd1c2eb9 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Thu, 9 Jan 2020 08:21:42 +0900
Subject: lib/net/imap.rb: use `&blk` instead of Kernel#proc with no block

[Bug #16488]

diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index aa46e47..720acbc 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -903,8 +903,9 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/imap.rb#L903
     #     end
     #   }
     #
-    def add_response_handler(handler = Proc.new)
-      @response_handlers.push(handler)
+    def add_response_handler(handler = nil, &block)
+      raise ArgumentError, "two Procs are passed" if handler && block
+      @response_handlers.push(block || handler)
     end
 
     # Removes the response handler.
@@ -959,7 +960,7 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/imap.rb#L960
         put_string("#{tag} IDLE#{CRLF}")
 
         begin
-          add_response_handler(response_handler)
+          add_response_handler(&response_handler)
           @idle_done_cond = new_cond
           @idle_done_cond.wait(timeout)
           @idle_done_cond = nil
@@ -1267,7 +1268,7 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/imap.rb#L1268
           @logout_command_tag = tag
         end
         if block
-          add_response_handler(block)
+          add_response_handler(&block)
         end
         begin
           return get_tagged_response(tag, cmd)
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]