add a function to do some array work
authormh <mh@immerda.ch>
Wed, 20 Oct 2010 22:40:23 +0000 (00:40 +0200)
committerMicah Anderson <micah@riseup.net>
Sun, 7 Nov 2010 18:37:24 +0000 (13:37 -0500)
lib/puppet/parser/functions/uniq_flatten.rb [new file with mode: 0644]

diff --git a/lib/puppet/parser/functions/uniq_flatten.rb b/lib/puppet/parser/functions/uniq_flatten.rb
new file mode 100644 (file)
index 0000000..a4cae40
--- /dev/null
@@ -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