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%2Fmember.rb;h=7efcb1f63ede779674f3509219840481af73cde9;hp=8154f3b03df6dc4f5d0ea83a05ab700d417e4906;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/member.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/member.rb index 8154f3b03..7efcb1f63 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/member.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/member.rb @@ -5,39 +5,34 @@ # module Puppet::Parser::Functions newfunction(:member, :type => :rvalue, :doc => <<-DOC - This function determines if a variable is a member of an array. - The variable can be a string, fixnum, or array. - - *Examples:* - - member(['a','b'], 'b') - - Would return: true - - member(['a', 'b', 'c'], ['a', 'b']) - - would return: true - - member(['a','b'], 'c') + @summary + This function determines if a variable is a member of an array. - Would return: false - - member(['a', 'b', 'c'], ['d', 'b']) - - would return: false - - Note: Since Puppet 4.0.0 the same can be performed in the Puppet language. For single values - the operator `in` can be used: - - 'a' in ['a', 'b'] # true - - And for arrays by using operator `-` to compute a diff: - - ['d', 'b'] - ['a', 'b', 'c'] == [] # false because 'd' is not subtracted - ['a', 'b'] - ['a', 'b', 'c'] == [] # true because both 'a' and 'b' are subtracted + The variable can be a string, fixnum, or array. - Also note that since Puppet 5.2.0 the general form of testing content of an array or hash is to use the built-in - `any` and `all` functions. + > **Note**: This function does not support nested arrays. If the first argument contains + nested arrays, it will not recurse through them. + + @example **Usage** + member(['a','b'], 'b') # Returns: true + member(['a', 'b', 'c'], ['a', 'b']) # Returns: true + member(['a','b'], 'c') # Returns: false + member(['a', 'b', 'c'], ['d', 'b']) # Returns: false + + > *Note:* + Since Puppet 4.0.0 the same can be performed in the Puppet language. + For single values the operator `in` can be used: + `'a' in ['a', 'b'] # true` + For arrays by using operator `-` to compute a diff: + `['d', 'b'] - ['a', 'b', 'c'] == [] # false because 'd' is not subtracted` + `['a', 'b'] - ['a', 'b', 'c'] == [] # true because both 'a' and 'b' are subtracted` + + @return + Returns whether the given value was a member of the array + + > **Note** that since Puppet 5.2.0, the general form to test the content of an array or + hash is to use the built-in [`any`](https://puppet.com/docs/puppet/latest/function.html#any) + and [`all`](https://puppet.com/docs/puppet/latest/function.html#all) functions. DOC ) do |arguments|