Method: Chef.deprecated

Defined in:
lib/chef/chef_class.rb

.deprecated(type, message, location = nil) ⇒ void

This method returns an undefined value.

Emit a deprecation message.

Examples:

Chef.deprecated(:my_deprecation, message: "This is deprecated!")

Parameters:

  • type (Symbol)

    The message to send. This should refer to a class defined in Chef::Deprecated

  • message (String, nil)

    An explicit message to display, rather than the generic one associated with the deprecation.

  • location (String, nil) (defaults to: nil)

    The location. Defaults to the caller who called you (since generally the person who triggered the check is the one that needs to be fixed).



216
217
218
219
220
221
222
223
224
225
226
# File 'lib/chef/chef_class.rb', line 216

def deprecated(type, message, location = nil)
  location ||= Chef::Log.caller_location
  deprecation = Chef::Deprecated.create(type, message, location)
  # `run_context.events` is the primary deprecation target if we're in a
  # run. If we are not yet in a run, print to `Chef::Log`.
  if run_context && run_context.events
    run_context.events.deprecation(deprecation, location)
  elsif !deprecation.silenced?
    Chef::Log.deprecation(deprecation.to_s)
  end
end