class Novel::WorkflowBuilder
Attributes
name[R]
raw_workflow[R]
repository[R]
Public Class Methods
new(name:, repository:, raw_workflow: [])
click to toggle source
# File lib/novel/workflow_builder.rb, line 5 def initialize(name:, repository:, raw_workflow: []) @name = name @raw_workflow = raw_workflow @repository = repository end
Public Instance Methods
build()
click to toggle source
# File lib/novel/workflow_builder.rb, line 19 def build Saga.new( name: name, workflow: Workflow.new(raw: raw_workflow), executor: Executor.new(container: build_container, repository: repository) ) end
register_step(name, activity:, compensation: nil)
click to toggle source
# File lib/novel/workflow_builder.rb, line 11 def register_step(name, activity:, compensation: nil) self.class.new( name: name, repository: repository, raw_workflow: raw_workflow + [{ name: name, activity: activity, compensation: compensation }] ) end
Private Instance Methods
build_container()
click to toggle source
# File lib/novel/workflow_builder.rb, line 29 def build_container container = Container.new raw_workflow.each do |step| container.register("#{step[:name]}.activity", step[:activity][:command]) container.register("#{step[:name]}.compensation", step[:compensation][:command]) end container end