lib/active_support/deprecation.rb in activesupport-2.1.0 vs lib/active_support/deprecation.rb in activesupport-2.1.1

- old
+ new

@@ -90,11 +90,11 @@ 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}, #{options[method_name].inspect}), caller) - #{target}_without_deprecation#{punctuation}(*args, &block) + send(:#{target}_without_deprecation#{punctuation}, *args, &block) end EOS end end end @@ -107,11 +107,11 @@ else warning end end def deprecation_horizon - '2.0' + '2.2' end end module Assertions #:nodoc: def assert_deprecated(match = nil, &block) @@ -142,21 +142,15 @@ ensure ActiveSupport::Deprecation.behavior = old_behavior end end - # Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc. - # which emits deprecation warnings on any method call (except +inspect+). - class DeprecatedInstanceVariableProxy #:nodoc: + class DeprecationProxy #:nodoc: silence_warnings do instance_methods.each { |m| undef_method m unless m =~ /^__/ } end - def initialize(instance, method, var = "@#{method}") - @instance, @method, @var = instance, method, var - end - # Don't give a deprecation warning on inspect since test/unit and error # logs rely on it for diagnostics. def inspect target.inspect end @@ -164,19 +158,43 @@ private def method_missing(called, *args, &block) warn caller, called, args target.__send__(called, *args, &block) end + end + # Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc. + # which emits deprecation warnings on any method call (except +inspect+). + class DeprecatedInstanceVariableProxy < DeprecationProxy #:nodoc: + def initialize(instance, method, var = "@#{method}") + @instance, @method, @var = instance, method, var + end + + private def target @instance.__send__(@method) end def warn(callstack, called, args) ActiveSupport::Deprecation.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack) end end + class DeprecatedConstantProxy < DeprecationProxy #:nodoc: + def initialize(old_const, new_const) + @old_const = old_const + @new_const = new_const + end + + private + def target + @new_const.to_s.constantize + end + + def warn(callstack, called, args) + ActiveSupport::Deprecation.warn("#{@old_const} is deprecated! Use #{@new_const} instead.", callstack) + end + end end end class Module include ActiveSupport::Deprecation::ClassMethods