Method: Hanuman::TreeInstanceMethods#add_link

Defined in:
lib/hanuman/tree.rb

Raises:

  • (TSort::Cyclic)


38
39
40
41
42
43
44
# File 'lib/hanuman/tree.rb', line 38

def add_link type, from, into
  return if has_link?(from, into)
  raise TSort::Cyclic.new("Cannot link from a stage <#{from.label}> to itself") if into == from
  raise MultipleRoots.new("Cannot link from <#{from.label}> to <#{into.label}> because <#{into.label}> aleady has an ancestor <#{ancestor(into).label}>") if ancestor(into)
  raise TSort::Cyclic.new("Cannot link from leaf <#{from.label}> to the root <#{into.label}>") if into == root && leaves.include?(from)
  super(type, from, into)
end