class ActiveSupport::Deprecation::DeprecatedObjectProxy

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>"

Public Class Methods

new(object, message, deprecator = nil) click to toggle source
# File lib/active_support/deprecation/proxy_wrappers.rb, line 39
def initialize(object, message, deprecator = nil)
  @object = object
  @message = message
  ActiveSupport.deprecator.warn("DeprecatedObjectProxy without a deprecator is deprecated") unless deprecator
  @deprecator = deprecator || ActiveSupport::Deprecation._instance
end

Private Instance Methods

target() click to toggle source
# File lib/active_support/deprecation/proxy_wrappers.rb, line 47
def target
  @object
end
warn(callstack, called, args) click to toggle source
# File lib/active_support/deprecation/proxy_wrappers.rb, line 51
def warn(callstack, called, args)
  @deprecator.warn(@message, callstack)
end