模块:Mongoid::Deprecable Private

包含在:
Mongoid
定义于:
lib/mongoid/deprecable.rb

Overview

该模块是私有 API 的一部分。 您应尽可能避免使用此模块,因为它将来可能会被删除或更改。

新增声明特定于能力的弃用功能的功能。

实例方法摘要折叠

实例方法详细信息

# deprecate (target_module, *method_descriptors) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

将方法声明为已弃用。

例子:

弃用方法。

Mongoid.deprecate(Cat, :meow); Cat.new.meow
#=> Mongoid.logger.warn("meow is deprecated and will be removed from Mongoid 8.0")

弃用方法并声明替换方法。

Mongoid.deprecate(Cat, meow: :speak); Cat.new.meow
#=> Mongoid.logger.warn("meow is deprecated and will be removed from Mongoid 8.0 (use speak instead)")

弃用方法并提供替换说明。

Mongoid.deprecate(Cat, meow: 'eat :catnip instead'); Cat.new.meow
#=> Mongoid.logger.warn("meow is deprecated and will be removed from Mongoid 8.0 (eat :catnip instead)")

参数:

  • target_module (模块)

    包含该方法的父项。

  • *method_descriptors ( [Symbol | Hash<Symbol, [Symbol | string ]> ]... )

    要弃用的方法,以及可选的替换说明。



30
31
32
33
# File 'lib/mongoid/deprecable.rb', line 30

def deprecate(target_module, *method_descriptors)
  @_deprecator ||= Mongoid::弃用.new
  @_deprecator.deprecate_methods(target_module, *method_descriptors)
end