diff options
author | mh <mh@immerda.ch> | 2010-10-21 00:40:23 +0200 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2010-11-07 13:37:24 -0500 |
commit | 82eed89bccfe1af07caf925ce91e43b878bfda41 (patch) | |
tree | 46d943e34e9fce3583f1802792e63817d5eaf8bf | |
parent | 2dd17923bf6787029aee00d0b0e1e8dfbb0a5e7f (diff) | |
download | puppet-common-82eed89bccfe1af07caf925ce91e43b878bfda41.tar.gz puppet-common-82eed89bccfe1af07caf925ce91e43b878bfda41.tar.bz2 |
add a function to do some array work
-rw-r--r-- | lib/puppet/parser/functions/uniq_flatten.rb | 10 |
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 |