summaryrefslogtreecommitdiff
path: root/lib/chef/resource.rb
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2015-06-29 11:04:08 -0700
committerNoah Kantrowitz <noah@coderanger.net>2015-06-29 11:04:08 -0700
commit84846e365a792801ef036b67ea9409c348b99096 (patch)
tree7ab972e535c876a4a1d756fdc7d2cec3e19e35e7 /lib/chef/resource.rb
parentb45894a439bcff3a49af2bf5e817cbe662a0329a (diff)
downloadchef-84846e365a792801ef036b67ea9409c348b99096.tar.gz
Handle setting default action with the same coercion logic as action.
This coerces default_action(:one) so action() == [:one]. Also update doctoring to match behavior.
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r--lib/chef/resource.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 0240554b3d..f2f14b6955 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -1093,22 +1093,17 @@ class Chef
# Setting default_action will automatially add the action to
# allowed_actions, if it isn't already there.
#
- # Defaults to :nothing.
+ # Defaults to [:nothing].
#
# @param action_name [Symbol,Array<Symbol>] The default action (or series
# of actions) to use.
#
- # @return [Symbol,Array<Symbol>] The default actions for the resource.
+ # @return [Array<Symbol>] The default actions for the resource.
#
def self.default_action(action_name=NOT_PASSED)
unless action_name.equal?(NOT_PASSED)
- if action_name.is_a?(Array)
- @default_action = action_name.map { |arg| arg.to_sym }
- else
- @default_action = action_name.to_sym
- end
-
- self.allowed_actions |= Array(@default_action)
+ @default_action = Array(action_name).map(&:to_sym)
+ self.allowed_actions |= @default_action
end
if @default_action