# File lib/chef/resource_collection.rb, line 57 def insert(resource) is_chef_resource(resource) if @insert_after_idx # in the middle of executing a run, so any resources inserted now should # be placed after the most recent addition done by the currently executing # resource @resources.insert(@insert_after_idx + 1, resource) # update name -> location mappings and register new resource @resources_by_name.each_key do |key| @resources_by_name[key] += 1 if @resources_by_name[key] > @insert_after_idx end @resources_by_name[resource.to_s] = @insert_after_idx + 1 @insert_after_idx += 1 else @resources << resource @resources_by_name[resource.to_s] = @resources.length - 1 end end