-
Notifications
You must be signed in to change notification settings - Fork 28
Interactor
Sunny Ripert edited this page Jul 15, 2024
·
6 revisions
This gem is heavily influenced by Interactor ♥.
Some key differences make Actor unique:
- Requires documenting arguments with
input
andoutput
. - Defaults to raising errors on failures: actor uses
call
andresult
instead ofcall!
andcall
. This way, the default is to raise an error and failures are not hidden away because you forgot to use!
. - Can add defaults to inputs.
- Can add type checking to inputs.
- Can add requirements and conditions on inputs.
- Delegates methods on the context:
foo
vscontext.foo
,self.foo =
vscontext.foo =
,fail!
vscontext.fail!
. - Shorter setup syntax: inherit from
< Actor
vs having toinclude Interactor
andinclude Interactor::Organizer
. - Can use lambdas and instance methods in an organizer.
- Can call interactors multiple times inside organizers.
- Add conditions to interactors in an organizer.
- Allows early success with organizer conditions.
- No
before
&after
hooks, prefer usingplay
. -
Does not hide errors when an actor fails inside another actor(finally fixed in Interactor).
Actor accepts using Interactor classes when using play
for a smooth migration. You can use both gems at the same time in your application.