跳至内容 跳至搜索

DeprecatedObjectProxy 将对象转换为已弃用的对象。它采用一个对象、一个弃用消息和一个弃用者。

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>"
方法
N

类公共方法

new(object, message, deprecator = nil)

# File activesupport/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