Class: Tumugi::TaskDefinition
- Inherits:
-
Object
- Object
- Tumugi::TaskDefinition
- Includes:
- Mixin::Listable, Mixin::TaskHelper
- Defined in:
- lib/tumugi/task_definition.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, opts = {}) ⇒ TaskDefinition
constructor
A new instance of TaskDefinition.
- #instance ⇒ Object
- #output(outputs = [], &block) ⇒ Object
- #output_eval(task) ⇒ Object
- #param(name, opts = {}) ⇒ Object
- #param_auto_bind_enabled(v) ⇒ Object
- #param_set(name, value) ⇒ Object
- #required_tasks ⇒ Object
- #requires(tasks) ⇒ Object
- #run(&block) ⇒ Object
- #run_block(task) ⇒ Object
Methods included from Mixin::TaskHelper
Methods included from Mixin::Listable
Constructor Details
#initialize(id, opts = {}) ⇒ TaskDefinition
Returns a new instance of TaskDefinition.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tumugi/task_definition.rb', line 20 def initialize(id, opts={}) @id = id @opts = { type: Tumugi::Task }.merge(opts) @params = {} @param_defaults = {} unless @opts[:type].is_a?(Class) @opts[:type] = Tumugi::Plugin.lookup_task(@opts[:type]) end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
18 19 20 |
# File 'lib/tumugi/task_definition.rb', line 18 def id @id end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
18 19 20 |
# File 'lib/tumugi/task_definition.rb', line 18 def opts @opts end |
Class Method Details
.define(id, opts = {}, &block) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/tumugi/task_definition.rb', line 11 def self.define(id, opts={}, &block) td = Tumugi::TaskDefinition.new(id, opts) td.instance_eval(&block) if block_given? Tumugi.application.add_task(id, td) td end |
Instance Method Details
#instance ⇒ Object
31 32 33 |
# File 'lib/tumugi/task_definition.rb', line 31 def instance @task ||= create_task end |
#output(outputs = [], &block) ⇒ Object
51 52 53 |
# File 'lib/tumugi/task_definition.rb', line 51 def output(outputs=[], &block) @outputs ||= (block || outputs) end |
#output_eval(task) ⇒ Object
59 60 61 |
# File 'lib/tumugi/task_definition.rb', line 59 def output_eval(task) @out ||= @outputs.is_a?(Proc) ? task.instance_eval(&@outputs) : @outputs end |
#param(name, opts = {}) ⇒ Object
35 36 37 |
# File 'lib/tumugi/task_definition.rb', line 35 def param(name, opts={}) @params[name] = opts end |
#param_auto_bind_enabled(v) ⇒ Object
43 44 45 |
# File 'lib/tumugi/task_definition.rb', line 43 def param_auto_bind_enabled(v) @param_auto_bind_enabled = v end |
#param_set(name, value) ⇒ Object
39 40 41 |
# File 'lib/tumugi/task_definition.rb', line 39 def param_set(name, value) @param_defaults[name] = value end |
#required_tasks ⇒ Object
63 64 65 |
# File 'lib/tumugi/task_definition.rb', line 63 def required_tasks @required_tasks end |
#requires(tasks) ⇒ Object
47 48 49 |
# File 'lib/tumugi/task_definition.rb', line 47 def requires(tasks) @required_tasks = tasks end |
#run(&block) ⇒ Object
55 56 57 |
# File 'lib/tumugi/task_definition.rb', line 55 def run(&block) @run = block end |