# File lib/puppet/resource/catalog.rb, line 99
 99:     def alias(resource, name)
100:         #set $1
101:         resource.ref =~ /^(.+)\[/
102: 
103:         newref = "%s[%s]" % [$1 || resource.class.name, name]
104: 
105:         # LAK:NOTE It's important that we directly compare the references,
106:         # because sometimes an alias is created before the resource is
107:         # added to the catalog, so comparing inside the below if block
108:         # isn't sufficient.
109:         return if newref == resource.ref
110:         if existing = @resource_table[newref]
111:             return if existing == resource
112:             raise(ArgumentError, "Cannot alias %s to %s; resource %s already exists" % [resource.ref, name, newref])
113:         end
114:         @resource_table[newref] = resource
115:         @aliases[resource.ref] ||= []
116:         @aliases[resource.ref] << newref
117:     end