2009-04-18 00:29:30 -04:00
|
|
|
require 'active_support/core_ext/module/deprecation'
|
2009-04-22 20:41:28 -04:00
|
|
|
require 'active_support/core_ext/module/aliasing'
|
2010-01-01 14:55:31 -05:00
|
|
|
require 'active_support/core_ext/array/extract_options'
|
2009-04-18 00:29:30 -04:00
|
|
|
|
|
|
|
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|
|
2009-04-20 21:31:22 -04:00
|
|
|
target_module.module_eval(<<-end_eval, __FILE__, __LINE__ + 1)
|
2010-02-25 12:28:18 -05:00
|
|
|
def #{target}_with_deprecation#{punctuation}(*args, &block)
|
|
|
|
::ActiveSupport::Deprecation.warn(
|
|
|
|
::ActiveSupport::Deprecation.deprecated_method_warning(
|
|
|
|
:#{method_name},
|
|
|
|
#{options[method_name].inspect}),
|
|
|
|
caller
|
|
|
|
)
|
|
|
|
send(:#{target}_without_deprecation#{punctuation}, *args, &block)
|
|
|
|
end
|
2009-04-18 00:29:30 -04:00
|
|
|
end_eval
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|