Module: Mongoid::Deprecable Private

Included in:
Mongoid
Defined in:
build/mongoid-master/lib/mongoid/deprecable.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Adds ability to declare Mongoid-specific deprecations.

Instance Method Summary collapse

Instance Method Details

#deprecate(target_module, *method_descriptors) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Declares method(s) as deprecated.

Examples:

Deprecate a method.

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

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

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

Parameters:

  • target_module (Module)

    The parent which contains the method.

  • method_descriptors (Symbol | Hash<Symbol, [Symbol|String]>)

    The methods to deprecate, with optional replacement instructions.



29
30
31
# File 'build/mongoid-master/lib/mongoid/deprecable.rb', line 29

def deprecate(target_module, *method_descriptors)
  Mongoid::Deprecation.deprecate_methods(target_module, *method_descriptors)
end