123456789_123456789_123456789_123456789_123456789_

Class: Gem::Molinillo::DependencyGraph::AddEdgeNoCircular

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Action
Instance Chain:
self, Action
Inherits: Gem::Molinillo::DependencyGraph::Action
Defined in: lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb

Overview

Action

AddEdgeNoCircular

Class Method Summary

Action - Inherited

Instance Attribute Summary

Action - Inherited

Instance Method Summary

Action - Inherited

#down

Reverses the action on the given graph.

#up

Performs the action on the given graph.

Constructor Details

.new(origin, destination, requirement) ⇒ AddEdgeNoCircular

Initialize an action to add an edge to a dependency graph

Parameters:

  • origin (String)

    the name of the origin of the edge

  • destination (String)

    the name of the destination of the edge

  • requirement (Object)

    the requirement that the edge represents

[ GitHub ]

  
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb', line 52

def initialize(origin, destination, requirement)
  @origin = origin
  @destination = destination
  @requirement = requirement
end

Class Method Details

.action_nameSymbol

Returns:

  • (Symbol)

    The name of the action.

[ GitHub ]

  
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb', line 12

def self.action_name
  :add_vertex
end

Instance Attribute Details

#destinationString (readonly)

Returns:

  • (String)

    the name of the destination of the edge

[ GitHub ]

  
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb', line 37

attr_reader :destination

#originString (readonly)

Returns:

  • (String)

    the name of the origin of the edge

[ GitHub ]

  
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb', line 34

attr_reader :origin

#requirementObject (readonly)

Returns:

  • (Object)

    the requirement that the edge represents

[ GitHub ]

  
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb', line 40

attr_reader :requirement

Instance Method Details

#delete_first(array, item) (private)

[ GitHub ]

  
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb', line 60

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

#down(graph) ⇒ Void

Reverses the action on the given graph.

Parameters:

[ GitHub ]

  
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb', line 25

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

#make_edge(graph) ⇒ Edge

Parameters:

Returns:

  • (Edge)

    The edge this action adds

[ GitHub ]

  
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb', line 44

def make_edge(graph)
  Edge.new(graph.vertex_named(origin), graph.vertex_named(destination), requirement)
end

#up(graph) ⇒ Void

Performs the action on the given graph.

Parameters:

[ GitHub ]

  
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb', line 17

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