Class: ActiveInteractor::Base
- Inherits:
-
Object
- Object
- ActiveInteractor::Base
- Extended by:
- Interactor::Callbacks::ClassMethods, Interactor::Context::ClassMethods, Interactor::Perform::ClassMethods
- Includes:
- Interactor::Callbacks, Interactor::Context, Interactor::Perform, ActiveSupport::Callbacks
- Defined in:
- lib/active_interactor/base.rb
Overview
The base class all interactors should inherit from.
When Base is loaded by your application an
ActiveSupport load hook is called
with :active_interactor
and Base.
Direct Known Subclasses
Class Method Summary collapse
-
.after_context_validation(*args, &block) ⇒ Object
extended
from Interactor::Callbacks::ClassMethods
Define a callback to call after validation has been run on an interactor instance's context instance.
-
.after_perform(*filters, &block) ⇒ Object
extended
from Interactor::Callbacks::ClassMethods
Define a callback to call after #perform has been called on an interactor instance.
-
.after_rollback(*filters, &block) ⇒ Object
extended
from Interactor::Callbacks::ClassMethods
Define a callback to call after #rollback has been called on an interactor instance.
-
.around_perform(*filters, &block) ⇒ Object
extended
from Interactor::Callbacks::ClassMethods
Define a callback to call around #perform invokation on an interactor instance.
-
.around_rollback(*filters, &block) ⇒ Object
extended
from Interactor::Callbacks::ClassMethods
Define a callback to call around #rollback invokation on an interactor instance.
-
.before_context_validation(*args, &block) ⇒ Object
extended
from Interactor::Callbacks::ClassMethods
Define a callback to call before validation has been run on an interactor instance's context instance.
-
.before_perform(*filters, &block) ⇒ Object
extended
from Interactor::Callbacks::ClassMethods
Define a callback to call before #perform has been called on an interactor instance.
-
.before_rollback(*filters, &block) ⇒ Object
extended
from Interactor::Callbacks::ClassMethods
Define a callback to call before #rollback has been called on an interactor instance.
-
.context_attribute(name, type = Type::Value.new, **options) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .attribute on the interactor class' context class.
-
.context_attribute_method?(attribute) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .attribute_method? on the interactor class' context class.
-
.context_attribute_missing(match, *args, &block) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .attribute_missing on the interactor class' context class.
-
.context_attribute_names ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .attribute_names on the interactor class' context class.
-
.context_attributes(*attributes) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .attributes on the interactor class' context class.
-
.context_class ⇒ Const
extended
from Interactor::Context::ClassMethods
Get the interactor class' context class.
-
.context_clear_validators!(attribute) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .clear_validators! on the interactor class' context class.
-
.context_respond_to_without_attributes?(method, include_private_methods = false) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .respond_to_without_attributes? on the interactor class' context class.
-
.context_validate(*args, &block) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validate on the interactor class' context class.
-
.context_validates(*attributes) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates on the interactor class' context class.
-
.context_validates!(*attributes) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates! on the interactor class' context class.
-
.context_validates_absence_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_absence_of on the interactor class' context class.
-
.context_validates_acceptance_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_acceptance_of on the interactor class' context class.
-
.context_validates_confirmation_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_confirmation_of on the interactor class' context class.
-
.context_validates_each(*attr_names, &block) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_each on the interactor class' context class.
-
.context_validates_exclusion_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_exclusion_of on the interactor class' context class.
-
.context_validates_format_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_format_of on the interactor class' context class.
-
.context_validates_inclusion_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_inclusion_of on the interactor class' context class.
-
.context_validates_length_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_length_of on the interactor class' context class.
-
.context_validates_numericality_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_numericality_of on the interactor class' context class.
-
.context_validates_presence_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_presence_of on the interactor class' context class.
-
.context_validates_size_of(*attr_names) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_size_of on the interactor class' context class.
-
.context_validates_with(*args, &block) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validates_with on the interactor class' context class.
-
.context_validators ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validators on the interactor class' context class.
-
.context_validators_on(*attributes) ⇒ Object
extended
from Interactor::Context::ClassMethods
Call .validators_on on the interactor class' context class.
-
.contextualize_with(klass) ⇒ Const
extended
from Interactor::Context::ClassMethods
Set the interactor class' context class.
-
.defer_after_callbacks_when_organized ⇒ Object
extended
from Interactor::Callbacks::ClassMethods
Set after_callbacks_deferred_when_organized to
true
. -
.perform(context = {}, options = {}) ⇒ Class
extended
from Interactor::Perform::ClassMethods
Initialize a new interactor instance and call its #perform method.
-
.perform!(context = {}, options = {}) ⇒ Class
extended
from Interactor::Perform::ClassMethods
Initialize a new interactor instance and call its #perform method without rescuing Error::ContextFailure.
Instance Method Summary collapse
-
#context_attribute_missing(match, *args, &block) ⇒ Object
included
from Interactor::Context
Call #attribute_missing on the interactor instance's context instance.
-
#context_attribute_names ⇒ Object
included
from Interactor::Context
Call #attribute_names on the interactor instance's context instance.
-
#context_errors ⇒ Object
included
from Interactor::Context
Call #errors on the interactor instance's context instance.
-
#context_fail!(errors = nil) ⇒ Object
included
from Interactor::Context
Call #fail! on the interactor instance's context instance.
-
#context_invalid?(context = nil) ⇒ Object
included
from Interactor::Context
Call #invalid? on the interactor instance's context instance.
-
#context_respond_to_without_attributes?(method, include_private_methods = false) ⇒ Object
included
from Interactor::Context
Call #respond_to_without_attributes? on the interactor instance's context instance.
-
#context_rollback! ⇒ Object
included
from Interactor::Context
Call #rollback! on the interactor instance's context instance.
-
#context_valid?(context = nil) ⇒ Object
included
from Interactor::Context
Call #valid? on the interactor instance's context instance.
-
#context_validate(context = nil) ⇒ Object
included
from Interactor::Context
Call #validate on the interactor instance's context instance.
-
#context_validate!(context = nil) ⇒ Object
included
from Interactor::Context
Call #validate! on the interactor instance's context instance.
-
#context_validates_absence_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_absence_of on the interactor instance's context instance.
-
#context_validates_acceptance_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_acceptance_of on the interactor instance's context instance.
-
#context_validates_confirmation_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_confirmation_of on the interactor instance's context instance.
-
#context_validates_exclusion_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_exclusion_of on the interactor instance's context instance.
-
#context_validates_format_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_format_of on the interactor instance's context instance.
-
#context_validates_inclusion_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_inclusion_of on the interactor instance's context instance.
-
#context_validates_length_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_length_of on the interactor instance's context instance.
-
#context_validates_numericality_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_numericality_of on the interactor instance's context instance.
-
#context_validates_presence_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_presence_of on the interactor instance's context instance.
-
#context_validates_size_of(*attr_names) ⇒ Object
included
from Interactor::Context
Call #validates_size_of on the interactor instance's context instance.
-
#context_validates_with(*args, &block) ⇒ Object
included
from Interactor::Context
Call #validates_with on the interactor instance's context instance.
-
#deep_dup ⇒ Base
included
from Interactor::Perform
Duplicate an interactor instance as well as it's Interactor::Perform#options and context instances.
-
#execute_perform ⇒ Object
included
from Interactor::Perform
private
Run the interactor instance's Interactor::Perform::ClassMethods#perform with callbacks and validation.
-
#execute_perform! ⇒ Object
included
from Interactor::Perform
private
Run the interactor instance's Interactor::Perform::ClassMethods#perform with callbacks and validation without rescuing Error::ContextFailure.
-
#finalize_context! ⇒ Class
included
from Interactor::Context
Mark the interactor instance as called on the instance's context instance and return the context instance.
-
#initialize(context = {}) ⇒ Base
included
from Interactor::Context
Initialize a new instance of Base.
-
#options ⇒ Options
included
from Interactor::Perform
Options for the interactor Interactor::Perform::ClassMethods#perform.
-
#perform ⇒ Object
included
from Interactor::Perform
abstract
The steps to run when an interactor is called.
-
#rollback ⇒ Object
included
from Interactor::Perform
abstract
The steps to run when an interactor fails.
- #with_options(options) ⇒ self included from Interactor::Perform private
Class Method Details
.after_context_validation(*args, &block) ⇒ Object Originally defined in module Interactor::Callbacks::ClassMethods
Define a callback to call after validation has been run on an interactor instance's context instance.
.after_perform(*filters, &block) ⇒ Object Originally defined in module Interactor::Callbacks::ClassMethods
Define a callback to call after #perform has been called on an interactor instance.
.after_rollback(*filters, &block) ⇒ Object Originally defined in module Interactor::Callbacks::ClassMethods
Define a callback to call after #rollback has been called on an interactor instance.
.around_perform(*filters, &block) ⇒ Object Originally defined in module Interactor::Callbacks::ClassMethods
Define a callback to call around #perform invokation on an interactor instance.
.around_rollback(*filters, &block) ⇒ Object Originally defined in module Interactor::Callbacks::ClassMethods
Define a callback to call around #rollback invokation on an interactor instance.
.before_context_validation(*args, &block) ⇒ Object Originally defined in module Interactor::Callbacks::ClassMethods
Define a callback to call before validation has been run on an interactor instance's context instance.
.before_perform(*filters, &block) ⇒ Object Originally defined in module Interactor::Callbacks::ClassMethods
Define a callback to call before #perform has been called on an interactor instance
.before_rollback(*filters, &block) ⇒ Object Originally defined in module Interactor::Callbacks::ClassMethods
Define a callback to call before #rollback has been called on an interactor instance.
.context_attribute(name, type = Type::Value.new, **options) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .attribute on the interactor class' context class
.context_attribute_method?(attribute) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .attribute_method? on the interactor class' context class
.context_attribute_missing(match, *args, &block) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .attribute_missing on the interactor class' context class
.context_attribute_names ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .attribute_names on the interactor class' context class
.context_attributes(*attributes) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .attributes on the interactor class' context class
.context_class ⇒ Const Originally defined in module Interactor::Context::ClassMethods
Get the interactor class' context class. If no class is found or no class is set via the #contextualize_with method a new class is created.
.context_clear_validators!(attribute) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .clear_validators! on the interactor class' context class
.context_respond_to_without_attributes?(method, include_private_methods = false) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .respond_to_without_attributes? on the interactor class' context class
.context_validate(*args, &block) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validate on the interactor class' context class
.context_validates(*attributes) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates on the interactor class' context class
.context_validates!(*attributes) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates! on the interactor class' context class
.context_validates_absence_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_absence_of on the interactor class' context class
.context_validates_acceptance_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_acceptance_of on the interactor class' context class
.context_validates_confirmation_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_confirmation_of on the interactor class' context class
.context_validates_each(*attr_names, &block) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_each on the interactor class' context class
.context_validates_exclusion_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_exclusion_of on the interactor class' context class
.context_validates_format_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_format_of on the interactor class' context class
.context_validates_inclusion_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_inclusion_of on the interactor class' context class
.context_validates_length_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_length_of on the interactor class' context class
.context_validates_numericality_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_numericality_of on the interactor class' context class
.context_validates_presence_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_presence_of on the interactor class' context class
.context_validates_size_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_size_of on the interactor class' context class
.context_validates_with(*args, &block) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validates_with on the interactor class' context class
.context_validators ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validators on the interactor class' context class
.context_validators_on(*attributes) ⇒ Object Originally defined in module Interactor::Context::ClassMethods
Call .validators_on on the interactor class' context class
.contextualize_with(klass) ⇒ Const Originally defined in module Interactor::Context::ClassMethods
Set the interactor class' context class
.defer_after_callbacks_when_organized ⇒ Object Originally defined in module Interactor::Callbacks::ClassMethods
Set after_callbacks_deferred_when_organized to true
.perform(context = {}, options = {}) ⇒ Class Originally defined in module Interactor::Perform::ClassMethods
Initialize a new interactor instance and call its #perform method. This is the default api to interact with all interactors.
.perform!(context = {}, options = {}) ⇒ Class Originally defined in module Interactor::Perform::ClassMethods
Initialize a new interactor instance and call its #perform method without rescuing Error::ContextFailure.
Instance Method Details
#context_attribute_missing(match, *args, &block) ⇒ Object Originally defined in module Interactor::Context
Call #attribute_missing on the interactor instance's context instance
#context_attribute_names ⇒ Object Originally defined in module Interactor::Context
Call #attribute_names on the interactor instance's context instance
#context_errors ⇒ Object Originally defined in module Interactor::Context
Call #errors on the interactor instance's context instance
#context_fail!(errors = nil) ⇒ Object Originally defined in module Interactor::Context
Call #fail! on the interactor instance's context instance
#context_invalid?(context = nil) ⇒ Object Originally defined in module Interactor::Context
Call #invalid? on the interactor instance's context instance
#context_respond_to_without_attributes?(method, include_private_methods = false) ⇒ Object Originally defined in module Interactor::Context
Call #respond_to_without_attributes? on the interactor instance's context instance
#context_rollback! ⇒ Object Originally defined in module Interactor::Context
Call #rollback! on the interactor instance's context instance
#context_valid?(context = nil) ⇒ Object Originally defined in module Interactor::Context
Call #valid? on the interactor instance's context instance
#context_validate(context = nil) ⇒ Object Originally defined in module Interactor::Context
Call #validate on the interactor instance's context instance
#context_validate!(context = nil) ⇒ Object Originally defined in module Interactor::Context
Call #validate! on the interactor instance's context instance
#context_validates_absence_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_absence_of on the interactor instance's context instance
#context_validates_acceptance_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_acceptance_of on the interactor instance's context instance
#context_validates_confirmation_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_confirmation_of on the interactor instance's context instance
#context_validates_exclusion_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_exclusion_of on the interactor instance's context instance
#context_validates_format_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_format_of on the interactor instance's context instance
#context_validates_inclusion_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_inclusion_of on the interactor instance's context instance
#context_validates_length_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_length_of on the interactor instance's context instance
#context_validates_numericality_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_numericality_of on the interactor instance's context instance
#context_validates_presence_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_presence_of on the interactor instance's context instance
#context_validates_size_of(*attr_names) ⇒ Object Originally defined in module Interactor::Context
Call #validates_size_of on the interactor instance's context instance
#context_validates_with(*args, &block) ⇒ Object Originally defined in module Interactor::Context
Call #validates_with on the interactor instance's context instance
#deep_dup ⇒ Base Originally defined in module Interactor::Perform
Duplicate an interactor instance as well as it's #options and context instances.
#execute_perform ⇒ Object Originally defined in module Interactor::Perform
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run the interactor instance's #perform with callbacks and validation.
#execute_perform! ⇒ Object Originally defined in module Interactor::Perform
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run the interactor instance's #perform with callbacks and validation without rescuing Error::ContextFailure.
#finalize_context! ⇒ Class Originally defined in module Interactor::Context
Mark the interactor instance as called on the instance's context instance and return the context instance.
#initialize(context = {}) ⇒ Base Originally defined in module Interactor::Context
Initialize a new instance of Base
#options ⇒ Options Originally defined in module Interactor::Perform
Options for the interactor #perform
#perform ⇒ Object Originally defined in module Interactor::Perform
interactors should override #perform with the appropriate steps and context mutations required for the interactor to do its work.
The steps to run when an interactor is called. An interactor's #perform method should never be called directly on an interactor instance and should instead be invoked by the interactor's class method .perform.
#rollback ⇒ Object Originally defined in module Interactor::Perform
interactors should override #rollback with the appropriate steps and context mutations required for the interactor to roll back its work.
The steps to run when an interactor fails. An interactor's #rollback method should never be called directly and is instead called by the interactor's context when #fail is called.
#with_options(options) ⇒ self Originally defined in module Interactor::Perform
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set options for an interactor's #perform