class ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy
Default deprecator is ActiveSupport::Deprecation.
instance variable.
variable via request method and execute the same method on non-proxywarn method on deprecator_instance and will fetch @_request
When someone execute any method on @request variable this will trigger
end
end
@request
def old_request
end
@_request
def request
end
@_request = :a_request
@request = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :request, :@request, deprecator)
def initialize(deprecator)
class Example
deprecated instance variable.
This DeprecatedInstanceVariableProxy transforms instance variable to
def initialize(instance, method, var = "@#{method}", deprecator = ActiveSupport::Deprecation.instance)
def initialize(instance, method, var = "@#{method}", deprecator = ActiveSupport::Deprecation.instance) @instance = instance @method = method @var = var @deprecator = deprecator end
def target
def target @instance.__send__(@method) end
def warn(callstack, called, args)
def warn(callstack, called, args) @deprecator.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack) end