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

#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



142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/bolt/pal/yaml_plan.rb', line 142

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