From c8e89cc1a69ff5827ad40439a2c903c24ae42aba Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 21 Jan 2010 22:00:10 -0800 Subject: Changing the interface of Puppet::Resource We need the ability to set the namespace and environment at initialization so the resource can look up qualified types. Signed-off-by: Luke Kanies --- lib/puppet/resource.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/puppet/resource.rb') diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index bdd11fcc5..e47501791 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -116,14 +116,20 @@ class Puppet::Resource end # Create our resource. - def initialize(type, title, parameters = {}) - @reference = Puppet::Resource::Reference.new(type, title) + def initialize(type, title, attributes = {}) @parameters = {} - parameters.each do |param, value| + (attributes[:parameters] || {}).each do |param, value| self[param] = value end + attributes.each do |attr, value| + next if attr == :parameters + send(attr.to_s + "=", value) + end + + @reference = Puppet::Resource::Reference.new(type, title) + tag(@reference.type) tag(@reference.title) if valid_tag?(@reference.title) end -- cgit