Module: Mongoid::Config::DeprecatedOptions

Included in:
Mongoid::Config
Defined in:
lib/mongoid/config.rb

Overview

Wraps configuration options that have been deprecated so that assigning them emits a deprecation warning. OPTIONS is intentionally empty when no options are currently deprecated; it is populated as options are retired, at which point this module rewrites their setters to warn.

Constant Summary collapse

OPTIONS =
%i[]

Class Method Summary collapse

Class Method Details

.prepended(klass) ⇒ Object



597
598
599
600
601
602
603
604
605
606
607
608
# File 'lib/mongoid/config.rb', line 597

def self.prepended(klass)
  klass.class_eval do
    OPTIONS.each do |option|
      alias_method :"#{option}_without_deprecation=", :"#{option}="

      define_method(:"#{option}=") do |value|
        Mongoid::Warnings.send(:"warn_#{option}_deprecated")
        send(:"#{option}_without_deprecation=", value)
      end
    end
  end
end