Extract message = options[method_name] out of method definition

This commit is contained in:
Ryuta Kamizono 2020-01-20 01:53:54 +09:00
parent 3a85ced1a0
commit eff64790fc

@ -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)