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

ruby-changes:37096

From: nobu <ko1@a...>
Date: Thu, 8 Jan 2015 12:52:13 +0900 (JST)
Subject: [ruby-changes:37096] nobu:r49177 (trunk): open3.rb: Hash.try_convert

nobu	2015-01-08 12:52:01 +0900 (Thu, 08 Jan 2015)

  New Revision: 49177

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49177

  Log:
    open3.rb: Hash.try_convert
    
    * lib/open3.rb (popen_run): use Hash.try_convert for duck typing.

  Modified files:
    trunk/lib/open3.rb
Index: lib/open3.rb
===================================================================
--- lib/open3.rb	(revision 49176)
+++ lib/open3.rb	(revision 49177)
@@ -190,7 +190,10 @@ module Open3 https://github.com/ruby/ruby/blob/trunk/lib/open3.rb#L190
   module_function :popen2e
 
   def popen_run(cmd, opts, child_io, parent_io) # :nodoc:
-    opts = opts.merge(cmd.pop) if cmd.last.kind_of? Hash
+    if last = Hash.try_convert(cmd.last)
+      opts = opts.merge(last)
+      cmd.pop
+    end
     pid = spawn(*cmd, opts)
     wait_thr = Process.detach(pid)
     child_io.each {|io| io.close }

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

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