From c8d7fb66b7a2cf3b1312b9aae807979c597586f2 Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Fri, 7 Mar 2014 14:54:23 +0200 Subject: [PATCH] util: Added to_array() function. --- util/lib/puppet/parser/functions/to_array.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 util/lib/puppet/parser/functions/to_array.rb diff --git a/util/lib/puppet/parser/functions/to_array.rb b/util/lib/puppet/parser/functions/to_array.rb new file mode 100644 index 0000000..6b10b25 --- /dev/null +++ b/util/lib/puppet/parser/functions/to_array.rb @@ -0,0 +1,13 @@ +module Puppet::Parser::Functions + newfunction(:to_array, :type => :rvalue) do |args| + if args.length != 1 + raise Puppet::ParseError, ("to_array(): wrong number of arguments (#{args.length}; must be 1)") + end + if args[0].is_a?(Array) then + args[0] + else + [ args[0] ] + end + end +end +