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