summaryrefslogtreecommitdiff
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorAdrien Thebo <git@somethingsinistral.net>2013-03-18 15:46:41 -0700
committerAdrien Thebo <git@somethingsinistral.net>2013-03-18 15:46:41 -0700
commitfc2352f346b7b7acfc1a51afe4d17310cdcc4213 (patch)
tree9e5d6633b54a1b23d4b83fa78a77e7cfaa5d253f /lib/puppet/parser
parent6dfd7f6b73c4f9437058609f43d0065d52e36494 (diff)
parent961dcab15d3cf00eabeb5a496efc9da051169241 (diff)
downloadpuppet-stdlib-fc2352f346b7b7acfc1a51afe4d17310cdcc4213.tar.gz
puppet-stdlib-fc2352f346b7b7acfc1a51afe4d17310cdcc4213.tar.bz2
Merge branch 'pull-59'
This closes GH-59
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/functions/is_function_available.rb23
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 :