class Gem::Molinillo::DependencyGraph::DetachVertexNamed

@!visibility private @see DependencyGraph#detach_vertex_named

属性

name[R]

@return [String] 要分离的顶点的名称

公共类方法

action_name() 点击切换源代码

(参见 Action#name)

# File rubygems/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb, line 12
def self.action_name
  :add_vertex
end
new(name) 点击切换源代码

初始化一个从依赖图中分离顶点的动作 @param [String] name 要分离的顶点的名称

# File rubygems/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb, line 56
def initialize(name)
  @name = name
end

公共实例方法

down(graph) 点击切换源代码

(参见 Action#down)

# File rubygems/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb, line 38
def down(graph)
  return unless @vertex
  graph.vertices[@vertex.name] = @vertex
  @vertex.outgoing_edges.each do |e|
    e.destination.incoming_edges << e
  end
  @vertex.incoming_edges.each do |e|
    e.origin.outgoing_edges << e
  end
end
up(graph) 点击切换源代码

(参见 Action#up)

# File rubygems/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb, line 17
def up(graph)
  return [] unless @vertex = graph.vertices.delete(name)

  removed_vertices = [@vertex]
  @vertex.outgoing_edges.each do |e|
    v = e.destination
    v.incoming_edges.delete(e)
    if !v.root? && v.incoming_edges.empty?
      removed_vertices.concat graph.detach_vertex_named(v.name)
    end
  end

  @vertex.incoming_edges.each do |e|
    v = e.origin
    v.outgoing_edges.delete(e)
  end

  removed_vertices
end