From 90453d177f99b6fee811bf36e77b03c66bf80d5e Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Thu, 23 May 2013 15:04:45 +0000 Subject: mga-common: add hash_keys function This function takes a hash as argument and return the hash keys as a list. --- modules/mga-common/lib/puppet/parser/functions/hash_keys.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 modules/mga-common/lib/puppet/parser/functions/hash_keys.rb (limited to 'modules/mga-common/lib') diff --git a/modules/mga-common/lib/puppet/parser/functions/hash_keys.rb b/modules/mga-common/lib/puppet/parser/functions/hash_keys.rb new file mode 100644 index 00000000..3a926bee --- /dev/null +++ b/modules/mga-common/lib/puppet/parser/functions/hash_keys.rb @@ -0,0 +1,10 @@ +module Puppet::Parser::Functions + newfunction(:hash_keys, :type => :rvalue) do |args| + unless args[0].is_a?(Hash) + Puppet.warning "hash_keys takes one argument, the input hash" + nil + else + args[0].keys + end + end +end -- cgit v1.2.1