module-common/lib/puppet/parser/functions/uniq_flatten.rb

11 lines
326 B
Ruby
Raw Normal View History

2010-10-21 00:40:23 +02:00
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
2010-10-21 00:40:23 +02:00
end