X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fdig44.rb;h=ff1d9df6589ffea7814d69a7f9b0ae892136a556;hp=91724f43c06c3c9989280e5cf9ee12cdcd7e1436;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb index 91724f43c..ff1d9df65 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb @@ -7,14 +7,14 @@ module Puppet::Parser::Functions :type => :rvalue, :arity => -2, :doc => <<-DOC - DEPRECATED: This function has been replaced in Puppet 4.5.0. - - Looks up into a complex structure of arrays and hashes and returns a value - or the default value if nothing was found. + @summary + **DEPRECATED**: Looks up into a complex structure of arrays and hashes and returns a value + or the default value if nothing was found. Key can contain slashes to describe path components. The function will go down the structure and try to extract the required value. + ``` $data = { 'a' => { 'b' => [ @@ -25,19 +25,24 @@ module Puppet::Parser::Functions } } - $value = dig44($data, ['a', 'b', '2'], 'not_found') - => $value = 'b3' + $value = dig44($data, ['a', 'b', 2]) + # $value = 'b3' + + # with all possible options + $value = dig44($data, ['a', 'b', 2], 'not_found') + # $value = 'b3' - a -> first hash key - b -> second hash key - 2 -> array index starting with 0 + # using the default value + $value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found') + # $value = 'not_found' + ``` - not_found -> (optional) will be returned if there is no value or the path - did not match. Defaults to nil. + > **Note:* **Deprecated** This function has been replaced with a built-in + [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of + Puppet 4.5.0. - In addition to the required "key" argument, the function accepts a default - argument. It will be returned if no value was found or a path component is - missing. And the fourth argument can set a variable path separator. + @return [String] 'not_found' will be returned if nothing is found + @return [Any] the value that was searched for DOC ) do |arguments| # Two arguments are required