module Garcon::Interpolation

Public Instance Methods

interpolate(item = self, parent = nil) click to toggle source

Interpolate provides a means of externally using Ruby string interpolation mechinism.

@example

node[:ldap][:basedir] = '/opt'
node[:ldap][:homedir] = '%{basedir}/openldap/slap/happy'

interpolate(node[:ldap])[:homedir]  # => "/opt/openldap/slap/happy"

@param [String] item

The string to interpolate.

@param [String, Hash] parent

The string used for substitution.

@return [String]

The interpolated string.

@api public

# File lib/garcon/utility/interpolation.rb, line 44
def interpolate(item = self, parent = nil)
  item = render item, parent
  item.is_a?(Hash) ? ::Mash.new(item) : item
end