Skip to content

Commit

Permalink
Merge pull request #45 from yogeshjain999/improvement/testing-signals
Browse files Browse the repository at this point in the history
Allow `Testing.def_task` & `Testing.def_tasks` to return custom signals
  • Loading branch information
yogeshjain999 authored Aug 29, 2020
2 parents b8e8a65 + 088a772 commit f3ed45c
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 f3ed45c

Please sign in to comment.