| 1 |
module Puppet::Parser::Functions |
| 2 |
newfunction(:scope_defaults, :type => :rvalue, :doc => <<-EOS |
| 3 |
Determine if specified resource defaults have a attribute defined in |
| 4 |
current scope. |
| 5 |
EOS |
| 6 |
) do |arguments| |
| 7 |
|
| 8 |
raise(Puppet::ParseError, "scope_defaults(): Wrong number of arguments " + |
| 9 |
"given (#{arguments.size} for 2)") if arguments.size != 2 |
| 10 |
|
| 11 |
# auto capitalize puppet resource for lookup: |
| 12 |
res_type = arguments[0].split('::').collect{ |x| x.capitalize }.join('::') |
| 13 |
res_attr = arguments[1] |
| 14 |
|
| 15 |
return self.lookupdefaults(res_type).has_key?(res_attr.to_sym) |
| 16 |
end |
| 17 |
end |