Task
A Task is a Method with prerequisite dependencies.
NOTE Can‘t subclass Method b/c Method has no initiator. Not sure that would be a good idea anyway.
Methods
Classes and Modules
Class Task::GraphAttributes
[RW] | description |
Public Class methods
[ show source ]
# File lib/facets/more/taskable.rb, line 57 def initialize( name, container, preq, desc=nil, &action ) @name = name @container = container @prerequisite = preq || [] @description = desc @action = action end
Public Instance methods
[ show source ]
# File lib/facets/more/taskable.rb, line 94 def call @action.call end
#— # TODO Problem is ‘a’ can’t take any parameters, # and there’s no way to sort the tasks # from here. FIX if possible. #++ def to_proc
r = @prerequisite n = @name a = @action lambda { r.each{ |d| send(d) unless n == d } instance_eval &a if a }
end
[ show source ]
# File lib/facets/more/taskable.rb, line 84 def complete # ensure no cycles in the graph and extract call graph #own = (class << self; self; end) # in case there are singletons? t = Graph.new( container, name ) t.each_strongly_connected_component_from( name ) { |c| #@container.instance_task(c).call @container.send("->#{d}") } end
[ show source ]
# File lib/facets/more/taskable.rb, line 98 def each(&blk) @prerequisite.each(&blk) end
[ show source ]
# File lib/facets/more/taskable.rb, line 65 def prerequisite @prerequisite ||= [] end