Module: Cell::Dependencies::TotalOrder

Defined in:
lib/cell/dependencies.rb

Instance Method Summary collapse

Instance Method Details

#total_orderObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cell/dependencies.rb', line 32

def total_order
  seen = Set.new
  order = []
  cells = Cell::Base.descendants.sort_by {|cell| cell.cell_name}
  cells.each do |cell|
    next if seen.include?(cell)
    order += cell.dependencies.select {|dep| !seen.include?(dep)} + [cell]
    seen += order
  end
  return order.uniq
end