123456789_123456789_123456789_123456789_123456789_

Class: Mongoid::Deprecation

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveSupport::Deprecation
Instance Chain:
self, ActiveSupport::Deprecation
Inherits: ActiveSupport::Deprecation
  • Object
Defined in: lib/mongoid/deprecation.rb

Overview

Utility class for logging deprecation warnings.

Class Method Summary

Instance Method Summary

Constructor Details

.newDeprecation

[ GitHub ]

  
# 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.

[ GitHub ]

  
# 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