summaryrefslogtreecommitdiff
path: root/lib/puppet/parser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/functions/delete_undef_values.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/puppet/parser/functions/delete_undef_values.rb b/lib/puppet/parser/functions/delete_undef_values.rb
index 4eecab2..532639e 100644
--- a/lib/puppet/parser/functions/delete_undef_values.rb
+++ b/lib/puppet/parser/functions/delete_undef_values.rb
@@ -18,16 +18,16 @@ Would return: ['A','',false]
raise(Puppet::ParseError,
"delete_undef_values(): Wrong number of arguments given " +
"(#{args.size})") if args.size < 1
-
- result = args[0]
+
+ unless args[0].is_a? Array or args[0].is_a? Hash
+ raise(Puppet::ParseError,
+ "delete_undef_values(): expected an array or hash, got #{args[0]} type #{args[0].class} ")
+ end
+ result = args[0].dup
if result.is_a?(Hash)
result.delete_if {|key, val| val.equal? :undef}
elsif result.is_a?(Array)
result.delete :undef
- else
- raise(Puppet::ParseError,
- "delete_undef_values(): Wrong argument type #{args[0].class} " +
- "for first argument")
end
result
end