diff options
author | Jamis Buck <jamis@37signals.com> | 2006-10-24 16:56:59 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-10-24 16:56:59 +0000 |
commit | 3a318970b19129c2ba57ebf576015dfa653613e8 (patch) | |
tree | a9676d0d1db7ed9fc823d52af4573317805e3525 /activesupport/lib | |
parent | 53a97e9d610c03024b21d5d87681d98b5ed115bf (diff) | |
download | rails-3a318970b19129c2ba57ebf576015dfa653613e8.tar.gz rails-3a318970b19129c2ba57ebf576015dfa653613e8.tar.bz2 rails-3a318970b19129c2ba57ebf576015dfa653613e8.zip |
Extend deprecate so that alternatives can be specified via the deprecation
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5356 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/deprecation.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index 297a17850e..621cc14cea 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -71,11 +71,13 @@ module ActiveSupport module ClassMethods # Declare that a method has been deprecated. def deprecate(*method_names) + options = method_names.last.is_a?(Hash) ? method_names.pop : {} + method_names = method_names + options.keys method_names.each do |method_name| alias_method_chain(method_name, :deprecation) do |target, punctuation| class_eval(<<-EOS, __FILE__, __LINE__) def #{target}_with_deprecation#{punctuation}(*args, &block) - ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:#{method_name}), caller) + ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:#{method_name}, #{options[method_name].inspect}), caller) #{target}_without_deprecation#{punctuation}(*args, &block) end EOS @@ -83,8 +85,13 @@ module ActiveSupport end end - def deprecated_method_warning(method_name) - "#{method_name} is deprecated and will be removed from Rails #{deprecation_horizon}" + def deprecated_method_warning(method_name, message=nil) + warning = "#{method_name} is deprecated and will be removed from Rails #{deprecation_horizon}" + case message + when Symbol then "#{warning} (use #{message} instead)" + when String then "#{warning} (#{message})" + else warning + end end def deprecation_horizon |