Class: Bolt::PAL::YamlPlan::BareString

Inherits:
EvaluableString show all
Defined in:
lib/bolt/pal/yaml_plan.rb

Overview

This class stores a bare YAML string, which is fuzzily interpreted as either Puppet code or a literal string, depending on whether it starts with a variable reference.

Instance Attribute Summary

Attributes inherited from EvaluableString

#file, #line, #value

Instance Method Summary collapse

Methods inherited from EvaluableString

#==, #initialize

Constructor Details

This class inherits a constructor from Bolt::PAL::YamlPlan::EvaluableString

Instance Method Details

#evaluate(scope, evaluator) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/bolt/pal/yaml_plan.rb', line 157

def evaluate(scope, evaluator)
  if @value.start_with?('$')
    # Try to parse the string as Puppet code. If it's invalid code,
    # return the original string.
    parse_result = evaluator.parse_string(@value)
    scope.with_local_scope({}) do
      evaluator.evaluate(scope, parse_result)
    end
  else
    @value
  end
end