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%2Fany2array.rb;h=b45e5b50bf341bd9ad79bfe655acc5497fdb6493;hp=8358a6f6448e740e17fcb238fd9ebc3e1b29e404;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2array.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2array.rb index 8358a6f64..b45e5b50b 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2array.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2array.rb @@ -3,26 +3,35 @@ # module Puppet::Parser::Functions newfunction(:any2array, :type => :rvalue, :doc => <<-DOC - This converts any object to an array containing that object. Empty argument - lists are converted to an empty array. Arrays are left untouched. Hashes are - converted to arrays of alternating keys and values. + @summary + This converts any object to an array containing that object. - Note that since Puppet 5.0.0 it is possible to create new data types for almost any - datatype using the type system and the built-in - [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple) - function is used to create a new Array.. + Empty argument lists are converted to an empty array. Arrays are left + untouched. Hashes are converted to arrays of alternating keys and values. - $hsh = {'key' => 42, 'another-key' => 100} - notice(Array($hsh)) + > *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple) + function is used to create a new Array.. + + ``` + $hsh = {'key' => 42, 'another-key' => 100} + notice(Array($hsh)) + ``` Would notice `[['key', 42], ['another-key', 100]]` The Array data type also has a special mode to "create an array if not already an array" - notice(Array({'key' => 42, 'another-key' => 100}, true)) + ``` + notice(Array({'key' => 42, 'another-key' => 100}, true)) + ``` Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being transformed into an array. + + @return [Array] The new array containing the given object DOC ) do |arguments|