Class: Mongoid::Deprecation

Inherits:
ActiveSupport::Deprecation
  • Object
show all
Defined in:
lib/mongoid/deprecation.rb

Overview

Utility class for logging deprecation warnings.

Instance Method Summary collapse

Constructor Details

#initializeDeprecation

Returns a new instance of Deprecation.



9
10
11
12
13
14
# File 'lib/mongoid/deprecation.rb', line 9

def initialize
  # Per change policy, deprecations will be removed in the next major version.
  deprecation_horizon = "#{Mongoid::VERSION.split('.').first.to_i + 1}.0".freeze
  gem_name = 'Mongoid'
  super(deprecation_horizon, gem_name)
end

Instance Method Details

#behaviorArray<Proc>

Overrides default ActiveSupport::Deprecation behavior to use Mongoid’s logger.

Returns:

  • (Array<Proc>)

    The deprecation behavior.



21
22
23
24
25
26
27
# File 'lib/mongoid/deprecation.rb', line 21

def behavior
  @behavior ||= Array(->(*args) {
    logger = Mongoid.logger
    logger.warn(args[0])
    logger.debug(args[1].join("\n  ")) if debug
  })
end