summaryrefslogtreecommitdiff
path: root/lib/chef/guard_interpreter
diff options
context:
space:
mode:
authorAdam Edwards <adamed@opscode.com>2014-03-29 00:20:08 -0700
committerAdam Edwards <adamed@opscode.com>2014-03-29 00:21:14 -0700
commit718de5b01c5458e512004bf072618052ffa654bc (patch)
treef6ebe786d641ad260c399cf776adec8ce6e218a0 /lib/chef/guard_interpreter
parentbada8aeb8cdac4779a0d65d4d3fd9333910fc886 (diff)
downloadchef-718de5b01c5458e512004bf072618052ffa654bc.tar.gz
CR feedback: clean up convert boolean expressions and add tests
Diffstat (limited to 'lib/chef/guard_interpreter')
-rw-r--r--lib/chef/guard_interpreter/resource_guard_interpreter.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
index 0a88d75d5c..c4b6d33a16 100644
--- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb
+++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
@@ -24,8 +24,19 @@ class Chef
def translate_command_block(command, opts, &block)
merge_inherited_attributes
+
if command && ! block_given?
block_attributes = opts.merge({:code => command})
+
+ # Handles cases like powershell_script where default
+ # attributes are different when used in a guard vs. not. For
+ # powershell_script in particular, this will go away when
+ # the one attribue that causes this changes its default to be
+ # the same after some period to prepare for deprecation
+ if @resource.class.respond_to?(:get_default_attributes)
+ block_attributes = @resource.class.send(:get_default_attributes, opts).merge(block_attributes)
+ end
+
translated_block = to_block(block_attributes)
[nil, translated_block]
else