puppetlabs/puppetlabs-stdlib — pull request #205 by indirect (2013-11-23 22:37:14+00:00)
Title: add hash_compact function

When wrapping a resource in a defined type, it is extremely useful
to be able to accept the same parameters as the wrapped class. If
the parameters are optional, it is necessary to remove the keys
with unset values from the hash, because explicit `undef` values
will overwrite defaults in the wrapped resource. For example,
here is a wrapper that overwrites default values:

define wrapper($name, $path = undef) {
wrapped { $name: path => $path }
}

And here is a wrapper that does not overwrite default values:

define wrapper($name, $path = undef) {
$compacted = hash_compact({path => $path})
wrapped { $name: $compacted }
}