Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / keys.rb
1 #
2 # keys.rb
3 #
4 module Puppet::Parser::Functions
5   newfunction(:keys, :type => :rvalue, :doc => <<-DOC
6     @summary
7       **Deprecated:** Returns the keys of a hash as an array.
8
9     @return [Array]
10       An array containing each of the hashes key values.
11
12     > **Note:** **Deprecated** from Puppet 5.5.0, the built-in [`keys`](https://puppet.com/docs/puppet/latest/function.html#keys)
13     function will be used instead of this function.
14     DOC
15              ) do |arguments|
16
17     raise(Puppet::ParseError, "keys(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
18
19     hash = arguments[0]
20
21     unless hash.is_a?(Hash)
22       raise(Puppet::ParseError, 'keys(): Requires hash to work with')
23     end
24
25     result = hash.keys
26
27     return result
28   end
29 end
30
31 # vim: set ts=2 sw=2 et :