]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Adding support for strings and hashes to the function empty.
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Fri, 29 Apr 2011 17:27:52 +0000 (18:27 +0100)
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Fri, 29 Apr 2011 17:27:52 +0000 (18:27 +0100)
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
empty.rb

index 2e75c61a4b7d745fa53175b969fbe1625a84df35..1db9b632c5a8368c3a4939201ab062e9c128602a 100644 (file)
--- 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