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

ruby-changes:63525

From: Benoit <ko1@a...>
Date: Thu, 5 Nov 2020 19:25:54 +0900 (JST)
Subject: [ruby-changes:63525] 4dba0c1a8e (master): Prefer #send over #__send__ when it is clear there is no possible conflict

https://git.ruby-lang.org/ruby.git/commit/?id=4dba0c1a8e

From 4dba0c1a8e3cc08664872e637099c4e7d58d24d3 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Thu, 5 Nov 2020 11:23:27 +0100
Subject: Prefer #send over #__send__ when it is clear there is no possible
 conflict

* Reverts part of 3198e7abd70bd2af977f2bb6c967e9df8f91adb0.
* If the rule is #send should be deprecated, that should be ruled by matz,
  there is no such rule currently and gems seem to prefer #send
  overwhelmingly.

diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index c720feb..95596ba 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -189,7 +189,7 @@ module Forwardable https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L189
     # If it's not a class or module, it's an instance
     mod = Module === self ? self : singleton_class
     ret = mod.module_eval(&gen)
-    mod.__send__(:ruby2_keywords, ali) if RUBY_VERSION >= '2.7'
+    mod.send(:ruby2_keywords, ali) if RUBY_VERSION >= '2.7'
     ret
   end
 
diff --git a/lib/irb/cmd/fork.rb b/lib/irb/cmd/fork.rb
index 7566d10..19c78fc 100644
--- a/lib/irb/cmd/fork.rb
+++ b/lib/irb/cmd/fork.rb
@@ -16,7 +16,7 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/cmd/fork.rb#L16
   module ExtendCommand
     class Fork < Nop
       def execute
-        pid = __send__ ExtendCommand.irb_original_method_name("fork")
+        pid = send ExtendCommand.irb_original_method_name("fork")
         unless pid
           class << self
             alias_method :exit, ExtendCommand.irb_original_method_name('exit')
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index 6d82139..c9328e5 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -268,7 +268,7 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/completion.rb#L268
     PerfectMatchedProc = ->(matched, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding) {
       RDocRIDriver ||= RDoc::RI::Driver.new
       if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
-        IRB.__send__(:easter_egg)
+        IRB.send(:easter_egg)
         return
       end
       namespace = retrieve_completion_data(matched, bind: bind, doc_namespace: true)
diff --git a/lib/irb/easter-egg.rb b/lib/irb/easter-egg.rb
index 3e79692..be7f471 100644
--- a/lib/irb/easter-egg.rb
+++ b/lib/irb/easter-egg.rb
@@ -135,4 +135,4 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/easter-egg.rb#L135
   end
 end
 
-IRB.__send__(:easter_egg, ARGV[0]&.to_sym) if $0 == __FILE__
+IRB.send(:easter_egg, ARGV[0]&.to_sym) if $0 == __FILE__
diff --git a/lib/un.rb b/lib/un.rb
index a759328..628260a 100644
--- a/lib/un.rb
+++ b/lib/un.rb
@@ -88,7 +88,7 @@ def cp https://github.com/ruby/ruby/blob/trunk/lib/un.rb#L88
     options[:preserve] = true if options.delete :p
     dest = argv.pop
     argv = argv[0] if argv.size == 1
-    FileUtils.__send__ cmd, argv, dest, **options
+    FileUtils.send cmd, argv, dest, **options
   end
 end
 
@@ -109,7 +109,7 @@ def ln https://github.com/ruby/ruby/blob/trunk/lib/un.rb#L109
     options[:force] = true if options.delete :f
     dest = argv.pop
     argv = argv[0] if argv.size == 1
-    FileUtils.__send__ cmd, argv, dest, **options
+    FileUtils.send cmd, argv, dest, **options
   end
 end
 
@@ -144,7 +144,7 @@ def rm https://github.com/ruby/ruby/blob/trunk/lib/un.rb#L144
     cmd = "rm"
     cmd += "_r" if options.delete :r
     options[:force] = true if options.delete :f
-    FileUtils.__send__ cmd, argv, **options
+    FileUtils.send cmd, argv, **options
   end
 end
 
@@ -161,7 +161,7 @@ def mkdir https://github.com/ruby/ruby/blob/trunk/lib/un.rb#L161
   setup("p") do |argv, options|
     cmd = "mkdir"
     cmd += "_p" if options.delete :p
-    FileUtils.__send__ cmd, argv, **options
+    FileUtils.send cmd, argv, **options
   end
 end
 
-- 
cgit v0.10.2


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

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