add a get_default function
This commit is contained in:
parent
16951d51b1
commit
e9d8147584
1 changed files with 15 additions and 0 deletions
15
lib/puppet/parser/functions/get_default.rb
Normal file
15
lib/puppet/parser/functions/get_default.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue