aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/functions/uniq_flatten.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/uniq_flatten.rb b/lib/puppet/parser/functions/uniq_flatten.rb
new file mode 100644
index 0000000..a4cae40
--- /dev/null
+++ b/lib/puppet/parser/functions/uniq_flatten.rb
@@ -0,0 +1,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.uniq
+end