aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoro <o@immerda.ch>2014-10-09 13:32:52 +0200
committero <o@immerda.ch>2014-10-09 13:33:11 +0200
commite9d8147584cf42dceec6d2cdd4314e8a85dc3aeb (patch)
treee7c2d4161b529967079d20ff4f81e5c118cf1a67
parent16951d51b112a0e035bd62a403d6a1838d3ff997 (diff)
downloadpuppet-common-e9d8147584cf42dceec6d2cdd4314e8a85dc3aeb.tar.gz
puppet-common-e9d8147584cf42dceec6d2cdd4314e8a85dc3aeb.tar.bz2
add a get_default function
-rw-r--r--lib/puppet/parser/functions/get_default.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/get_default.rb b/lib/puppet/parser/functions/get_default.rb
new file mode 100644
index 0000000..3f4359b
--- /dev/null
+++ b/lib/puppet/parser/functions/get_default.rb
@@ -0,0 +1,15 @@
+# get_default($value, $default) : $value
+#
+# return $value || $default.
+module Puppet::Parser::Functions
+ newfunction(:get_default, :type => :rvalue) do |args|
+ value = nil
+ args.each { |x|
+ if ! x.nil? and x.length > 0
+ value = x
+ break
+ end
+ }
+ return value
+ end
+end