Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / is_function_available.rb
1 #
2 # is_function_available.rb
3 #
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.
9     DOC
10              ) do |arguments|
11
12     if arguments.size != 1
13       raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments given #{arguments.size} for 1")
14     end
15
16     # Only allow String types
17     return false unless arguments[0].is_a?(String)
18
19     function = Puppet::Parser::Functions.function(arguments[0].to_sym)
20     function.is_a?(String) && !function.empty?
21   end
22 end
23
24 # vim: set ts=2 sw=2 et :