Method: Qricker::Resolver#addDependency

Defined in:
lib/qricker/dependency.rb

#addDependency(parent, child) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/qricker/dependency.rb', line 81

def addDependency(parent, child)
  parentNode = @roots.searchChild(parent)
  if parentNode.nil?
    parentNode = DependencyNode.new(parent)
    @roots.addChild(parentNode)
  end
  childNode = nil
  if @roots.hasChild(child)
    childNode = @roots.searchChild(child)
    @roots.removeChild childNode
  else
    childNode = DependencyNode.new(child)
  end
  if parentNode.searchChild(child).nil?
    parentNode.addChild(childNode)
  end
end