Module: Pacer::Utils::TSort::Route
- Includes:
- TSort
- Defined in:
- lib/pacer/utils/tsort.rb
Instance Attribute Summary collapse
-
#tsort_anon_mod ⇒ Object
Returns the value of attribute tsort_anon_mod.
Instance Method Summary collapse
-
#dependencies(&block) ⇒ Object
NOTE: this is a great example of dynamically injecting a custom method into a route.
- #tsort ⇒ Object
- #tsort_each_child(node) ⇒ Object
- #tsort_each_node ⇒ Object
Instance Attribute Details
#tsort_anon_mod ⇒ Object
Returns the value of attribute tsort_anon_mod.
12 13 14 |
# File 'lib/pacer/utils/tsort.rb', line 12 def tsort_anon_mod @tsort_anon_mod end |
Instance Method Details
#dependencies(&block) ⇒ Object
NOTE: this is a great example of dynamically injecting a custom method into a route.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pacer/utils/tsort.rb', line 16 def dependencies(&block) anon_mod = Module.new class << anon_mod def inspect '<TSort anon mixin module>' end end anon_mod.const_set :Route, TSort::Route anon_mod.const_set :Vertex, Module.new anon_mod::Vertex.const_set :DependenciesBlock, block anon_mod::Vertex.instance_eval do def self.included(target) target.const_set :DependenciesBlock, self::DependenciesBlock end end route = v.add_extensions [TSort, anon_mod] route.tsort_anon_mod = anon_mod route end |
#tsort ⇒ Object
48 49 50 51 52 |
# File 'lib/pacer/utils/tsort.rb', line 48 def tsort super.to_route(:graph => graph, :element_type => :vertex, :extensions => (extensions - [TSort, tsort_anon_mod])) end |
#tsort_each_child(node) ⇒ Object
42 43 44 45 46 |
# File 'lib/pacer/utils/tsort.rb', line 42 def tsort_each_child(node) node.tsort_dependencies(tsort_anon_mod).each do |vertex| yield vertex end end |
#tsort_each_node ⇒ Object
36 37 38 39 40 |
# File 'lib/pacer/utils/tsort.rb', line 36 def tsort_each_node v.each do |vertex| yield vertex end end |