class Molinillo::DependencyGraph::AddEdgeNoCircular

(see DependencyGraph#add_edge_no_circular)
@!visibility private

def self.action_name

(see Action.action_name)
def self.action_name
  :add_vertex
end

def delete_first(array, item)

def delete_first(array, item)
  return unless index = array.index(item)
  array.delete_at(index)
end

def down(graph)

(see Action#down)
def down(graph)
  edge = make_edge(graph)
  delete_first(edge.origin.outgoing_edges, edge)
  delete_first(edge.destination.incoming_edges, edge)
end

def initialize(origin, destination, requirement)

Parameters:
  • requirement (Object) -- the requirement that the edge represents
  • destination (String) -- the name of the destination of the edge
  • origin (String) -- the name of the origin of the edge
def initialize(origin, destination, requirement)
  @origin = origin
  @destination = destination
  @requirement = requirement
end

def make_edge(graph)

Returns:
  • (Edge) - The edge this action adds

Parameters:
  • graph (DependencyGraph) -- the graph to find vertices from
def make_edge(graph)
  Edge.new(graph.vertex_named(origin), graph.vertex_named(destination), requirement)
end

def up(graph)

(see Action#up)
def up(graph)
  edge = make_edge(graph)
  edge.origin.outgoing_edges << edge
  edge.destination.incoming_edges << edge
  edge
end