5 module Puppet::Parser::Functions
6 newfunction(:hash, :type => :rvalue, :doc => <<-EOS
7 This function converts an array into a hash.
11 hash(['a',1,'b',2,'c',3])
13 Would return: {'a'=>1,'b'=>2,'c'=>3}
17 raise(Puppet::ParseError, "hash(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
21 unless array.is_a?(Array)
22 raise(Puppet::ParseError, 'hash(): Requires array to work with')
28 # This is to make it compatible with older version of Ruby ...
32 raise(Puppet::ParseError, 'hash(): Unable to compute hash from array given')
39 # vim: set ts=2 sw=2 et :