Class: Chef::GuardInterpreter::ResourceGuardInterpreter
- Inherits:
-
DefaultGuardInterpreter
- Object
- DefaultGuardInterpreter
- Chef::GuardInterpreter::ResourceGuardInterpreter
- Defined in:
- lib/chef/guard_interpreter/resource_guard_interpreter.rb
Constant Summary
Constants included from Mixin::ShellOut
Mixin::ShellOut::DEPRECATED_OPTIONS
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(parent_resource, command, opts, &block) ⇒ ResourceGuardInterpreter
constructor
A new instance of ResourceGuardInterpreter.
Methods included from Mixin::ShellOut
#run_command_compatible_options, #shell_out, #shell_out!
Constructor Details
#initialize(parent_resource, command, opts, &block) ⇒ ResourceGuardInterpreter
Returns a new instance of ResourceGuardInterpreter.
25 26 27 28 29 |
# File 'lib/chef/guard_interpreter/resource_guard_interpreter.rb', line 25 def initialize(parent_resource, command, opts, &block) super(command, opts) @parent_resource = parent_resource @resource = get_interpreter_resource(parent_resource) end |
Instance Method Details
#evaluate ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/chef/guard_interpreter/resource_guard_interpreter.rb', line 31 def evaluate # Add attributes inherited from the parent class # to the resource merge_inherited_attributes # Script resources have a code attribute, which is # what is used to execute the command, so include # that with attributes specified by caller in opts block_attributes = @command_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, @command_opts).merge(block_attributes) end resource_block = block_from_attributes(block_attributes) evaluate_action(nil, &resource_block) end |