123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Deprecable Private

Do not use. This module is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Defined in: lib/mongoid/deprecable.rb

Overview

Adds ability to declare Mongoid-specific deprecations.

Instance Method Summary

Instance Method Details

#deprecate(target_module, *method_descriptors)

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.

[ GitHub ]

  
# 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