summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-16 04:35:56 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-16 04:35:56 +0000
commit093963e60313f28afc95f829bce94d6096fba868 (patch)
tree61fae7c5f63fa213efb1703911bc77d3c5a83e2d /lib
parentac0454a4bfcf6e9ecd3f3eb6037f04caa3c3ce59 (diff)
downloadpuppet-093963e60313f28afc95f829bce94d6096fba868.tar.gz
puppet-093963e60313f28afc95f829bce94d6096fba868.tar.xz
puppet-093963e60313f28afc95f829bce94d6096fba868.zip
finishing up merge method
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@675 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/type.rb25
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 39050ca55..4f957a74e 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -684,7 +684,8 @@ class Type < Puppet::Element
# force users to call this, so that we can merge objects if
# necessary
def self.create(hash)
- if name = self["name"] || self[:name]
+ if name = hash["name"] || hash[:name] ||
+ hash[self.namevar] || hash[self.namevar.to_s]
# if the object already exists
if retobj = self[name]
retobj.merge(self)
@@ -694,9 +695,8 @@ class Type < Puppet::Element
return new(hash)
end
else
- return new(hash)
- #raise Puppet::Error, "You must specify a name for objects of type %s" %
- # self.to_s
+ raise Puppet::Error, "You must specify a name for objects of type %s" %
+ self.to_s
end
end
#---------------------------------------------------------------
@@ -800,20 +800,17 @@ class Type < Puppet::Element
def merge(hash)
hash.each { |param, value|
if param.is_a?(String)
- hash[param.intern] = value
- hash.delete(param)
+ param = param.intern
end
- }
+ next if param == :name or param == self.class.namevar
- hash.each { |param, value|
# FIXME we should really allow equal values, but for now, don't allow
# any values
-
- if oldval = self[param]
- if self.parent.class == self.class # they're a result of recursion
- end
- unless oldval == value
- end
+ if oldval = self.should(param)
+ raise Puppet::Error, "Cannot override %s on %s(%s)" %
+ [param, self.class.name, self.name]
+ else
+ self[param] = value
end
}
end