Method: Chef::ResourceCollection#insert

Defined in:
lib/chef/resource_collection.rb

#insert(resource, opts = {}) ⇒ Object Also known as: <<

This method is meant to be the 1 insert method necessary in the future. It should support all known use cases

for writing into the ResourceCollection.

Parameters:

  • The resource to insert

  • If known, the resource type used in the recipe, Eg package, execute

  • If known, the resource name as used in the recipe, IE vim in ‘package ’vim’‘



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/chef/resource_collection.rb', line 54

def insert(resource, opts = {})
  resource_type ||= opts[:resource_type] # Would rather use Ruby 2.x syntax, but oh well
  instance_name ||= opts[:instance_name]
  resource_list.insert(resource)
  if !(resource_type.nil? && instance_name.nil?)
    resource_set.insert_as(resource, resource_type, instance_name)
  else
    resource_set.insert_as(resource)
  end
  if unified_mode
    run_context.runner.run_all_actions(resource)
  end
end