Puppet Function: stdlib::nested_values
- Defined in:
-
lib/puppet/functions/stdlib/nested_values.rb
- Function type:
- Ruby 4.x API
Summary
Get list of nested values from given hash
This function will return list of nested Hash values and returns list of values in form of Array
Overview
stdlib::nested_values(Hash $hash) ⇒ Array
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/puppet/functions/stdlib/nested_values.rb', line 14
Puppet::Functions.create_function(:'stdlib::nested_values') do
dispatch :nested_values do
param 'Hash', :hash
return_type 'Array'
end
def nested_values(hash)
hash.each_with_object([]) do |(_k, v), values|
v.is_a?(Hash) ? values.concat(nested_values(v)) : (values << v)
end
end
end
|