Module: Chef::Mixin

Defined in:
lib/chef/mixin/command.rb,
lib/chef/mixin/why_run.rb,
lib/chef/mixin/checksum.rb,
lib/chef/mixin/language.rb,
lib/chef/mixin/template.rb,
lib/chef/mixin/from_file.rb,
lib/chef/mixin/securable.rb,
lib/chef/mixin/shell_out.rb,
lib/chef/mixin/deep_merge.rb,
lib/chef/mixin/file_class.rb,
lib/chef/mixin/xml_escape.rb,
lib/chef/mixin/create_path.rb,
lib/chef/mixin/deprecation.rb,
lib/chef/mixin/path_sanity.rb,
lib/chef/mixin/command/unix.rb,
lib/chef/mixin/command/windows.rb,
lib/chef/mixin/params_validate.rb,
lib/chef/mixin/convert_to_class_name.rb,
lib/chef/mixin/get_source_from_package.rb,
lib/chef/mixin/language_include_recipe.rb,
lib/chef/mixin/language_include_attribute.rb,
lib/chef/mixin/recipe_definition_dsl_core.rb,
lib/chef/mixin/enforce_ownership_and_permissions.rb

Defined Under Namespace

Modules: Checksum, Command, ConvertToClassName, CreatePath, DeepMerge, DeprecatedLanguageModule, Deprecation, EnforceOwnershipAndPermissions, FileClass, FromFile, GetSourceFromPackage, ParamsValidate, PathSanity, Securable, ShellOut, Template, WhyRun, XMLEscape

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object

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.



45
46
47
48
49
50
51
52
53
# 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) ⇒ Object

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, <<-EOM)
  Chef::Mixin::RecipeDefinitionDSLCore is deprecated, use Chef::DSL::Recipe instead.
EOM


36
37
38
# File 'lib/chef/mixin/deprecation.rb', line 36

def self.deprecate_constant(name, replacement, message)
  deprecated_constants[name] = {:replacement => replacement, :message => message}
end

.deprecated_constantsObject



23
24
25
# File 'lib/chef/mixin/deprecation.rb', line 23

def self.deprecated_constants
  @deprecated_constants ||= {}
end