module Chef::Mixin
Public Class Methods
const_missing(name)
click to toggle source
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
# File lib/chef/mixin/deprecation.rb, line 45 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
deprecate_constant(name, replacement, message)
click to toggle source
Add a deprecated constant to the Chef::Mixin namespace.
Arguments¶ ↑
-
name: the constant name, as a relative symbol.
-
replacement: the constant to return instead.
-
message: A message telling the user what to do instead.
Example:¶ ↑
deprecate_constant(:RecipeDefinitionDSLCore, Chef::DSL::Recipe, " Chef::Mixin::RecipeDefinitionDSLCore is deprecated, use Chef::DSL::Recipe instead. ")
# File lib/chef/mixin/deprecation.rb, line 36 def self.deprecate_constant(name, replacement, message) deprecated_constants[name] = {:replacement => replacement, :message => message} end
deprecated_constants()
click to toggle source
# File lib/chef/mixin/deprecation.rb, line 23 def self.deprecated_constants @deprecated_constants ||= {} end