mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
respond_to_missing?
should be private
Follow up of03d3f036
. Some of `respond_to?` were replaced to `respond_to_missing?` in03d3f036
. But the visibility is still public. It should be private.
This commit is contained in:
parent
0541a0d548
commit
ca9ac31002
10 changed files with 40 additions and 46 deletions
|
@ -326,11 +326,11 @@ module Mime
|
||||||
|
|
||||||
def ref; end
|
def ref; end
|
||||||
|
|
||||||
def respond_to_missing?(method, include_private = false)
|
private
|
||||||
|
def respond_to_missing?(method, _)
|
||||||
method.to_s.ends_with? "?"
|
method.to_s.ends_with? "?"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
def method_missing(method, *args)
|
def method_missing(method, *args)
|
||||||
false if method.to_s.ends_with? "?"
|
false if method.to_s.ends_with? "?"
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,8 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to_missing?(method, include_private = false)
|
private
|
||||||
|
def respond_to_missing?(method, _)
|
||||||
super || @helpers.respond_to?(method)
|
super || @helpers.respond_to?(method)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ module ActionDispatch
|
||||||
@helpers.#{method}(*args)
|
@helpers.#{method}(*args)
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
send(method, *args)
|
public_send(method, *args)
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
|
@ -385,14 +385,15 @@ module ActionDispatch
|
||||||
integration_session.default_url_options = options
|
integration_session.default_url_options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to_missing?(method, include_private = false)
|
private
|
||||||
integration_session.respond_to?(method, include_private) || super
|
def respond_to_missing?(method, _)
|
||||||
|
integration_session.respond_to?(method) || super
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delegate unhandled messages to the current session instance.
|
# Delegate unhandled messages to the current session instance.
|
||||||
def method_missing(sym, *args, &block)
|
def method_missing(method, *args, &block)
|
||||||
if integration_session.respond_to?(sym)
|
if integration_session.respond_to?(method)
|
||||||
integration_session.__send__(sym, *args, &block).tap do
|
integration_session.public_send(method, *args, &block).tap do
|
||||||
copy_session_variables!
|
copy_session_variables!
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module ActiveRecord
|
module ActiveRecord
|
||||||
module DynamicMatchers #:nodoc:
|
module DynamicMatchers #:nodoc:
|
||||||
def respond_to_missing?(name, include_private = false)
|
private
|
||||||
|
def respond_to_missing?(name, _)
|
||||||
if self == Base
|
if self == Base
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
|
@ -9,8 +10,6 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def method_missing(name, *arguments, &block)
|
def method_missing(name, *arguments, &block)
|
||||||
match = Method.match(self, name)
|
match = Method.match(self, name)
|
||||||
|
|
||||||
|
|
|
@ -92,10 +92,6 @@ module ActiveRecord
|
||||||
send(method, args, &block)
|
send(method, args, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to_missing?(*args) # :nodoc:
|
|
||||||
super || delegate.respond_to?(*args)
|
|
||||||
end
|
|
||||||
|
|
||||||
ReversibleAndIrreversibleMethods.each do |method|
|
ReversibleAndIrreversibleMethods.each do |method|
|
||||||
class_eval <<-EOV, __FILE__, __LINE__ + 1
|
class_eval <<-EOV, __FILE__, __LINE__ + 1
|
||||||
def #{method}(*args, &block) # def create_table(*args, &block)
|
def #{method}(*args, &block) # def create_table(*args, &block)
|
||||||
|
@ -225,10 +221,14 @@ module ActiveRecord
|
||||||
[:add_foreign_key, reversed_args]
|
[:add_foreign_key, reversed_args]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def respond_to_missing?(method, _)
|
||||||
|
super || delegate.respond_to?(method)
|
||||||
|
end
|
||||||
|
|
||||||
# Forwards any missing method call to the \target.
|
# Forwards any missing method call to the \target.
|
||||||
def method_missing(method, *args, &block)
|
def method_missing(method, *args, &block)
|
||||||
if @delegate.respond_to?(method)
|
if delegate.respond_to?(method)
|
||||||
@delegate.send(method, *args, &block)
|
delegate.public_send(method, *args, &block)
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
|
@ -109,12 +109,10 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to_missing?(method, include_private = false)
|
|
||||||
super || @klass.respond_to?(method, include_private) ||
|
|
||||||
arel.respond_to?(method, include_private)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def respond_to_missing?(method, _)
|
||||||
|
super || @klass.respond_to?(method) || arel.respond_to?(method)
|
||||||
|
end
|
||||||
|
|
||||||
def method_missing(method, *args, &block)
|
def method_missing(method, *args, &block)
|
||||||
if @klass.respond_to?(method)
|
if @klass.respond_to?(method)
|
||||||
|
|
|
@ -2040,7 +2040,6 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
|
||||||
def test_respond_to_private_class_methods
|
def test_respond_to_private_class_methods
|
||||||
client_association = companies(:first_firm).clients
|
client_association = companies(:first_firm).clients
|
||||||
assert !client_association.respond_to?(:private_method)
|
assert !client_association.respond_to?(:private_method)
|
||||||
assert client_association.respond_to?(:private_method, true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creating_using_primary_key
|
def test_creating_using_primary_key
|
||||||
|
|
|
@ -594,7 +594,7 @@ class RelationTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_respond_to_delegates_to_relation
|
def test_respond_to_delegates_to_arel
|
||||||
relation = Topic.all
|
relation = Topic.all
|
||||||
fake_arel = Struct.new(:responds) {
|
fake_arel = Struct.new(:responds) {
|
||||||
def respond_to?(method, access = false)
|
def respond_to?(method, access = false)
|
||||||
|
@ -607,10 +607,6 @@ class RelationTest < ActiveRecord::TestCase
|
||||||
|
|
||||||
relation.respond_to?(:matching_attributes)
|
relation.respond_to?(:matching_attributes)
|
||||||
assert_equal [:matching_attributes, false], fake_arel.responds.first
|
assert_equal [:matching_attributes, false], fake_arel.responds.first
|
||||||
|
|
||||||
fake_arel.responds = []
|
|
||||||
relation.respond_to?(:matching_attributes, true)
|
|
||||||
assert_equal [:matching_attributes, true], fake_arel.responds.first
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_respond_to_dynamic_finders
|
def test_respond_to_dynamic_finders
|
||||||
|
|
|
@ -305,10 +305,6 @@ module ActiveSupport
|
||||||
to_i
|
to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to_missing?(method, include_private = false) #:nodoc:
|
|
||||||
@value.respond_to?(method, include_private)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Build ISO 8601 Duration string for this duration.
|
# Build ISO 8601 Duration string for this duration.
|
||||||
# The +precision+ parameter can be used to limit seconds' precision of duration.
|
# The +precision+ parameter can be used to limit seconds' precision of duration.
|
||||||
def iso8601(precision: nil)
|
def iso8601(precision: nil)
|
||||||
|
@ -335,8 +331,12 @@ module ActiveSupport
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def respond_to_missing?(method, _)
|
||||||
|
value.respond_to?(method)
|
||||||
|
end
|
||||||
|
|
||||||
def method_missing(method, *args, &block)
|
def method_missing(method, *args, &block)
|
||||||
value.send(method, *args, &block)
|
value.public_send(method, *args, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def raise_type_error(other)
|
def raise_type_error(other)
|
||||||
|
|
|
@ -162,10 +162,6 @@ module Rails
|
||||||
@instance ||= new
|
@instance ||= new
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to_missing?(*args)
|
|
||||||
instance.respond_to?(*args) || super
|
|
||||||
end
|
|
||||||
|
|
||||||
# Allows you to configure the railtie. This is the same method seen in
|
# Allows you to configure the railtie. This is the same method seen in
|
||||||
# Railtie::Configurable, but this module is no longer required for all
|
# Railtie::Configurable, but this module is no longer required for all
|
||||||
# subclasses of Railtie so we provide the class method here.
|
# subclasses of Railtie so we provide the class method here.
|
||||||
|
@ -178,6 +174,10 @@ module Rails
|
||||||
ActiveSupport::Inflector.underscore(string).tr("/", "_")
|
ActiveSupport::Inflector.underscore(string).tr("/", "_")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def respond_to_missing?(name, _)
|
||||||
|
instance.respond_to?(name) || super
|
||||||
|
end
|
||||||
|
|
||||||
# If the class method does not have a method, then send the method call
|
# If the class method does not have a method, then send the method call
|
||||||
# to the Railtie instance.
|
# to the Railtie instance.
|
||||||
def method_missing(name, *args, &block)
|
def method_missing(name, *args, &block)
|
||||||
|
|
Loading…
Reference in a new issue