Update stdlib and concat to 6.1.0 both
[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     @summary
7       **Deprecated:** Determines whether the Puppet runtime has access to a function by that name.
8
9     This function accepts a string as an argument.
10
11     @return [Boolean]
12       Returns `true` or `false`
13
14     > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
15     [`validate_legacy`](#validate_legacy).
16     DOC
17              ) do |arguments|
18
19     if arguments.size != 1
20       raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments given #{arguments.size} for 1")
21     end
22
23     # Only allow String types
24     return false unless arguments[0].is_a?(String)
25
26     function = Puppet::Parser::Functions.function(arguments[0].to_sym)
27     function.is_a?(String) && !function.empty?
28   end
29 end
30
31 # vim: set ts=2 sw=2 et :