Method: Puppet::Parser::Functions.function

Defined in:
lib/puppet/parser/functions.rb

.function(name, environment = Puppet.lookup(:current_environment)) ⇒ Symbol, false

Determine if a function is defined

Parameters:

  • name (Symbol)

    the function

  • environment (Puppet::Node::Environment) (defaults to: Puppet.lookup(:current_environment))

    the environment to find the function in

Returns:

  • (Symbol, false)

    The name of the function if it’s defined, otherwise false.



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/puppet/parser/functions.rb', line 244

def self.function(name, environment = Puppet.lookup(:current_environment))
  name = name.intern

  func = get_function(name, environment)
  unless func
    autoloader.delegatee.load(name, environment)
    func = get_function(name, environment)
  end

  if func
    func[:name]
  else
    false
  end
end