diff options
author | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-03-12 23:05:56 +0000 |
---|---|---|
committer | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-03-12 23:05:56 +0000 |
commit | 0eea8ac101fdd6dbbe67c2406c3e742ae81a1c4c (patch) | |
tree | e69c60bf300b8c5c07ecd122b6f377a232d0de9b | |
parent | 49d208a13edce166811a71b1ada1d201e756c06a (diff) | |
download | puppet-stdlib-0eea8ac101fdd6dbbe67c2406c3e742ae81a1c4c.tar.gz puppet-stdlib-0eea8ac101fdd6dbbe67c2406c3e742ae81a1c4c.tar.bz2 |
Check for the number of arguments given.
-rw-r--r-- | load_vars.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/load_vars.rb b/load_vars.rb index 87effad..02e99a0 100644 --- a/load_vars.rb +++ b/load_vars.rb @@ -40,11 +40,19 @@ # 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) |