Class: Taski::Task
- Inherits:
-
Object
- Object
- Taski::Task
- Defined in:
- lib/taski/task.rb
Direct Known Subclasses
Class Method Summary collapse
- .cached_dependencies ⇒ Object
- .clean(context: {}) ⇒ Object
- .clear_dependency_cache ⇒ Object
- .coordinator ⇒ Object
- .exported_methods ⇒ Object
- .exports(*export_methods) ⇒ Object
-
.new ⇒ Object
Each call creates a fresh TaskWrapper instance for re-execution support.
- .registry ⇒ Object
- .reset! ⇒ Object
- .run(context: {}) ⇒ Object
- .tree ⇒ Object
Instance Method Summary collapse
Class Method Details
.cached_dependencies ⇒ Object
34 35 36 |
# File 'lib/taski/task.rb', line 34 def cached_dependencies @dependencies_cache ||= StaticAnalysis::Analyzer.analyze(self) end |
.clean(context: {}) ⇒ Object
48 49 50 51 52 |
# File 'lib/taski/task.rb', line 48 def clean(context: {}) Taski.start_context(options: context, root_task: self) validate_no_circular_dependencies! cached_wrapper.clean end |
.clear_dependency_cache ⇒ Object
38 39 40 |
# File 'lib/taski/task.rb', line 38 def clear_dependency_cache @dependencies_cache = nil end |
.coordinator ⇒ Object
58 59 60 61 62 63 |
# File 'lib/taski/task.rb', line 58 def coordinator @coordinator ||= Execution::Coordinator.new( registry: registry, analyzer: StaticAnalysis::Analyzer ) end |
.exported_methods ⇒ Object
20 21 22 |
# File 'lib/taski/task.rb', line 20 def exported_methods @exported_methods ||= [] end |
.exports(*export_methods) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/taski/task.rb', line 11 def exports(*export_methods) @exported_methods = export_methods export_methods.each do |method| define_instance_reader(method) define_class_accessor(method) end end |
.new ⇒ Object
Each call creates a fresh TaskWrapper instance for re-execution support. Use class methods (e.g., MyTask.result) for cached single execution.
26 27 28 29 30 31 32 |
# File 'lib/taski/task.rb', line 26 def new Execution::TaskWrapper.new( super, registry: registry, coordinator: coordinator ) end |
.registry ⇒ Object
54 55 56 |
# File 'lib/taski/task.rb', line 54 def registry Taski.global_registry end |
.reset! ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/taski/task.rb', line 65 def reset! registry.reset! Taski.reset_global_registry! Taski.reset_context! @coordinator = nil @circular_dependency_checked = false end |
.run(context: {}) ⇒ Object
42 43 44 45 46 |
# File 'lib/taski/task.rb', line 42 def run(context: {}) Taski.start_context(options: context, root_task: self) validate_no_circular_dependencies! cached_wrapper.run end |
.tree ⇒ Object
73 74 75 |
# File 'lib/taski/task.rb', line 73 def tree build_tree(self, "", {}, false) end |
Instance Method Details
#clean ⇒ Object
208 209 |
# File 'lib/taski/task.rb', line 208 def clean end |
#reset! ⇒ Object
211 212 213 214 215 |
# File 'lib/taski/task.rb', line 211 def reset! self.class.exported_methods.each do |method| instance_variable_set("@#{method}", nil) end end |
#run ⇒ Object
204 205 206 |
# File 'lib/taski/task.rb', line 204 def run raise NotImplementedError, "Subclasses must implement the run method" end |