Class: ActiveInteractor::Organizer
- Defined in:
- lib/active_interactor/organizer.rb
Overview
The Base Interactor class inherited by all Interactor::Organizers
Class Method Summary collapse
-
.after_each_perform(*filters, &block) ⇒ Object
Define a callback to call after each organized interactor’s Base.perform has been invoked.
-
.around_each_perform(*filters, &block) ⇒ Object
Define a callback to call around each organized interactor’s Base.perform has been invokation.
-
.before_each_perform(*filters, &block) ⇒ Object
Define a callback to call before each organized interactor’s Base.perform has been invoked.
-
.organize(*interactors) ⇒ Object
Declare Interactors to be invoked as part of the organizer’s invocation.
-
.organized ⇒ Array<ActiveInteractor::Base] the organized interactors
An Array of declared Interactors to be invoked.
Instance Method Summary collapse
-
#perform ⇒ Object
Invoke the organized interactors.
Methods inherited from Base
Methods included from Interactor
#fail_on_invalid_context?, #rollback, #should_clean_context?, #skip_clean_context!
Constructor Details
This class inherits a constructor from ActiveInteractor::Base
Class Method Details
.after_each_perform(*filters, &block) ⇒ Object
Define a callback to call after each organized interactor’s
{ActiveInteractor::Base.perform} has been invoked
51 52 53 |
# File 'lib/active_interactor/organizer.rb', line 51 def after_each_perform(*filters, &block) set_callback(:each_perform, :after, *filters, &block) end |
.around_each_perform(*filters, &block) ⇒ Object
Define a callback to call around each organized interactor’s
{ActiveInteractor::Base.perform} has been invokation
97 98 99 |
# File 'lib/active_interactor/organizer.rb', line 97 def around_each_perform(*filters, &block) set_callback(:each_perform, :around, *filters, &block) end |
.before_each_perform(*filters, &block) ⇒ Object
Define a callback to call before each organized interactor’s
{ActiveInteractor::Base.perform} has been invoked
139 140 141 |
# File 'lib/active_interactor/organizer.rb', line 139 def before_each_perform(*filters, &block) set_callback(:each_perform, :before, *filters, &block) end |
.organize(*interactors) ⇒ Object
Declare Interactors to be invoked as part of the
organizer's invocation. These interactors are invoked in
the order in which they are declared
157 158 159 |
# File 'lib/active_interactor/organizer.rb', line 157 def organize(*interactors) @organized = interactors.flatten end |
.organized ⇒ Array<ActiveInteractor::Base] the organized interactors
An Array of declared Interactors to be invoked
163 164 165 |
# File 'lib/active_interactor/organizer.rb', line 163 def organized @organized ||= [] end |
Instance Method Details
#perform ⇒ Object
Invoke the organized interactors. An organizer is
expected not to define its own {ActiveInteractor::Interactor#perform #perform} method
in favor of this default implementation.
171 172 173 174 175 176 177 178 179 |
# File 'lib/active_interactor/organizer.rb', line 171 def perform self.class.organized.each do |interactor| run_callbacks :each_perform do self.context = interactor.new(context) .tap(&:skip_clean_context!) .execute_perform! end end end |