summaryrefslogtreecommitdiff
path: root/lib/chef/resource_collection.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/resource_collection.rb')
-rw-r--r--lib/chef/resource_collection.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/chef/resource_collection.rb b/lib/chef/resource_collection.rb
index dc93cfb4fa..5728fdd3e9 100644
--- a/lib/chef/resource_collection.rb
+++ b/lib/chef/resource_collection.rb
@@ -33,6 +33,7 @@ class Chef
def []=(index, arg)
is_chef_resource(arg)
+ raise ArgumentError, "Already have a resource named #{arg.to_s}" if @resources_by_name.has_key?(arg.to_s)
@resources[index] = arg
@resources_by_name[arg.to_s] = index
end
@@ -40,6 +41,7 @@ class Chef
def <<(*args)
args.flatten.each do |a|
is_chef_resource(a)
+ raise ArgumentError, "Already have a resource named #{a.to_s}" if @resources_by_name.has_key?(a.to_s)
@resources << a
@resources_by_name[a.to_s] = @resources.length - 1
end
@@ -48,6 +50,7 @@ class Chef
def push(*args)
args.flatten.each do |a|
is_chef_resource(a)
+ raise ArgumentError, "Already have a resource named #{a.to_s}" if @resources_by_name.has_key?(a.to_s)
@resources.push(a)
@resources_by_name[a.to_s] = @resources.length - 1
end