class Molinillo::DependencyGraph::AddVertex

:nodoc:
(see DependencyGraph#add_vertex)
@!visibility private

def self.action_name

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

def down(graph)

(see Action#down)
def down(graph)
  if defined?(@existing_payload)
    vertex = graph.vertices[name]
    vertex.payload = @existing_payload
    vertex.root = @existing_root
  else
    graph.vertices.delete(name)
  end
end

def initialize(name, payload, root)

Parameters:
  • root (Boolean) -- whether the vertex is root or not
  • payload (Object) -- the payload for the vertex
  • name (String) -- the name of the vertex
def initialize(name, payload, root)
  @name = name
  @payload = payload
  @root = root
end

def up(graph)

(see Action#up)
def up(graph)
  if existing = graph.vertices[name]
    @existing_payload = existing.payload
    @existing_root = existing.root
  end
  vertex = existing || Vertex.new(name, payload)
  graph.vertices[vertex.name] = vertex
  vertex.payload ||= payload
  vertex.root ||= root
  vertex
end