Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / functions / validate_legacy.rb
index c9d1f56..1e16219 100644 (file)
@@ -1,6 +1,16 @@
+# @summary
+#   Validate a value against both the target_type (new) and the previous_validation function (old).
 Puppet::Functions.create_function(:validate_legacy) do
   # The function checks a value against both the target_type (new) and the previous_validation function (old).
-
+  # @param scope
+  #   The main value that will be passed to the method
+  # @param target_type
+  # @param function_name
+  # @param value
+  # @param args
+  #   Any additional values that are to be passed to the method
+  # @return
+  #   A boolean value (`true` or `false`) returned from the called function.
   dispatch :validate_legacy do
     param 'Any', :scope
     param 'Type', :target_type
@@ -9,6 +19,14 @@ Puppet::Functions.create_function(:validate_legacy) do
     repeated_param 'Any', :args
   end
 
+  # @param scope
+  #   The main value that will be passed to the method
+  # @param type_string
+  # @param function_name
+  # @param value
+  # @param args Any additional values that are to be passed to the method
+  # @return Legacy validation method
+  #
   dispatch :validate_legacy_s do
     param 'Any', :scope
     param 'String', :type_string
@@ -17,7 +35,8 @@ Puppet::Functions.create_function(:validate_legacy) do
     repeated_param 'Any', :args
   end
 
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-
+  #   c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
@@ -48,12 +67,11 @@ Puppet::Functions.create_function(:validate_legacy) do
 
   def previous_validation(scope, function_name, value, *prev_args)
     # Call the previous validation function and catch any errors. Return true if no errors are thrown.
-    begin
-      scope.send("function_#{function_name}".to_s, [value, *prev_args])
-      true
-    rescue Puppet::ParseError
-      false
-    end
+
+    scope.send("function_#{function_name}".to_s, [value, *prev_args])
+    true
+  rescue Puppet::ParseError
+    false
   end
 
   def assert_type(type, value)