Class: ForemanDeployments::TaskReference
- Inherits:
-
Object
- Object
- ForemanDeployments::TaskReference
- Defined in:
- app/lib/foreman_deployments/task_reference.rb
Instance Attribute Summary collapse
-
#output_key ⇒ Object
Returns the value of attribute output_key.
-
#task ⇒ Object
Returns the value of attribute task.
-
#task_id ⇒ Object
Returns the value of attribute task_id.
Class Method Summary collapse
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #dereference(output) ⇒ Object
-
#initialize(task_id, output_key, task = nil) ⇒ TaskReference
constructor
A new instance of TaskReference.
- #to_hash ⇒ Object
Constructor Details
#initialize(task_id, output_key, task = nil) ⇒ TaskReference
Returns a new instance of TaskReference.
5 6 7 8 9 |
# File 'app/lib/foreman_deployments/task_reference.rb', line 5 def initialize(task_id, output_key, task = nil) @task_id = task_id @output_key = output_key @task = task end |
Instance Attribute Details
#output_key ⇒ Object
Returns the value of attribute output_key.
3 4 5 |
# File 'app/lib/foreman_deployments/task_reference.rb', line 3 def output_key @output_key end |
#task ⇒ Object
Returns the value of attribute task.
3 4 5 |
# File 'app/lib/foreman_deployments/task_reference.rb', line 3 def task @task end |
#task_id ⇒ Object
Returns the value of attribute task_id.
3 4 5 |
# File 'app/lib/foreman_deployments/task_reference.rb', line 3 def task_id @task_id end |
Class Method Details
.tag_name ⇒ Object
38 39 40 |
# File 'app/lib/foreman_deployments/task_reference.rb', line 38 def self.tag_name 'reference' end |
Instance Method Details
#accept(visitor) ⇒ Object
25 26 27 |
# File 'app/lib/foreman_deployments/task_reference.rb', line 25 def accept(visitor) visitor.visit(self) end |
#dereference(output) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/lib/foreman_deployments/task_reference.rb', line 11 def dereference(output) output_keys.each do |key| return nil if output.nil? if output.is_a?(Hash) || output.is_a?(Dynflow::ExecutionPlan::OutputReference) output = output[key] else output = output.send(key) end end return output rescue NoMethodError return nil end |
#to_hash ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/lib/foreman_deployments/task_reference.rb', line 29 def to_hash { '_type' => 'reference', '_name' => self.class.tag_name, 'object' => task_id, 'field' => output_key } end |