1
0
mirror of https://github.com/krislamo/puppet-rsnapshot synced 2024-11-10 08:10:34 +00:00
puppet-rsnapshot/lib/puppet/parser/functions/assert_empty_hash.rb

19 lines
540 B
Ruby
Raw Normal View History

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