Method: Puppet::Resource::Catalog#add_resource_after

Defined in:
lib/puppet/resource/catalog.rb

#add_resource_after(other, *resources) ⇒ Object

Add ‘resources` to the catalog after `other`. WARNING: adding multiple resources will produce the reverse ordering, e.g. calling `add_resource_after(A, [B,C])` will result in `[A,C,B]`.



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/puppet/resource/catalog.rb', line 114

def add_resource_after(other, *resources)
  resources.each do |resource|
    other_title_key = title_key_for_ref(other.ref)
    idx = @resources.index(other_title_key)
    if idx.nil?
      raise ArgumentError, _("Cannot add resource %{resource_1} after %{resource_2} because %{resource_2} is not yet in the catalog") %
                           { resource_1: resource.ref, resource_2: other.ref }
    end
    add_one_resource(resource, idx + 1)
  end
end