]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb
upgrade to stdlib 4.6.1
[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 "+
15         "given #{arguments.size} for 1")
16     end
17
18     # Only allow String types
19     return false unless arguments[0].is_a?(String)
20
21     function = Puppet::Parser::Functions.function(arguments[0].to_sym)
22     function.is_a?(String) and not function.empty?
23   end
24 end
25
26 # vim: set ts=2 sw=2 et :