Class: Conductor::Workflow::Dsl::TaskRef
- Inherits:
-
Object
- Object
- Conductor::Workflow::Dsl::TaskRef
- Defined in:
- lib/conductor/workflow/dsl/task_ref.rb
Overview
TaskRef is a lightweight proxy returned by DSL task methods Enables [] syntax for output references and stores task metadata
Instance Attribute Summary collapse
-
#input_parameters ⇒ Object
(also: #inputs)
readonly
Returns the value of attribute input_parameters.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#ref_name ⇒ Object
readonly
Returns the value of attribute ref_name.
-
#task_name ⇒ Object
readonly
Returns the value of attribute task_name.
-
#task_type ⇒ Object
readonly
Returns the value of attribute task_type.
Instance Method Summary collapse
-
#[](field) ⇒ OutputRef
Access task output by field name using [] syntax.
-
#initialize(ref_name:, task_name:, task_type:, input_parameters: {}, options: {}) ⇒ TaskRef
constructor
A new instance of TaskRef.
-
#input(field = nil) ⇒ OutputRef
Access task input (for dynamic references).
-
#output ⇒ OutputRef
Access task's full output (no specific field).
-
#to_workflow_task ⇒ Conductor::Http::Models::WorkflowTask
Convert to WorkflowTask model for serialization.
Constructor Details
#initialize(ref_name:, task_name:, task_type:, input_parameters: {}, options: {}) ⇒ TaskRef
Returns a new instance of TaskRef.
17 18 19 20 21 22 23 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 17 def initialize(ref_name:, task_name:, task_type:, input_parameters: {}, options: {}) @ref_name = ref_name @task_name = task_name @task_type = task_type @input_parameters = input_parameters @options = end |
Instance Attribute Details
#input_parameters ⇒ Object (readonly) Also known as: inputs
Returns the value of attribute input_parameters.
9 10 11 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 9 def input_parameters @input_parameters end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 9 def @options end |
#ref_name ⇒ Object (readonly)
Returns the value of attribute ref_name.
9 10 11 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 9 def ref_name @ref_name end |
#task_name ⇒ Object (readonly)
Returns the value of attribute task_name.
9 10 11 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 9 def task_name @task_name end |
#task_type ⇒ Object (readonly)
Returns the value of attribute task_type.
9 10 11 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 9 def task_type @task_type end |
Instance Method Details
#[](field) ⇒ OutputRef
Access task output by field name using [] syntax
32 33 34 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 32 def [](field) OutputRef.new("#{@ref_name}.output.#{field}") end |
#input(field = nil) ⇒ OutputRef
Access task input (for dynamic references)
45 46 47 48 49 50 51 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 45 def input(field = nil) if field OutputRef.new("#{@ref_name}.input.#{field}") else OutputRef.new("#{@ref_name}.input") end end |
#output ⇒ OutputRef
Access task's full output (no specific field)
38 39 40 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 38 def output OutputRef.new("#{@ref_name}.output") end |
#to_workflow_task ⇒ Conductor::Http::Models::WorkflowTask
Convert to WorkflowTask model for serialization
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/conductor/workflow/dsl/task_ref.rb', line 55 def to_workflow_task wf_task = Conductor::Http::Models::WorkflowTask.new( name: @task_name, task_reference_name: @ref_name, type: @task_type, input_parameters: @input_parameters ) # Apply options wf_task.description = @options[:description] if @options[:description] wf_task.optional = @options[:optional] if @options[:optional] # Cache config if @options[:cache_key] && @options[:cache_ttl] wf_task.cache_config = Conductor::Http::Models::CacheConfig.new( key: @options[:cache_key], ttl_in_second: @options[:cache_ttl] ) end # Task-specific fields apply_task_specific_fields(wf_task) wf_task end |