Method: Chef::Provider.action

Defined in:
lib/chef/provider.rb

.action(name, description: nil, &block) ⇒ void

This method returns an undefined value.

Defines an action method on the provider, running the block to compile the resources, converging them, and then checking if any were updated (and updating new-resource if so)

Parameters:

  • name (String, Symbol)

    Name of the action to define.

  • description (String) (defaults to: nil)

    description of the action

  • block (Proc)

    Body of the action.

Since:

  • 13.0



63
64
65
66
67
68
69
70
71
72
# File 'lib/chef/provider.rb', line 63

def self.action(name, description: nil, &block)
  action_descriptions[name.to_sym] = description unless description.nil?
  # We need the block directly in a method so that `return` works.
  define_method("compile_action_#{name}", &block)
  class_eval "    def action_\#{name}\n      compile_and_converge_action { compile_action_\#{name} }\n    end\n  EOM\nend\n"