Method: Puppet::Type::RelationshipMetaparam#to_edges

Defined in:
lib/vendor/puppet/type.rb

#to_edgesObject

Create edges from each of our relationships. :in relationships are specified by the event-receivers, and :out relationships are specified by the event generator. This way ‘source’ and ‘target’ are consistent terms in both edges and events – that is, an event targets edges whose source matches the event’s source. The direction of the relationship determines which resource is applied first and which resource is considered to be the event generator.



1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
# File 'lib/vendor/puppet/type.rb', line 1205

def to_edges
  @value.collect do |reference|
    reference.catalog = resource.catalog

    # Either of the two retrieval attempts could have returned
    # nil.
    unless related_resource = reference.resolve
      self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}"
    end

    # Are we requiring them, or vice versa?  See the method docs
    # for futher info on this.
    if self.class.direction == :in
      source = related_resource
      target = @resource
    else
      source = @resource
      target = related_resource
    end

    if method = self.class.callback
      subargs = {
        :event => self.class.events,
        :callback => method
      }
      self.debug("subscribes to #{related_resource.ref}")
    else
      # If there's no callback, there's no point in even adding
      # a label.
      subargs = nil
      self.debug("requires #{related_resource.ref}")
    end

    rel = Puppet::Relationship.new(source, target, subargs)
  end
end