From af1ba5ce8a75cadf1de512ad01e6ccde0b20fd28 Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Fri, 29 Apr 2011 18:27:52 +0100 Subject: Adding support for strings and hashes to the function empty. Signed-off-by: Krzysztof Wilczynski --- empty.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/empty.rb b/empty.rb index 2e75c61..1db9b63 100644 --- a/empty.rb +++ b/empty.rb @@ -12,13 +12,15 @@ module Puppet::Parser::Functions raise(Puppet::ParseError, "empty(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if arguments.size < 1 - array = arguments[0] + value = arguments[0] + klass = value.class - if not array.is_a?(Array) - raise(Puppet::ParseError, 'empty(): Requires an array to work with') + if not [Array, Hash, String].include?(klass) + raise(Puppet::ParseError, 'empty(): Requires either an ' + + 'array, hash or string to work with') end - result = array.empty? + result = value.empty? return result end -- cgit v1.2.3