add a get_default function
authoro <o@immerda.ch>
Thu, 9 Oct 2014 11:32:52 +0000 (13:32 +0200)
committero <o@immerda.ch>
Thu, 9 Oct 2014 11:33:11 +0000 (13:33 +0200)
lib/puppet/parser/functions/get_default.rb [new file with mode: 0644]

diff --git a/lib/puppet/parser/functions/get_default.rb b/lib/puppet/parser/functions/get_default.rb
new file mode 100644 (file)
index 0000000..3f4359b
--- /dev/null
@@ -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