123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::Deprecation::DeprecatedObjectProxy

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveSupport::Deprecation::DeprecationProxy
Defined in: activesupport/lib/active_support/deprecation/proxy_wrappers.rb

Overview

DeprecatedObjectProxy transforms an object into a deprecated one. It takes an object, a deprecation message, and a deprecator.

deprecated_object = {ActiveSupport::Deprecation::DeprecatedObjectProxy.new}(Object.new, "This object is now deprecated", {ActiveSupport::Deprecation.new})
### => {#<}Object:0x007fb9b34c34b0>

deprecated_object.to_s
DEPRECATION WARNING: This object is now deprecated.
(Backtrace)
### => "#<Object:0x007fb9b34c34b0>"

Class Method Summary

Instance Attribute Summary

Instance Method Summary

DeprecationProxy - Inherited

#inspect

Don't give a deprecation warning on inspect since test/unit and error logs rely on it for diagnostics.

#method_missing

Constructor Details

.new(object, message, deprecator) ⇒ DeprecatedObjectProxy

[ GitHub ]

  
# File 'activesupport/lib/active_support/deprecation/proxy_wrappers.rb', line 42

def initialize(object, message, deprecator)
  @object = object
  @message = message
  @deprecator = deprecator
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveSupport::Deprecation::DeprecationProxy

Instance Attribute Details

#target (rw, private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/deprecation/proxy_wrappers.rb', line 53

def target
  @object
end

#target=(object) (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/deprecation/proxy_wrappers.rb', line 48

def target=(object)
  @object = object
end

Instance Method Details

#warn(callstack, called) (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/deprecation/proxy_wrappers.rb', line 57

def warn(callstack, called, *, **)
  @deprecator.warn(@message, callstack)
end