Puppet Function: keys
- Defined in:
- lib/puppet/parser/functions/keys.rb
- Function type:
- Ruby 3.x API
Overview
Returns the keys of a hash as an array.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/puppet/parser/functions/keys.rb', line 5 newfunction(:keys, :type => :rvalue, :doc => <<-DOC Returns the keys of a hash as an array. DOC ) do |arguments| raise(Puppet::ParseError, "keys(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? hash = arguments[0] unless hash.is_a?(Hash) raise(Puppet::ParseError, 'keys(): Requires hash to work with') end result = hash.keys return result end |