From 35bf5fd8c93d5052ecf5284ed3194a92cab838d5 Mon Sep 17 00:00:00 2001 From: Martin Foot Date: Fri, 21 Feb 2014 14:32:32 +0000 Subject: Allow concat to take non-array second parameters Also improve and extend concat tests to lock down functionality --- lib/puppet/parser/functions/concat.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/puppet/parser/functions/concat.rb') diff --git a/lib/puppet/parser/functions/concat.rb b/lib/puppet/parser/functions/concat.rb index c86aa00..6c86382 100644 --- a/lib/puppet/parser/functions/concat.rb +++ b/lib/puppet/parser/functions/concat.rb @@ -23,12 +23,16 @@ Would result in: a = arguments[0] b = arguments[1] - # Check that both args are arrays. - unless a.is_a?(Array) and b.is_a?(Array) + # Check that the first parameter is an array + unless a.is_a?(Array) raise(Puppet::ParseError, 'concat(): Requires array to work with') end - result = a.concat(b) + if b.is_a?(Array) + result = a.concat(b) + else + result = a << b + end return result end -- cgit v1.2.3