diff options
author | Micah Anderson <micah@riseup.net> | 2013-05-26 16:19:56 -0400 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2013-05-26 16:19:56 -0400 |
commit | 966f3b349a60b3997e58af1095bbd96671952fac (patch) | |
tree | 3c1dcdb0cd353427eb066f6926610445700a2a66 /lib/puppet/parser/functions/is_function_available.rb | |
parent | 66e0fa8f1bc5062e9d753598ad17602c378a2994 (diff) | |
parent | 9c8c8275abd76878d38a0f6f3af52dc468656283 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'lib/puppet/parser/functions/is_function_available.rb')
-rw-r--r-- | lib/puppet/parser/functions/is_function_available.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/is_function_available.rb b/lib/puppet/parser/functions/is_function_available.rb new file mode 100644 index 0000000..6cbd35c --- /dev/null +++ b/lib/puppet/parser/functions/is_function_available.rb @@ -0,0 +1,23 @@ +# +# is_function_available.rb +# + +module Puppet::Parser::Functions + newfunction(:is_function_available, :type => :rvalue, :doc => <<-EOS +This function accepts a string as an argument, determines whether the +Puppet runtime has access to a function by that name. It returns a +true if the function exists, false if not. + EOS + ) do |arguments| + + if (arguments.size != 1) then + raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments "+ + "given #{arguments.size} for 1") + end + + function = Puppet::Parser::Functions.function(arguments[0].to_sym) + function.is_a?(String) and not function.empty? + end +end + +# vim: set ts=2 sw=2 et : |