Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / values.rb
1 #
2 # values.rb
3 #
4 module Puppet::Parser::Functions
5   newfunction(:values, :type => :rvalue, :doc => <<-DOC
6     @summary
7       When given a hash this function will return the values of that hash.
8
9     @return
10       array of values
11
12     @example **Usage**
13       $hash = {
14         'a' => 1,
15         'b' => 2,
16         'c' => 3,
17       }
18       values($hash)
19
20       This example would return: ```[1,2,3]```
21
22     > *Note:*
23     From Puppet 5.5.0, the compatible function with the same name in Puppet core
24     will be used instead of this function.
25
26   DOC
27              ) do |arguments|
28
29     raise(Puppet::ParseError, "values(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
30
31     hash = arguments[0]
32
33     unless hash.is_a?(Hash)
34       raise(Puppet::ParseError, 'values(): Requires hash to work with')
35     end
36
37     result = hash.values
38
39     return result
40   end
41 end
42
43 # vim: set ts=2 sw=2 et :