class ActiveSupport::Deprecation::DeprecatedConstantProxy - activesupport-4.2.4 Documentation

# class ActiveSupport::Deprecation::DeprecatedConstantProxy

This DeprecatedConstantProxy transforms constant to deprecated constant.

    OLD_CONST = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('OLD_CONST', 'NEW_CONST')
    OLD_CONST = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('OLD_CONST', 'NEW_CONST', deprecator_instance)

When someone use old constant this will trigger `warn` method on `deprecator_instance`.

Default deprecator is `ActiveSupport::Deprecation`.

### Public Class Methods

new(old_const, new_const, deprecator = ActiveSupport::Deprecation.instance) click to toggle source

    # File lib/active_support/deprecation/proxy_wrappers.rb, line 106
    def initialize(old_const, new_const, deprecator = ActiveSupport::Deprecation.instance)
      @old_const = old_const
      @new_const = new_const
      @deprecator = deprecator
    end

### Public Instance Methods

class() click to toggle source

    # File lib/active_support/deprecation/proxy_wrappers.rb, line 112
    def class
      target.class
    end

### Private Instance Methods

target() click to toggle source

    # File lib/active_support/deprecation/proxy_wrappers.rb, line 117
    def target
      ActiveSupport::Inflector.constantize(@new_const.to_s)
    end

warn(callstack, called, args) click to toggle source

    # File lib/active_support/deprecation/proxy_wrappers.rb, line 121
    def warn(callstack, called, args)
      @deprecator.warn("#{@old_const} is deprecated! Use #{@new_const} instead.", callstack)
    end