From eff64790fc92a0c661bde39fd78174bd366a4209 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Mon, 20 Jan 2020 01:53:54 +0900 Subject: [PATCH] Extract `message = options[method_name]` out of method definition --- .../lib/active_support/deprecation/method_wrappers.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/deprecation/method_wrappers.rb b/activesupport/lib/active_support/deprecation/method_wrappers.rb index bc202ff2e4..e6cf28a89f 100644 --- a/activesupport/lib/active_support/deprecation/method_wrappers.rb +++ b/activesupport/lib/active_support/deprecation/method_wrappers.rb @@ -56,11 +56,12 @@ def deprecate_methods(target_module, *method_names) mod = nil method_names.each do |method_name| + message = options[method_name] if target_module.method_defined?(method_name) || target_module.private_method_defined?(method_name) method = target_module.instance_method(method_name) target_module.module_eval do redefine_method(method_name) do |*args, &block| - deprecator.deprecation_warning(method_name, options[method_name]) + deprecator.deprecation_warning(method_name, message) method.bind(self).call(*args, &block) end ruby2_keywords(method_name) if respond_to?(:ruby2_keywords, true) @@ -69,7 +70,7 @@ def deprecate_methods(target_module, *method_names) mod ||= Module.new mod.module_eval do define_method(method_name) do |*args, &block| - deprecator.deprecation_warning(method_name, options[method_name]) + deprecator.deprecation_warning(method_name, message) super(*args, &block) end ruby2_keywords(method_name) if respond_to?(:ruby2_keywords, true)