Module: ActiveInteractor::Interactor
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/active_interactor/interactor.rb,
lib/active_interactor/interactor/worker.rb,
lib/active_interactor/interactor/context.rb,
lib/active_interactor/interactor/callbacks.rb,
lib/active_interactor/interactor/execution.rb
Overview
Provides interactor methods to included classes
Defined Under Namespace
Modules: Callbacks, ClassMethods, Context, Execution Classes: Worker
Instance Method Summary collapse
-
#fail_on_invalid_context? ⇒ Boolean
Whether or not the context should fail when invalid this will return false if Callbacks::ClassMethods#allow_context_to_be_invalid has been invoked on the class.
-
#perform ⇒ Object
abstract
Invoke an Interactor instance without any hooks, tracking, or rollback.
-
#rollback ⇒ Object
abstract
Reverse prior invocation of an Interactor instance.
-
#should_clean_context? ⇒ Boolean
Whether or not the context should be cleaned after #perform if #skip_clean_context! has not been invoked on the instance and Callbacks::ClassMethods#clean_context_on_completion is invoked on the class this will return ‘true`.
-
#skip_clean_context! ⇒ Boolean
Skip #clean! on an interactor context that calls the {Callbacks.clean_context_on_completion class method. This method is meant to be invoked by organizer interactors to ensure contexts are approriately passed between interactors..
Instance Method Details
#fail_on_invalid_context? ⇒ Boolean
Whether or not the context should fail when invalid
this will return false if
{Interactor::Callbacks::ClassMethods#allow_context_to_be_invalid}
has been invoked on the class.
59 60 61 |
# File 'lib/active_interactor/interactor.rb', line 59 def fail_on_invalid_context? self.class.__fail_on_invalid_context end |
#perform ⇒ Object
It is expected that the #perform method is overwritten for each interactor class.
Invoke an Interactor instance without any hooks, tracking, or rollback
66 |
# File 'lib/active_interactor/interactor.rb', line 66 def perform; end |
#rollback ⇒ Object
Any interactor class that requires undoing upon downstream failure is expected to overwrite the #rollback method.
Reverse prior invocation of an Interactor instance.
71 |
# File 'lib/active_interactor/interactor.rb', line 71 def rollback; end |
#should_clean_context? ⇒ Boolean
Whether or not the context should be cleaned after #perform
if {#skip_clean_context!} has not been invoked on the instance
and {Interactor::Callbacks::ClassMethods#clean_context_on_completion}
is invoked on the class this will return `true`.
80 81 82 |
# File 'lib/active_interactor/interactor.rb', line 80 def should_clean_context? @should_clean_context.nil? && self.class.__clean_after_perform end |
#skip_clean_context! ⇒ Boolean
context that calls the {Callbacks.clean_context_on_completion</a></span> class method.
This method is meant to be invoked by organizer interactors
to ensure contexts are approriately passed between interactors.
91 92 93 |
# File 'lib/active_interactor/interactor.rb', line 91 def skip_clean_context! @should_clean_context = false end |