Module: Chef::Mixin

Defined in:
lib/chef/mixin/uris.rb,
lib/chef/mixin/which.rb,
lib/chef/mixin/why_run.rb,
lib/chef/mixin/checksum.rb,
lib/chef/mixin/provides.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/properties.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/unformatter.rb,
lib/chef/mixin/wide_string.rb,
lib/chef/mixin/user_context.rb,
lib/chef/mixin/homebrew_user.rb,
lib/chef/mixin/versioned_api.rb,
lib/chef/mixin/openssl_helper.rb,
lib/chef/mixin/powershell_out.rb,
lib/chef/mixin/notifying_block.rb,
lib/chef/mixin/params_validate.rb,
lib/chef/mixin/powershell_exec.rb,
lib/chef/mixin/proxified_socket.rb,
lib/chef/mixin/subclass_directive.rb,
lib/chef/mixin/windows_env_helper.rb,
lib/chef/mixin/descendants_tracker.rb,
lib/chef/mixin/lazy_module_include.rb,
lib/chef/mixin/convert_to_class_name.rb,
lib/chef/mixin/get_source_from_package.rb,
lib/chef/mixin/powershell_type_coercions.rb,
lib/chef/mixin/windows_architecture_helper.rb,
lib/chef/mixin/api_version_request_handling.rb,
lib/chef/mixin/enforce_ownership_and_permissions.rb

Defined Under Namespace

Modules: ApiVersionRequestHandling, Checksum, ConvertToClassName, CreatePath, DeepMerge, Deprecation, DescendantsTracker, EnforceOwnershipAndPermissions, FileClass, FromFile, GetSourceFromPackage, HomebrewUser, LazyModuleInclude, NotifyingBlock, OpenSSLHelper, ParamsValidate, PathSanity, PowershellExec, PowershellOut, PowershellTypeCoercions, Properties, Provides, ProxifiedSocket, Securable, ShellOut, SubclassDirective, Template, Unformatter, Uris, UserContext, VersionedAPI, VersionedAPIFactory, Which, WhyRun, WideString, WindowsArchitectureHelper, WindowsEnvHelper, 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.



44
45
46
47
48
49
50
51
52
# 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

.deprecate_constant(name, replacement, message) ⇒ Object

Add a deprecated constant to the Chef::Mixin namespace.

Examples:

deprecate_constant(:RecipeDefinitionDSLCore, Chef::DSL::Recipe, <<-EOM)
  Chef::Mixin::RecipeDefinitionDSLCore is deprecated, use Chef::DSL::Recipe instead.
EOM

Parameters:

  • name (Symbol)

    the constant name, as a relative symbol.

  • replacement (Object)

    the constant to return instead.

  • message (String)

    A message telling the user what to do instead.



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

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

.deprecated_constantsObject



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

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