Skip to content

Commit

Permalink
Allow Testing.def_task & Testing.def_tasks to return custom signals
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshjain999 committed Aug 29, 2020
1 parent b8e8a65 commit 088a772
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/trailblazer/activity/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def self.def_task(name)
Module.new do
define_singleton_method(name) do | (ctx, flow_options), ** |
ctx[:seq] << name
return Activity::Right, [ctx, flow_options]
signal = ctx.key?(name) ? ctx[name] : Activity::Right

return signal, [ctx, flow_options]
end
end.method(name)
end
Expand All @@ -38,9 +40,9 @@ def self.def_tasks(*names)
names.each do |name|
define_method(name) do | (ctx, flow_options), ** |
ctx[:seq] << name
result = ctx.key?(name) ? ctx[name] : true
signal = ctx.key?(name) ? ctx[name] : Activity::Right

return (result ? Activity::Right : Activity::Left), [ctx, flow_options]
return signal, [ctx, flow_options]
end
end
end
Expand Down

0 comments on commit 088a772

Please sign in to comment.