Class: Fiona7::Builder::BatchWidgetWriter::WidgetGraph
- Inherits:
-
Object
- Object
- Fiona7::Builder::BatchWidgetWriter::WidgetGraph
- Includes:
- TSort
- Defined in:
- lib/fiona7/builder/batch_widget_writer.rb
Instance Method Summary collapse
-
#initialize(nodes) ⇒ WidgetGraph
constructor
A new instance of WidgetGraph.
- #tsort_each_child(node, &block) ⇒ Object
- #tsort_each_node(&block) ⇒ Object
Constructor Details
#initialize(nodes) ⇒ WidgetGraph
Returns a new instance of WidgetGraph.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fiona7/builder/batch_widget_writer.rb', line 14 def initialize(nodes) @nodes = nodes @dependencies = {} @nodes.each do |node| @dependencies[node] = node.dependencies.map do |id| node = @nodes.find {|n| n.id.to_sym == id.to_sym } end.compact end end |
Instance Method Details
#tsort_each_child(node, &block) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/fiona7/builder/batch_widget_writer.rb', line 29 def tsort_each_child(node, &block) if !@dependencies[node] raise Scrivito::ScrivitoError, "Broken widget dependency graph" end @dependencies[node].each(&block) end |
#tsort_each_node(&block) ⇒ Object
25 26 27 |
# File 'lib/fiona7/builder/batch_widget_writer.rb', line 25 def tsort_each_node(&block) @nodes.each(&block) end |