Class: Puppet::Parser::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/macros.rb

Overview

Monkey patches to Scope, so we have convenient access to some methods from macros.

Instance Method Summary collapse

Instance Method Details

#call_macro(name, args = [], options = {}, env = Puppet::Macros.default_environment) ⇒ Object

Call macro registered with Macros.newmacro

Parameters:

  • name (String)

    macro name, e.g. 'foo::bar',

  • args (Array) (defaults to: [])

    arguments to be provided to the macro,

  • options (Hash) (defaults to: {})

    additional options, see Macros.call_macro

  • env (Puppet::Node::Environment) (defaults to: Puppet::Macros.default_environment)

    puppet environment,

Returns:

  • the result of macro evaluation


14
15
16
17
18
19
# File 'lib/puppet/macros.rb', line 14

def call_macro(name, args = [], options = {}, env = Puppet::Macros.default_environment)
  # FIXME: I believe I should use environment that is bound to scope, not the
  # Macros.default_environment, but at the moment I have no idea where to
  # find it
  Puppet::Macros.call_macro(self,name,args,options,env)
end

#fr2r(v) ⇒ Object

Convert value from facter to ruby.

This converts empty strings and :undefined symbol to nil.

Parameters:

  • v (String|Symbol)

    value to be converted

Returns:

  • converted value


37
38
39
# File 'lib/puppet/macros.rb', line 37

def fr2r(v)
  (v.equal?(:undefined) or v == '') ? nil : v
end

#pp2r(v) ⇒ Object

Convert puppet value to ruby.

This converts empty strings and :undefs to nil.

Parameters:

  • v (String|Symbol)

    value to be converted

Returns:

  • converted value


27
28
29
# File 'lib/puppet/macros.rb', line 27

def pp2r(v)
  (v.equal?(:undef) or v == '') ? nil : v
end