Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / union.rb
1 #
2 # union.rb
3 #
4 module Puppet::Parser::Functions
5   newfunction(:union, :type => :rvalue, :doc => <<-DOC
6     @summary
7       This function returns a union of two or more arrays.
8
9     @return
10       a unionized array of two or more arrays
11     @example **Usage**
12
13       union(["a","b","c"],["b","c","d"])
14       Would return: ["a","b","c","d"]
15     DOC
16              ) do |arguments|
17
18     # Check that 2 or more arguments have been given ...
19     raise(Puppet::ParseError, "union(): Wrong number of arguments given (#{arguments.size} for < 2)") if arguments.size < 2
20
21     arguments.each do |argument|
22       raise(Puppet::ParseError, 'union(): Every parameter must be an array') unless argument.is_a?(Array)
23     end
24
25     arguments.reduce(:|)
26   end
27 end
28
29 # vim: set ts=2 sw=2 et :