mirror of
https://github.com/krislamo/puppet-rsnapshot
synced 2024-11-10 00:00:35 +00:00
19 lines
540 B
Ruby
19 lines
540 B
Ruby
module Puppet::Parser::Functions
|
|
newfunction(:assert_empty_hash, :type => :rvalue, :doc => <<-EOS
|
|
This function checks an input struct for undefined hashes in key => hash and assigns {}. This is only a helper function to make a hash.each work if one of the values is undefined
|
|
EOS
|
|
)do |args|
|
|
fail "Must receive one argument." if args.empty?
|
|
args.each do |arg|
|
|
h = Hash.new
|
|
arg.each_pair do |host, hash|
|
|
unless hash.is_a? Hash
|
|
hash = {}
|
|
end
|
|
h[host] = hash
|
|
end
|
|
return h
|
|
end
|
|
end
|
|
end
|