X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstaging%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fscope_defaults.rb;fp=3rdparty%2Fmodules%2Fstaging%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fscope_defaults.rb;h=6c814849a0dcfdb87dacd80eb2aa8e42d24f7fd3;hb=269aa0e4ab1d106f521995e9e4beb8335acdbed6;hp=0000000000000000000000000000000000000000;hpb=d44d714d51cff79f225cae6a6d8f98f97d3000a5;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/staging/lib/puppet/parser/functions/scope_defaults.rb b/3rdparty/modules/staging/lib/puppet/parser/functions/scope_defaults.rb new file mode 100644 index 000000000..6c814849a --- /dev/null +++ b/3rdparty/modules/staging/lib/puppet/parser/functions/scope_defaults.rb @@ -0,0 +1,17 @@ +module Puppet::Parser::Functions + newfunction(:scope_defaults, :type => :rvalue, :doc => <<-EOS +Determine if specified resource defaults have a attribute defined in +current scope. +EOS + ) do |arguments| + + raise(Puppet::ParseError, "scope_defaults(): Wrong number of arguments " + + "given (#{arguments.size} for 2)") if arguments.size != 2 + + # auto capitalize puppet resource for lookup: + res_type = arguments[0].split('::').collect{ |x| x.capitalize }.join('::') + res_attr = arguments[1] + + return self.lookupdefaults(res_type).has_key?(res_attr.to_sym) + end +end