Skip to content

Interactor

Sunny Ripert edited this page Jul 15, 2024 · 6 revisions

This gem is heavily influenced by Interactor ♥.

Differences

Some key differences make Actor unique:

  • Requires documenting arguments with input and output.
  • Defaults to raising errors on failures: actor uses call and result instead of call! and call. 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 vs context.foo, self.foo = vs context.foo = , fail! vs context.fail!.
  • Shorter setup syntax: inherit from < Actor vs having to include Interactor and include 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 using play.
  • Does not hide errors when an actor fails inside another actor (finally fixed in Interactor).

Migrating from 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.

Clone this wiki locally