summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/size.rb
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
committervarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
commit066c08f8362d53f0f30897cb8710d11260c726ea (patch)
treea6369eecd88bb731fe413d0bbc8af73d74d1f447 /lib/puppet/parser/functions/size.rb
parent71123634744b9fe2ec7d6a3e38e9789fd84801e3 (diff)
parentb65dd1f45d10e10e45455358aeabb29167990e2c (diff)
Merge remote-tracking branch 'origin/master' into leap_master
Diffstat (limited to 'lib/puppet/parser/functions/size.rb')
-rw-r--r--lib/puppet/parser/functions/size.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/puppet/parser/functions/size.rb b/lib/puppet/parser/functions/size.rb
index cc207e3..0d6cc96 100644
--- a/lib/puppet/parser/functions/size.rb
+++ b/lib/puppet/parser/functions/size.rb
@@ -2,11 +2,9 @@
# size.rb
#
-# TODO(Krzysztof Wilczynski): Support for hashes would be nice too ...
-
module Puppet::Parser::Functions
newfunction(:size, :type => :rvalue, :doc => <<-EOS
-Returns the number of elements in a string or array.
+Returns the number of elements in a string, an array or a hash
EOS
) do |arguments|
@@ -29,13 +27,13 @@ Returns the number of elements in a string or array.
Float(item)
raise(Puppet::ParseError, 'size(): Requires either ' +
- 'string or array to work with')
+ 'string, array or hash to work with')
rescue ArgumentError
result = item.size
end
- elsif item.is_a?(Array)
+ elsif item.is_a?(Array) || item.is_a?(Hash)
result = item.size
else
raise(Puppet::ParseError, 'size(): Unknown type given')