]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Check for the number of arguments given.
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Sat, 12 Mar 2011 23:05:56 +0000 (23:05 +0000)
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Sat, 12 Mar 2011 23:05:56 +0000 (23:05 +0000)
load_vars.rb

index 87effad9ed57c21fc6a027d79b6612da33b7eea3..02e99a01e81492040eb394cb5a6ada1dbe057570 100644 (file)
 #
 
 module Puppet::Parser::Functions
-  newfunction(:load_vars, :type => :statement) do |args|
+  newfunction(:load_vars, :type => :statement) do |arguments|
+
+    number_of_arguments = arguments.size
+
+    if number_of_arguments < 2
+      raise(Puppet::ParseError, "Wrong number of arguments " +
+        "given (#{number_of_arguments} for 2)")
+    end
+
     data = {}
 
-    file = args[0]
-    key  = args[1] if args[1]
+    file = arguments[0]
+    key  = arguments[1] if arguments[1]
 
     if File.exists?(file)