Separate send
into public_send
and __send__
This commit is contained in:
parent
acdb893338
commit
3198e7abd7
@ -84,7 +84,7 @@ class CSV
|
|||||||
def field(header_or_index, minimum_index = 0)
|
def field(header_or_index, minimum_index = 0)
|
||||||
# locate the pair
|
# locate the pair
|
||||||
finder = (header_or_index.is_a?(Integer) || header_or_index.is_a?(Range)) ? :[] : :assoc
|
finder = (header_or_index.is_a?(Integer) || header_or_index.is_a?(Range)) ? :[] : :assoc
|
||||||
pair = @row[minimum_index..-1].send(finder, header_or_index)
|
pair = @row[minimum_index..-1].public_send(finder, header_or_index)
|
||||||
|
|
||||||
# return the field if we have a pair
|
# return the field if we have a pair
|
||||||
if pair.nil?
|
if pair.nil?
|
||||||
|
@ -13,7 +13,7 @@ module DRb
|
|||||||
if defined? @observer_peers
|
if defined? @observer_peers
|
||||||
@observer_peers.each do |observer, method|
|
@observer_peers.each do |observer, method|
|
||||||
begin
|
begin
|
||||||
observer.send(method, *arg)
|
observer.__send__(method, *arg)
|
||||||
rescue
|
rescue
|
||||||
delete_observer(observer)
|
delete_observer(observer)
|
||||||
end
|
end
|
||||||
|
@ -189,7 +189,7 @@ module Forwardable
|
|||||||
# If it's not a class or module, it's an instance
|
# If it's not a class or module, it's an instance
|
||||||
mod = Module === self ? self : singleton_class
|
mod = Module === self ? self : singleton_class
|
||||||
ret = mod.module_eval(&gen)
|
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
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ module SingleForwardable
|
|||||||
gen = Forwardable._delegator_method(self, accessor, method, ali)
|
gen = Forwardable._delegator_method(self, accessor, method, ali)
|
||||||
|
|
||||||
ret = instance_eval(&gen)
|
ret = instance_eval(&gen)
|
||||||
singleton_class.send(:ruby2_keywords, ali) if RUBY_VERSION >= '2.7'
|
singleton_class.__send__(:ruby2_keywords, ali) if RUBY_VERSION >= '2.7'
|
||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ module IRB
|
|||||||
module ExtendCommand
|
module ExtendCommand
|
||||||
class Fork < Nop
|
class Fork < Nop
|
||||||
def execute
|
def execute
|
||||||
pid = send ExtendCommand.irb_original_method_name("fork")
|
pid = __send__ ExtendCommand.irb_original_method_name("fork")
|
||||||
unless pid
|
unless pid
|
||||||
class << self
|
class << self
|
||||||
alias_method :exit, ExtendCommand.irb_original_method_name('exit')
|
alias_method :exit, ExtendCommand.irb_original_method_name('exit')
|
||||||
|
@ -268,7 +268,7 @@ module IRB
|
|||||||
PerfectMatchedProc = ->(matched, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding) {
|
PerfectMatchedProc = ->(matched, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding) {
|
||||||
RDocRIDriver ||= RDoc::RI::Driver.new
|
RDocRIDriver ||= RDoc::RI::Driver.new
|
||||||
if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
|
if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
|
||||||
IRB.send(:easter_egg)
|
IRB.__send__(:easter_egg)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
namespace = retrieve_completion_data(matched, bind: bind, doc_namespace: true)
|
namespace = retrieve_completion_data(matched, bind: bind, doc_namespace: true)
|
||||||
|
@ -126,6 +126,7 @@ module IRB
|
|||||||
print "\e[H" + buff
|
print "\e[H" + buff
|
||||||
sleep 0.05
|
sleep 0.05
|
||||||
end
|
end
|
||||||
|
rescue Interrupt
|
||||||
ensure
|
ensure
|
||||||
print "\e[0m\e[?1049l"
|
print "\e[0m\e[?1049l"
|
||||||
end
|
end
|
||||||
@ -134,4 +135,4 @@ module IRB
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
IRB.send(:easter_egg, ARGV[0]&.to_sym) if $0 == __FILE__
|
IRB.__send__(:easter_egg, ARGV[0]&.to_sym) if $0 == __FILE__
|
||||||
|
@ -180,7 +180,7 @@ module IRB # :nodoc:
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
], nil, __FILE__, line
|
], nil, __FILE__, line
|
||||||
send :#{cmd_name}_, *opts, &b
|
__send__ :#{cmd_name}_, *opts, &b
|
||||||
end
|
end
|
||||||
], nil, __FILE__, line
|
], nil, __FILE__, line
|
||||||
else
|
else
|
||||||
@ -268,7 +268,7 @@ module IRB # :nodoc:
|
|||||||
def #{cmd_name}(*opts, &b)
|
def #{cmd_name}(*opts, &b)
|
||||||
Context.module_eval {remove_method(:#{cmd_name})}
|
Context.module_eval {remove_method(:#{cmd_name})}
|
||||||
require "#{load_file}"
|
require "#{load_file}"
|
||||||
send :#{cmd_name}, *opts, &b
|
__send__ :#{cmd_name}, *opts, &b
|
||||||
end
|
end
|
||||||
for ali in aliases
|
for ali in aliases
|
||||||
alias_method ali, cmd_name
|
alias_method ali, cmd_name
|
||||||
@ -291,8 +291,8 @@ module IRB # :nodoc:
|
|||||||
module_eval %[
|
module_eval %[
|
||||||
alias_method alias_name, base_method
|
alias_method alias_name, base_method
|
||||||
def #{base_method}(*opts)
|
def #{base_method}(*opts)
|
||||||
send :#{extend_method}, *opts
|
__send__ :#{extend_method}, *opts
|
||||||
send :#{alias_name}, *opts
|
__send__ :#{alias_name}, *opts
|
||||||
end
|
end
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
@ -307,8 +307,8 @@ module IRB # :nodoc:
|
|||||||
module_eval %[
|
module_eval %[
|
||||||
alias_method alias_name, base_method
|
alias_method alias_name, base_method
|
||||||
def #{base_method}(*opts)
|
def #{base_method}(*opts)
|
||||||
send :#{alias_name}, *opts
|
__send__ :#{alias_name}, *opts
|
||||||
send :#{extend_method}, *opts
|
__send__ :#{extend_method}, *opts
|
||||||
end
|
end
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
@ -52,7 +52,7 @@ EOF
|
|||||||
@binding = BINDING_QUEUE.pop
|
@binding = BINDING_QUEUE.pop
|
||||||
|
|
||||||
when 3 # binding in function on TOPLEVEL_BINDING(default)
|
when 3 # binding in function on TOPLEVEL_BINDING(default)
|
||||||
@binding = eval("self.class.send(:remove_method, :irb_binding) if defined?(irb_binding); private; def irb_binding; binding; end; irb_binding",
|
@binding = eval("self.class.remove_method(:irb_binding) if defined?(irb_binding); private; def irb_binding; binding; end; irb_binding",
|
||||||
TOPLEVEL_BINDING,
|
TOPLEVEL_BINDING,
|
||||||
__FILE__,
|
__FILE__,
|
||||||
__LINE__ - 3)
|
__LINE__ - 3)
|
||||||
|
@ -784,7 +784,7 @@ int main() {printf("%"PRI_CONFTEST_PREFIX"#{neg ? 'd' : 'u'}\\n", conftest_const
|
|||||||
if opt and !opt.empty?
|
if opt and !opt.empty?
|
||||||
[[:to_str], [:join, " "], [:to_s]].each do |meth, *args|
|
[[:to_str], [:join, " "], [:to_s]].each do |meth, *args|
|
||||||
if opt.respond_to?(meth)
|
if opt.respond_to?(meth)
|
||||||
break opt = opt.send(meth, *args)
|
break opt = opt.__send__(meth, *args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
opt = "#{opt} #{libs}"
|
opt = "#{opt} #{libs}"
|
||||||
@ -982,7 +982,7 @@ SRC
|
|||||||
if noun
|
if noun
|
||||||
[[:to_str], [:join, ","], [:to_s]].each do |meth, *args|
|
[[:to_str], [:join, ","], [:to_s]].each do |meth, *args|
|
||||||
if noun.respond_to?(meth)
|
if noun.respond_to?(meth)
|
||||||
break noun = noun.send(meth, *args)
|
break noun = noun.__send__(meth, *args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless noun.empty?
|
unless noun.empty?
|
||||||
|
@ -1049,7 +1049,7 @@ module Net
|
|||||||
raise FTPProtoError, "invalid time-val: #{value}"
|
raise FTPProtoError, "invalid time-val: #{value}"
|
||||||
end
|
end
|
||||||
usec = fractions.to_i * 10 ** (6 - fractions.to_s.size)
|
usec = fractions.to_i * 10 ** (6 - fractions.to_s.size)
|
||||||
Time.send(local ? :local : :utc, year, month, day, hour, min, sec, usec)
|
Time.public_send(local ? :local : :utc, year, month, day, hour, min, sec, usec)
|
||||||
}
|
}
|
||||||
FACT_PARSERS = Hash.new(CASE_DEPENDENT_PARSER)
|
FACT_PARSERS = Hash.new(CASE_DEPENDENT_PARSER)
|
||||||
FACT_PARSERS["size"] = DECIMAL_PARSER
|
FACT_PARSERS["size"] = DECIMAL_PARSER
|
||||||
|
@ -1542,7 +1542,7 @@ module Net
|
|||||||
|
|
||||||
class RawData # :nodoc:
|
class RawData # :nodoc:
|
||||||
def send_data(imap, tag)
|
def send_data(imap, tag)
|
||||||
imap.send(:put_string, @data)
|
imap.__send__(:put_string, @data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
@ -1557,7 +1557,7 @@ module Net
|
|||||||
|
|
||||||
class Atom # :nodoc:
|
class Atom # :nodoc:
|
||||||
def send_data(imap, tag)
|
def send_data(imap, tag)
|
||||||
imap.send(:put_string, @data)
|
imap.__send__(:put_string, @data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
@ -1572,7 +1572,7 @@ module Net
|
|||||||
|
|
||||||
class QuotedString # :nodoc:
|
class QuotedString # :nodoc:
|
||||||
def send_data(imap, tag)
|
def send_data(imap, tag)
|
||||||
imap.send(:send_quoted_string, @data)
|
imap.__send__(:send_quoted_string, @data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
@ -1587,7 +1587,7 @@ module Net
|
|||||||
|
|
||||||
class Literal # :nodoc:
|
class Literal # :nodoc:
|
||||||
def send_data(imap, tag)
|
def send_data(imap, tag)
|
||||||
imap.send(:send_literal, @data, tag)
|
imap.__send__(:send_literal, @data, tag)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
@ -1602,7 +1602,7 @@ module Net
|
|||||||
|
|
||||||
class MessageSet # :nodoc:
|
class MessageSet # :nodoc:
|
||||||
def send_data(imap, tag)
|
def send_data(imap, tag)
|
||||||
imap.send(:put_string, format_internal(@data))
|
imap.__send__(:put_string, format_internal(@data))
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
|
@ -745,7 +745,7 @@ module Net
|
|||||||
def authenticate(user, secret, authtype = DEFAULT_AUTH_TYPE)
|
def authenticate(user, secret, authtype = DEFAULT_AUTH_TYPE)
|
||||||
check_auth_method authtype
|
check_auth_method authtype
|
||||||
check_auth_args user, secret
|
check_auth_args user, secret
|
||||||
send auth_method(authtype), user, secret
|
public_send auth_method(authtype), user, secret
|
||||||
end
|
end
|
||||||
|
|
||||||
def auth_plain(user, secret)
|
def auth_plain(user, secret)
|
||||||
|
@ -219,7 +219,7 @@ module Observable
|
|||||||
if defined? @observer_state and @observer_state
|
if defined? @observer_state and @observer_state
|
||||||
if defined? @observer_peers
|
if defined? @observer_peers
|
||||||
@observer_peers.each do |k, v|
|
@observer_peers.each do |k, v|
|
||||||
k.send v, *arg
|
k.__send__(v, *arg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@observer_state = false
|
@observer_state = false
|
||||||
|
@ -1749,7 +1749,7 @@ XXX
|
|||||||
#
|
#
|
||||||
def visit(id, *args, &block)
|
def visit(id, *args, &block)
|
||||||
@stack.reverse_each do |el|
|
@stack.reverse_each do |el|
|
||||||
el.send(id, *args, &block)
|
el.__send__(id, *args, &block)
|
||||||
end
|
end
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
@ -36,15 +36,15 @@
|
|||||||
# Hash keys with spaces or characters that could normally not be used for
|
# Hash keys with spaces or characters that could normally not be used for
|
||||||
# method calls (e.g. <code>()[]*</code>) will not be immediately available
|
# method calls (e.g. <code>()[]*</code>) will not be immediately available
|
||||||
# on the OpenStruct object as a method for retrieval or assignment, but can
|
# on the OpenStruct object as a method for retrieval or assignment, but can
|
||||||
# still be reached through the Object#send method or using [].
|
# still be reached through the Object#__send__ method or using [].
|
||||||
#
|
#
|
||||||
# measurements = OpenStruct.new("length (in inches)" => 24)
|
# measurements = OpenStruct.new("length (in inches)" => 24)
|
||||||
# measurements[:"length (in inches)"] # => 24
|
# measurements[:"length (in inches)"] # => 24
|
||||||
# measurements.send("length (in inches)") # => 24
|
# measurements.__send__("length (in inches)") # => 24
|
||||||
#
|
#
|
||||||
# message = OpenStruct.new(:queued? => true)
|
# message = OpenStruct.new(:queued? => true)
|
||||||
# message.queued? # => true
|
# message.queued? # => true
|
||||||
# message.send("queued?=", false)
|
# message.__send__("queued?=", false)
|
||||||
# message.queued? # => false
|
# message.queued? # => false
|
||||||
#
|
#
|
||||||
# Removing the presence of an attribute requires the execution of the
|
# Removing the presence of an attribute requires the execution of the
|
||||||
|
@ -288,7 +288,7 @@ module Racc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_user_code(label, src)
|
def add_user_code(label, src)
|
||||||
@result.params.send(USER_CODE_LABELS[label]).push src
|
@result.params.public_send(USER_CODE_LABELS[label]).push src
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -156,7 +156,7 @@ class RDoc::Markup::Formatter
|
|||||||
method_name = "handle_regexp_#{name}"
|
method_name = "handle_regexp_#{name}"
|
||||||
|
|
||||||
if respond_to? method_name then
|
if respond_to? method_name then
|
||||||
target.text = send method_name, target
|
target.text = public_send method_name, target
|
||||||
handled = true
|
handled = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1228,7 +1228,7 @@ or the PAGER environment variable.
|
|||||||
# +cache+ indicate if it is a class or instance method.
|
# +cache+ indicate if it is a class or instance method.
|
||||||
|
|
||||||
def load_method store, cache, klass, type, name
|
def load_method store, cache, klass, type, name
|
||||||
methods = store.send(cache)[klass]
|
methods = store.public_send(cache)[klass]
|
||||||
|
|
||||||
return unless methods
|
return unless methods
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ def cp
|
|||||||
options[:preserve] = true if options.delete :p
|
options[:preserve] = true if options.delete :p
|
||||||
dest = argv.pop
|
dest = argv.pop
|
||||||
argv = argv[0] if argv.size == 1
|
argv = argv[0] if argv.size == 1
|
||||||
FileUtils.send cmd, argv, dest, **options
|
FileUtils.__send__ cmd, argv, dest, **options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ def ln
|
|||||||
options[:force] = true if options.delete :f
|
options[:force] = true if options.delete :f
|
||||||
dest = argv.pop
|
dest = argv.pop
|
||||||
argv = argv[0] if argv.size == 1
|
argv = argv[0] if argv.size == 1
|
||||||
FileUtils.send cmd, argv, dest, **options
|
FileUtils.__send__ cmd, argv, dest, **options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ def rm
|
|||||||
cmd = "rm"
|
cmd = "rm"
|
||||||
cmd += "_r" if options.delete :r
|
cmd += "_r" if options.delete :r
|
||||||
options[:force] = true if options.delete :f
|
options[:force] = true if options.delete :f
|
||||||
FileUtils.send cmd, argv, **options
|
FileUtils.__send__ cmd, argv, **options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ def mkdir
|
|||||||
setup("p") do |argv, options|
|
setup("p") do |argv, options|
|
||||||
cmd = "mkdir"
|
cmd = "mkdir"
|
||||||
cmd += "_p" if options.delete :p
|
cmd += "_p" if options.delete :p
|
||||||
FileUtils.send cmd, argv, **options
|
FileUtils.__send__ cmd, argv, **options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1097,7 +1097,7 @@ module URI
|
|||||||
# # => "http://my.example.com/main.rbx?page=1"
|
# # => "http://my.example.com/main.rbx?page=1"
|
||||||
#
|
#
|
||||||
def merge(oth)
|
def merge(oth)
|
||||||
rel = parser.send(:convert_to_uri, oth)
|
rel = parser.__send__(:convert_to_uri, oth)
|
||||||
|
|
||||||
if rel.absolute?
|
if rel.absolute?
|
||||||
#raise BadURIError, "both URI are absolute" if absolute?
|
#raise BadURIError, "both URI are absolute" if absolute?
|
||||||
@ -1182,7 +1182,7 @@ module URI
|
|||||||
|
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
def route_from0(oth)
|
def route_from0(oth)
|
||||||
oth = parser.send(:convert_to_uri, oth)
|
oth = parser.__send__(:convert_to_uri, oth)
|
||||||
if self.relative?
|
if self.relative?
|
||||||
raise BadURIError,
|
raise BadURIError,
|
||||||
"relative URI: #{self}"
|
"relative URI: #{self}"
|
||||||
@ -1290,7 +1290,7 @@ module URI
|
|||||||
# #=> #<URI::Generic /main.rbx?page=1>
|
# #=> #<URI::Generic /main.rbx?page=1>
|
||||||
#
|
#
|
||||||
def route_to(oth)
|
def route_to(oth)
|
||||||
parser.send(:convert_to_uri, oth).route_from(self)
|
parser.__send__(:convert_to_uri, oth).route_from(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -1404,7 +1404,7 @@ module URI
|
|||||||
# Returns an Array of the components defined from the COMPONENT Array.
|
# Returns an Array of the components defined from the COMPONENT Array.
|
||||||
def component_ary
|
def component_ary
|
||||||
component.collect do |x|
|
component.collect do |x|
|
||||||
self.send(x)
|
self.__send__(x)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
protected :component_ary
|
protected :component_ary
|
||||||
@ -1429,7 +1429,7 @@ module URI
|
|||||||
def select(*components)
|
def select(*components)
|
||||||
components.collect do |c|
|
components.collect do |c|
|
||||||
if component.include?(c)
|
if component.include?(c)
|
||||||
self.send(c)
|
self.__send__(c)
|
||||||
else
|
else
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
"expected of components of #{self.class} (#{self.class.component.join(', ')})"
|
"expected of components of #{self.class} (#{self.class.component.join(', ')})"
|
||||||
|
@ -85,7 +85,7 @@ module WEBrick
|
|||||||
def log(meth, fmt, *args)
|
def log(meth, fmt, *args)
|
||||||
msg = format("%s %s: ", @auth_scheme, @realm)
|
msg = format("%s %s: ", @auth_scheme, @realm)
|
||||||
msg << fmt % args
|
msg << fmt % args
|
||||||
@logger.send(meth, msg)
|
@logger.__send__(meth, msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
def error(fmt, *args)
|
def error(fmt, *args)
|
||||||
|
@ -115,7 +115,7 @@ module WEBrick
|
|||||||
proxy_auth(req, res)
|
proxy_auth(req, res)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
self.send("do_#{req.request_method}", req, res)
|
public_send("do_#{req.request_method}", req, res)
|
||||||
rescue NoMethodError
|
rescue NoMethodError
|
||||||
raise HTTPStatus::MethodNotAllowed,
|
raise HTTPStatus::MethodNotAllowed,
|
||||||
"unsupported method `#{req.request_method}'."
|
"unsupported method `#{req.request_method}'."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user