4 module Puppet::Parser::Functions
11 **DEPRECATED**: Looks up into a complex structure of arrays and hashes and returns a value
12 or the default value if nothing was found.
14 Key can contain slashes to describe path components. The function will go down
15 the structure and try to extract the required value.
28 $value = dig44($data, ['a', 'b', 2])
31 # with all possible options
32 $value = dig44($data, ['a', 'b', 2], 'not_found')
35 # using the default value
36 $value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found')
37 # $value = 'not_found'
40 > **Note:* **Deprecated** This function has been replaced with a built-in
41 [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of
44 @return [String] 'not_found' will be returned if nothing is found
45 @return [Any] the value that was searched for
48 # Two arguments are required
49 raise(Puppet::ParseError, "dig44(): Wrong number of arguments given (#{arguments.size} for at least 2)") if arguments.size < 2
51 data, path, default = *arguments
53 raise(Puppet::ParseError, "dig44(): first argument must be a hash or an array, given #{data.class.name}") unless data.is_a?(Hash) || data.is_a?(Array)
54 raise(Puppet::ParseError, "dig44(): second argument must be an array, given #{path.class.name}") unless path.is_a? Array
56 value = path.reduce(data) do |structure, key|
57 break unless structure.is_a?(Hash) || structure.is_a?(Array)
58 if structure.is_a? Array
65 break if structure[key].nil? || structure[key] == :undef
68 value.nil? ? default : value