diff options
author | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-29 18:27:52 +0100 |
---|---|---|
committer | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-29 18:27:52 +0100 |
commit | af1ba5ce8a75cadf1de512ad01e6ccde0b20fd28 (patch) | |
tree | 1ffee2a54a34087fc3007a9c625e0820ba2ac4c9 | |
parent | 456a351ac2d7904c2c3bf4d106c1de679456325c (diff) | |
download | puppet-stdlib-af1ba5ce8a75cadf1de512ad01e6ccde0b20fd28.tar.gz puppet-stdlib-af1ba5ce8a75cadf1de512ad01e6ccde0b20fd28.tar.bz2 |
Adding support for strings and hashes to the function empty.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
-rw-r--r-- | empty.rb | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 |