summaryrefslogtreecommitdiff
path: root/lib/chef/resource/lwrp_base.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-07-23 11:53:29 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-07-23 14:20:30 -0700
commitc76575510575fb00280e2ee1b8442fe60c4a98a7 (patch)
treec579899a1cbe9efebbc7c934d467034b2e133bf8 /lib/chef/resource/lwrp_base.rb
parentacb572d390ebe47481745b5f22f7324bd4489bf3 (diff)
downloadchef-c76575510575fb00280e2ee1b8442fe60c4a98a7.tar.gz
fixup adding default_actions to action
if you specify a default_action we don't inherit from the superclass and initialize to an empty array if we have to (otherwise if we inherited from the superclass and later specified actions, we wouldn't get the correct behavior which overrides the superclass, and behavior would shift based on order of actions and default_action in the resource definition). also uses set union to eliminate dups in the (allowed) actions and eliminates dups in both cases.
Diffstat (limited to 'lib/chef/resource/lwrp_base.rb')
-rw-r--r--lib/chef/resource/lwrp_base.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb
index 6614adbcd2..5b67941a8b 100644
--- a/lib/chef/resource/lwrp_base.rb
+++ b/lib/chef/resource/lwrp_base.rb
@@ -92,13 +92,14 @@ class Chef
# Sets the default action
def self.default_action(action_name=NULL_ARG)
unless action_name.equal?(NULL_ARG)
+ @actions ||= []
if action_name.is_a?(Array)
action = action_name.map { |arg| arg.to_sym }
- actions.push(*action)
+ @actions = actions | action
@default_action = action
else
action = action_name.to_sym
- actions.push(action)
+ @actions.push(action) unless @actions.include?(action)
@default_action = action
end
end