Sha256: 05e3b3bedc1a8f7d2a000837c72df2133eefcd9e2b830a29f8cec01d8c48c3b7

Contents?: true

Size: 736 Bytes

Versions: 9

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

module Mongoid

  # Utility class for logging deprecation warnings.
  class Deprecation < ::ActiveSupport::Deprecation

    @gem_name = 'Mongoid'

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

    # Overrides default ActiveSupport::Deprecation behavior
    # to use Mongoid's logger.
    #
    # @return Array<Proc> The deprecation behavior.
    def behavior
      @behavior ||= Array(->(message, callstack, _deprecation_horizon, _gem_name) {
        logger = Mongoid.logger
        logger.warn(message)
        logger.debug(callstack.join("\n  ")) if debug
      })
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mongoid-8.1.2 lib/mongoid/deprecation.rb
mongoid-8.0.6 lib/mongoid/deprecation.rb
mongoid-8.1.1 lib/mongoid/deprecation.rb
mongoid-8.0.5 lib/mongoid/deprecation.rb
mongoid-8.1.0 lib/mongoid/deprecation.rb
mongoid-8.0.4 lib/mongoid/deprecation.rb
mongoid-8.0.3 lib/mongoid/deprecation.rb
mongoid-8.0.2 lib/mongoid/deprecation.rb
mongoid-8.0.1 lib/mongoid/deprecation.rb