Method: Chef::Resource#delayed_action

Defined in:
lib/chef/resource.rb

#delayed_action(arg) ⇒ Object

Force a delayed notification into this resource’s run_context.

This should most likely be paired with action :nothing

Parameters:

  • arg (Array[Symbol], Symbol)

    A list of actions (e.g. ‘:create`)



175
176
177
178
179
180
181
182
183
184
185
# File 'lib/chef/resource.rb', line 175

def delayed_action(arg)
  arg = Array(arg).map(&:to_sym)
  arg.map do |action|
    validate(
      { action: action },
      { action: { kind_of: Symbol, equal_to: allowed_actions } }
    )
    # the resource effectively sends a delayed notification to itself
    run_context.add_delayed_action(Notification.new(self, action, self, run_context.unified_mode))
  end
end