Now prefix will convert everything into string which is the same
as join would do. Also function is now more robust in error detection. Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
This commit is contained in:
parent
5fce8a7f54
commit
b26d5b2f3b
1 changed files with 11 additions and 2 deletions
13
prefix.rb
13
prefix.rb
|
@ -19,11 +19,20 @@ module Puppet::Parser::Functions
|
|||
|
||||
prefix = arguments[1] if arguments[1]
|
||||
|
||||
result = array.collect { |i| prefix ? prefix + i : i }
|
||||
if prefix
|
||||
unless prefix.is_a?(String)
|
||||
raise(Puppet::ParseError, 'prefix(): Requires string to work with')
|
||||
end
|
||||
end
|
||||
|
||||
# Turn everything into string same as join would do ...
|
||||
result = array.collect do |i|
|
||||
i = i.to_s
|
||||
prefix ? prefix + i : i
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
||||
|
||||
|
|
Loading…
Reference in a new issue