diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-04-17 21:29:30 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-04-17 21:29:30 -0700 |
commit | 727e9dc18a7059f024b922b65951198ff0184fdd (patch) | |
tree | 740e578645d8fdc45dbec0a4412a8455cc05bfed /activesupport/lib/active_support/deprecation/method_wrappers.rb | |
parent | 3202671dc9360c4a89d80355824b239b52b2f611 (diff) | |
download | rails-727e9dc18a7059f024b922b65951198ff0184fdd.tar.gz rails-727e9dc18a7059f024b922b65951198ff0184fdd.tar.bz2 rails-727e9dc18a7059f024b922b65951198ff0184fdd.zip |
Dice up ActiveSupport::Deprecation
Diffstat (limited to 'activesupport/lib/active_support/deprecation/method_wrappers.rb')
-rw-r--r-- | activesupport/lib/active_support/deprecation/method_wrappers.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/deprecation/method_wrappers.rb b/activesupport/lib/active_support/deprecation/method_wrappers.rb new file mode 100644 index 0000000000..845bef059f --- /dev/null +++ b/activesupport/lib/active_support/deprecation/method_wrappers.rb @@ -0,0 +1,27 @@ +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 |