Method: Chef::Resource#action

Defined in:
lib/chef/resource.rb

#action(arg = nil) ⇒ Array[Symbol]

The action or actions that will be taken when this resource is run.

Parameters:

  • arg (Array[Symbol], Symbol) (defaults to: nil)

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

Returns:

  • (Array[Symbol])

    the list of actions.



150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/chef/resource.rb', line 150

def action(arg = nil)
  if arg
    arg = Array(arg).map(&:to_sym)
    arg.each do |action|
      validate(
        { action: action },
        { action: { kind_of: Symbol, equal_to: allowed_actions } }
      )
    end
    @action = arg
  else
    @action
  end
end