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