module Mongoid::Deprecable

Adds ability to declare Mongoid-specific deprecations.

@api private

Public Instance Methods

deprecate(target_module, *method_descriptors) click to toggle source

Declares method(s) as deprecated.

@example Deprecate a method.

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

@example Deprecate a method and declare the replacement method.

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

@example Deprecate a method and give replacement instructions.

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

@param [ Module ] target_module The parent which contains the method. @param [ [ Symbol | Hash<Symbol, [ Symbol | String ]> ]… ] *method_descriptors

The methods to deprecate, with optional replacement instructions.
# File lib/mongoid/deprecable.rb, line 30
def deprecate(target_module, *method_descriptors)
  @_deprecator ||= Mongoid::Deprecation.new
  @_deprecator.deprecate_methods(target_module, *method_descriptors)
end