Skip to content

Commit 1f8d97f

Browse files
committed
Trying to deprecate length puppet4 function
1 parent fbe25ce commit 1f8d97f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/puppet/functions/length.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# 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.
22
Puppet::Functions.create_function(:length) do
3-
dispatch :length do
4-
param 'Variant[String,Array,Hash]', :value
3+
dispatch :deprecation_gen do
4+
scope_param
5+
optional_repeated_param 'Any', :args
56
end
67
def length(value)
78
if value.is_a?(String)
@@ -10,5 +11,8 @@ def length(value)
1011
result = value.size
1112
end
1213
result
14+
def deprecation_gen(scope, *args)
15+
call_function('deprecation', 'length', "This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes.")
16+
scope.send("function_length", args)
1317
end
1418
end

0 commit comments

Comments
 (0)