summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2010-10-21 00:40:23 +0200
committerMicah Anderson <micah@riseup.net>2010-11-07 13:37:24 -0500
commit82eed89bccfe1af07caf925ce91e43b878bfda41 (patch)
tree46d943e34e9fce3583f1802792e63817d5eaf8bf /lib
parent2dd17923bf6787029aee00d0b0e1e8dfbb0a5e7f (diff)
add a function to do some array work
Diffstat (limited to 'lib')
-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