module Chef::Mixin
Public Class Methods
Source
# File lib/chef/mixin/deprecation.rb, line 44 def self.const_missing(name) if new_const = deprecated_constants[name] Chef::Log.warn(new_const[:message]) Chef::Log.warn("Called from: \n#{caller[0...3].map { |l| "\t#{l}" }.join("\n")}") new_const[:replacement] else super end end
Const missing hook to look up deprecated constants defined with deprecate_constant. Emits a warning to the logger and returns the replacement constant. Will call super, most likely causing an exception for the missing constant, if name
is not found in the deprecated_constants
collection.
Calls superclass method
Source
# File lib/chef/mixin/deprecation.rb, line 35 def self.deprecate_constant(name, replacement, message) deprecated_constants[name] = { replacement: replacement, message: message } end
Add a deprecated constant to the Chef::Mixin
namespace.
@param name [Symbol] the constant name, as a relative symbol. @param replacement [Object] the constant to return instead. @param message [String] A message telling the user what to do instead. @example
deprecate_constant(:RecipeDefinitionDSLCore, Chef::DSL::Recipe, <<-EOM) Chef::Mixin::RecipeDefinitionDSLCore is deprecated, use Chef::DSL::Recipe instead. EOM
Source
# File lib/chef/mixin/deprecation.rb, line 22 def self.deprecated_constants @deprecated_constants ||= {} end