Method: Chef::Resource.default_action

Defined in:
lib/chef/resource.rb

.default_action(action_name = NOT_PASSED) ⇒ Array<Symbol>

The action that will be run if no other action is specified.

Setting default_action will automatically add the action to allowed_actions, if it isn’t already there.

Defaults to [:nothing].

Parameters:

  • action_name (Symbol, Array<Symbol>) (defaults to: NOT_PASSED)

    The default action (or series of actions) to use.

Returns:

  • (Array<Symbol>)

    The default actions for the resource.



1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
# File 'lib/chef/resource.rb', line 1029

def self.default_action(action_name = NOT_PASSED)
  unless action_name.equal?(NOT_PASSED)
    @default_action = Array(action_name).map(&:to_sym)
    self.allowed_actions |= @default_action
  end

  if defined?(@default_action) && @default_action
    @default_action
  elsif superclass.respond_to?(:default_action)
    superclass.default_action
  else
    [:nothing]
  end
end