Skip to content
Aaron Allen edited this page Jan 26, 2020 · 2 revisions

What is an Interactor

An interactor is a simple, single-purpose service object.

Interactors can be used to reduce the responsibility of your controllers, workers, and models and encapsulate your application's business logic. Each interactor represents one thing that your application does.

ActiveInteractor

ActiveInteractor's main component is called an interactor, each interactor has it's own immutable context which contains everything the interactor needs to do its work. When an interactor does its single purpose, it affects its given context. For detailed usage details jump to any of the sections outlined below.

Technical documentation for the gem can be found on rubydoc.

Usage

  1. Interactors
    1. Basic Interactors
    2. Organizers
      1. Organizing Interactors Conditionally
      2. Running Interactors In Parallel
      3. Rollback
  2. Context
    1. Adding to the Context
    2. Failing the Context
    3. Dealing with Failure
    4. Context Attributes
    5. Validating the Context
  3. Callbacks
    1. Validation Callbacks
    2. Perform Callbacks
    3. Rollback Callbacks
    4. Organizer Callbacks
  4. Working With Rails
    1. Generators
    2. ActiveRecord Helper Methods
Clone this wiki locally