Class: Trailblazer::Activity::TaskBuilder::Task
- Inherits:
-
Object
- Object
- Trailblazer::Activity::TaskBuilder::Task
- Defined in:
- lib/trailblazer/activity/task_builder.rb
Overview
Wraps a task (that usually expects the task interface) into a circuit interface that can be used directly in a Circuit. We expect task to be exposing an Option() interface when calling it.
Instance Method Summary collapse
- #call(ctx, flow_options, **circuit_options) ⇒ Object
-
#initialize(task, user_proc) ⇒ Task
constructor
A new instance of Task.
-
#inspect ⇒ Object
(also: #to_s)
TODO: make me private!.
Constructor Details
#initialize(task, user_proc) ⇒ Task
Returns a new instance of Task.
25 26 27 28 29 |
# File 'lib/trailblazer/activity/task_builder.rb', line 25 def initialize(task, user_proc) @task = task @user_proc = user_proc freeze end |
Instance Method Details
#call(ctx, flow_options, **circuit_options) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/trailblazer/activity/task_builder.rb', line 31 def call((ctx, ), **) # Execute the user step with TRB's kw args. # {@task} is/implements {Trailblazer::Option} interface. result = call_option(@task, [ctx, ], **) # Return an appropriate signal which direction to go next. signal = Activity::TaskBuilder.binary_signal_for(result, Activity::Right, Activity::Left) return signal, [ctx, ] end |
#inspect ⇒ Object Also known as: to_s
TODO: make me private!
47 48 49 |
# File 'lib/trailblazer/activity/task_builder.rb', line 47 def inspect # TODO: make me private! %{#<Trailblazer::Activity::TaskBuilder::Task user_proc=#{Trailblazer::Activity::Introspect.render_task(@user_proc)}>} end |