diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-10-14 14:42:25 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-10-16 13:30:24 -0700 |
commit | 8be4d2a44858b14d10d0a19484a2d090b0a7a2fb (patch) | |
tree | fa713587092354c19facbc1423ffab4c6bc2cc8e /lib/chef/resource.rb | |
parent | 8dd586b1fdbb13705a1a3a5f7f792568cc39e434 (diff) | |
download | chef-8be4d2a44858b14d10d0a19484a2d090b0a7a2fb.tar.gz |
Differentiate between the default and the user set guard_attributes in order to be able to warn users correctly when they configure a guard_attribute but use a ruby block in the guard.
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r-- | lib/chef/resource.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 70abfbcdb0..55de8f059c 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -229,6 +229,8 @@ F attr_reader :elapsed_time + attr_reader :default_guard_interpreter + # Each notify entry is a resource/action pair, modeled as an # Struct with a #resource and #action member @@ -250,7 +252,13 @@ F @not_if = [] @only_if = [] @source_line = nil - @guard_interpreter = :default + # We would like to raise an error when the user gives us a guard + # interpreter and a ruby_block to the guard. In order to achieve this + # we need to understand when the user overrides the default guard + # interpreter. Therefore we store the default separately in a different + # attribute. + @guard_interpreter = nil + @default_guard_interpreter = :default @elapsed_time = 0 @sensitive = false end @@ -410,11 +418,15 @@ F end def guard_interpreter(arg=nil) - set_or_return( - :guard_interpreter, - arg, - :kind_of => Symbol - ) + if arg.nil? + @guard_interpreter || @default_guard_interpreter + else + set_or_return( + :guard_interpreter, + arg, + :kind_of => Symbol + ) + end end # Sets up a notification from this resource to the resource specified by +resource_spec+. |