Class: SidekiqWorkflows::WorkerNode
- Inherits:
-
Object
- Object
- SidekiqWorkflows::WorkerNode
- Includes:
- Node
- Defined in:
- lib/sidekiq_workflows/worker_node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#on_partial_complete ⇒ Object
Returns the value of attribute on_partial_complete.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#workers ⇒ Object
Returns the value of attribute workers.
-
#workflow_uuid ⇒ Object
Returns the value of attribute workflow_uuid.
Instance Method Summary collapse
-
#initialize(workers:, workflow_uuid: nil, on_partial_complete: nil, parent: nil) ⇒ WorkerNode
constructor
A new instance of WorkerNode.
- #to_h ⇒ Object
Methods included from Node
#add_group, #all_nodes, #serialize
Constructor Details
#initialize(workers:, workflow_uuid: nil, on_partial_complete: nil, parent: nil) ⇒ WorkerNode
Returns a new instance of WorkerNode.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sidekiq_workflows/worker_node.rb', line 12 def initialize(workers:, workflow_uuid: nil, on_partial_complete: nil, parent: nil) @workers = workers.each do |entry| entry[:worker] = ActiveSupport::Inflector.constantize(entry[:worker]) if entry[:worker].is_a?(String) entry[:delay] = entry[:delay].to_i if entry[:delay] end @workflow_uuid = workflow_uuid @on_partial_complete = on_partial_complete @parent = parent @children = [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
9 10 11 |
# File 'lib/sidekiq_workflows/worker_node.rb', line 9 def children @children end |
#on_partial_complete ⇒ Object
Returns the value of attribute on_partial_complete.
8 9 10 |
# File 'lib/sidekiq_workflows/worker_node.rb', line 8 def on_partial_complete @on_partial_complete end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
10 11 12 |
# File 'lib/sidekiq_workflows/worker_node.rb', line 10 def parent @parent end |
#workers ⇒ Object
Returns the value of attribute workers.
8 9 10 |
# File 'lib/sidekiq_workflows/worker_node.rb', line 8 def workers @workers end |
#workflow_uuid ⇒ Object
Returns the value of attribute workflow_uuid.
8 9 10 |
# File 'lib/sidekiq_workflows/worker_node.rb', line 8 def workflow_uuid @workflow_uuid end |
Instance Method Details
#to_h ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sidekiq_workflows/worker_node.rb', line 23 def to_h { workers: workers.map do |entry| { worker: entry[:worker].name, payload: entry[:payload], delay: entry[:delay] } end, workflow_uuid: workflow_uuid, on_partial_complete: on_partial_complete, children: @children.map(&:to_h) } end |