1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/lib/active_support/deprecation/method_wrappers.rb

28 lines
1.5 KiB
Ruby
Raw Normal View History

2009-04-18 00:29:30 -04:00
require 'active_support/core_ext/module/deprecation'
module ActiveSupport
class << Deprecation
# Declare that a method has been deprecated.
def deprecate_methods(target_module, *method_names)
options = method_names.extract_options!
method_names += options.keys
method_names.each do |method_name|
target_module.alias_method_chain(method_name, :deprecation) do |target, punctuation|
target_module.module_eval(<<-end_eval, __FILE__, __LINE__)
def #{target}_with_deprecation#{punctuation}(*args, &block) # def generate_secret_with_deprecation(*args, &block)
::ActiveSupport::Deprecation.warn( # ::ActiveSupport::Deprecation.warn(
::ActiveSupport::Deprecation.deprecated_method_warning( # ::ActiveSupport::Deprecation.deprecated_method_warning(
:#{method_name}, # :generate_secret,
#{options[method_name].inspect}), # "You should use ActiveSupport::SecureRandom.hex(64)"),
caller # caller
) # )
#{target}_without_deprecation#{punctuation}(*args, &block) # generate_secret_without_deprecation(*args, &block)
end # end
end_eval
end
end
end
end
end