aboutsummaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/uniq_flatten.rb
blob: 4841c4dde5658bcb95a5645d0d590b8d50c92aac (plain)
1
2
3
4
5
6
7
8
9
10
Puppet::Parser::Functions::newfunction(
  :uniq_flatten,
  :type => :rvalue,
  :doc => "Flattens an array and make it uniq

    Example: uniq_flatten([['a','b'],'a']) -> ['a','b']"
) do |args|
  raise Puppet::ParseError, 'uniq_flatten() needs one arguments' if args.length != 1
  args[0].to_a.flatten.collect(&:to_s).uniq
end