2 # is_function_available.rb
4 module Puppet::Parser::Functions
5 newfunction(:is_function_available, :type => :rvalue, :doc => <<-DOC
6 This function accepts a string as an argument, determines whether the
7 Puppet runtime has access to a function by that name. It returns a
8 true if the function exists, false if not.
12 if arguments.size != 1
13 raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments given #{arguments.size} for 1")
16 # Only allow String types
17 return false unless arguments[0].is_a?(String)
19 function = Puppet::Parser::Functions.function(arguments[0].to_sym)
20 function.is_a?(String) && !function.empty?
24 # vim: set ts=2 sw=2 et :