diff options
author | John Keiser <john@johnkeiser.com> | 2016-09-16 15:56:55 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-09-16 18:14:07 -0700 |
commit | 9a79d4edac7be3140cab0cd7fb773c77110834cc (patch) | |
tree | 3418ff4bdb236646052278f238f5f0ec5a30220d | |
parent | 9ff31d777d7d80029118e04da743dfed505365b8 (diff) | |
download | chef-9a79d4edac7be3140cab0cd7fb773c77110834cc.tar.gz |
Change `Resource.action` into a property
-rw-r--r-- | lib/chef/resource.rb | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index d11fa1c80c..26d303cd2c 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -162,23 +162,11 @@ class Chef # @param arg [Array[Symbol], Symbol] A list of actions (e.g. `:create`) # @return [Array[Symbol]] the list of actions. # - 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 + property :action, Array, coerce: proc { |v| Array(v).map(&:to_sym) }, callbacks: { + "must be one of the allowed actions" => proc do |actions| + actions.all? { |action| allowed_actions.include?(action) } end - end - - # Alias for normal assigment syntax. - alias_method :action=, :action + }, desired_state: false # # Sets up a notification that will run a particular action on another resource |