A Ruby gem providing a common interface for encapsulating business logic into single-purpose objects called interactors.
Interactor is a Ruby library that provides a common interface for encapsulating complex business logic into single-purpose objects called interactors. It helps organize application behavior by separating concerns and making code more maintainable and testable. Each interactor represents one specific thing your application does, such as authenticating a user or placing an order.
Ruby and Rails developers building applications with complex business logic that needs to be organized, tested, and maintained cleanly. It's particularly useful for teams working on larger codebases where fat controllers and models are becoming a problem.
Developers choose Interactor because it provides a simple, standardized pattern for organizing business logic without the complexity of larger frameworks. Its clear separation of concerns, built-in failure handling, and organizer pattern for sequencing actions make it easier to write and test complex interactions.
Interactor provides a common interface for performing complex user interactions.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Interactors enforce single-purpose units named after business actions, making code self-documenting and reducing controller bloat, as shown in the AuthenticateUser example.
Organizers run multiple interactors in order and automatically roll back completed ones on failure, demonstrated in the PlaceOrder organizer with destroy rollbacks.
Each interactor can be tested in isolation by stubbing dependencies, as recommended in the testing section with RSpec examples focusing on context changes.
The context.fail! method provides a consistent way to handle errors without exceptions, simplifying controller logic and response handling.
After hooks are skipped when an interactor fails, which can complicate cleanup or logging in error scenarios, as noted in the hook documentation.
Interactor lacks built-in mechanisms for asynchronous execution, requiring manual integration with job queues like Sidekiq for background processing.
As interactors pass data via a shared context object, it can become overloaded with unrelated data, making debugging and maintenance harder over time.