X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Ffunctions%2Flength.rb;fp=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Ffunctions%2Flength.rb;h=ccd662a16b2a69ca703659184bdddd386dc14ca2;hb=131e09855e065be940e104d9ab0f18940cc76257;hp=86e735cb41aac918f021ea41e879d413160c40ed;hpb=407d322498f4fde815abf381007fbecfe5c10b2b;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/length.rb b/3rdparty/modules/stdlib/lib/puppet/functions/length.rb index 86e735cb4..ccd662a16 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/length.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/length.rb @@ -1,14 +1,19 @@ -#A function to eventually replace the old size() function for stdlib - The original size function did not handle Puppets new type capabilities, so this function is a Puppet 4 compatible solution. +# A function to eventually replace the old size() function for stdlib +# The original size function did not handle Puppets new type capabilities, so this function is a Puppet 4 compatible solution. +# +# Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core +# will be used instead of this function. +# Puppet::Functions.create_function(:length) do dispatch :length do param 'Variant[String,Array,Hash]', :value end - def length(value) + def length(value) if value.is_a?(String) result = value.length elsif value.is_a?(Array) || value.is_a?(Hash) result = value.size end - return result + result end end