Class: CircuitBreaker::WorkflowBuilder::DSL::ActionBuilder
- Inherits:
-
Object
- Object
- CircuitBreaker::WorkflowBuilder::DSL::ActionBuilder
- Defined in:
- lib/circuit_breaker/workflow_dsl.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #execute(executor, method, result_name = nil, **params) ⇒ Object
- #execute_actions(token) ⇒ Object
-
#initialize(workflow_builder) ⇒ ActionBuilder
constructor
A new instance of ActionBuilder.
Constructor Details
#initialize(workflow_builder) ⇒ ActionBuilder
Returns a new instance of ActionBuilder.
54 55 56 57 58 |
# File 'lib/circuit_breaker/workflow_dsl.rb', line 54 def initialize(workflow_builder) @workflow_builder = workflow_builder @context = ActionContext.new @actions = [] end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
52 53 54 |
# File 'lib/circuit_breaker/workflow_dsl.rb', line 52 def actions @actions end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
52 53 54 |
# File 'lib/circuit_breaker/workflow_dsl.rb', line 52 def context @context end |
Instance Method Details
#execute(executor, method, result_name = nil, **params) ⇒ Object
60 61 62 |
# File 'lib/circuit_breaker/workflow_dsl.rb', line 60 def execute(executor, method, result_name = nil, **params) @actions << [executor, method, result_name, params] end |
#execute_actions(token) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/circuit_breaker/workflow_dsl.rb', line 64 def execute_actions(token) puts "Executing actions for token #{token.id}..." @actions.each do |executor, method, result_name, params| puts " Executing #{method} -> #{result_name}" result = executor.send(method, token, **params) puts " Result: #{result.inspect}" @context.add_result(result_name, result) if result_name end end |