Module: Puppet::Pops::Lookup::Interpolation

Includes:
SubLookup
Included in:
DataHashFunctionProvider, FunctionContext, LocationResolver
Defined in:
lib/puppet/pops/lookup/interpolation.rb

Constant Summary

Constants included from SubLookup

SubLookup::SPECIAL

Instance Method Summary collapse

Methods included from SubLookup

#split_key, #sub_lookup

Instance Method Details

#interpolate(value, context, allow_methods) ⇒ Object

Returns the result of resolving all interpolations in the given value.

Parameters:

  • value (Object)

    The value to interpolate

  • context (Context)

    The current lookup context

  • allow_methods (Boolean)

    ‘true` if interpolation expression that contains lookup methods are allowed

Returns:

  • (Object)

    the result of resolving all interpolations in the given value



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/puppet/pops/lookup/interpolation.rb', line 19

def interpolate(value, context, allow_methods)
  case value
  when String
    value.index('%{').nil? ? value : interpolate_string(value, context, allow_methods)
  when Array
    value.map { |element| interpolate(element, context, allow_methods) }
  when Hash
    result = {}
    value.each_pair { |k, v| result[interpolate(k, context, allow_methods)] = interpolate(v, context, allow_methods) }
    result
  else
    value
  end
end