Module: ActiveInteractor::Interactor::Callbacks::ClassMethods
- Included in:
- Base
- Defined in:
- lib/active_interactor/interactor/callbacks.rb
Overview
Interactor callback class methods. Because ClassMethods is a module classes should extend ClassMethods rather than inherit from it.
Class Method Summary collapse
Instance Method Summary collapse
-
#after_context_validation(*args, &block) ⇒ Object
Define a callback to call after validation has been run on an interactor instance’s context instance.
-
#after_perform(*filters, &block) ⇒ Object
Define a callback to call after #perform has been called on an interactor instance.
-
#after_rollback(*filters, &block) ⇒ Object
Define a callback to call after #rollback has been called on an interactor instance.
-
#around_perform(*filters, &block) ⇒ Object
Define a callback to call around #perform invokation on an interactor instance.
-
#around_rollback(*filters, &block) ⇒ Object
Define a callback to call around #rollback invokation on an interactor instance.
-
#before_context_validation(*args, &block) ⇒ Object
Define a callback to call before validation has been run on an interactor instance’s context instance.
-
#before_perform(*filters, &block) ⇒ Object
Define a callback to call before #perform has been called on an interactor instance.
-
#before_rollback(*filters, &block) ⇒ Object
Define a callback to call before #rollback has been called on an interactor instance.
-
#defer_after_callbacks_when_organized ⇒ Object
Set after_callbacks_deferred_when_organized to
true
.
Class Method Details
.extended(base) ⇒ Object
264 265 266 267 268 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 264 def self.extended(base) base.class_eval do class_attribute :after_callbacks_deferred_when_organized, instance_writer: false, default: false end end |
Instance Method Details
#after_context_validation(*args, &block) ⇒ Object
Define a callback to call after validation has been run on an interactor instance’s context instance.
41 42 43 44 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 41 def after_context_validation(*args, &block) = (args..dup.merge(prepend: true)) set_callback(:validation, :after, *args, , &block) end |
#after_perform(*filters, &block) ⇒ Object
Define a callback to call after #perform has been called on an interactor instance.
68 69 70 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 68 def after_perform(*filters, &block) set_callback(:perform, :after, *filters, &block) end |
#after_rollback(*filters, &block) ⇒ Object
Define a callback to call after #rollback has been called on an interactor instance.
98 99 100 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 98 def after_rollback(*filters, &block) set_callback(:rollback, :after, *filters, &block) end |
#around_perform(*filters, &block) ⇒ Object
Define a callback to call around #perform invokation on an interactor instance.
128 129 130 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 128 def around_perform(*filters, &block) set_callback(:perform, :around, *filters, &block) end |
#around_rollback(*filters, &block) ⇒ Object
Define a callback to call around #rollback invokation on an interactor instance.
162 163 164 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 162 def around_rollback(*filters, &block) set_callback(:rollback, :around, *filters, &block) end |
#before_context_validation(*args, &block) ⇒ Object
Define a callback to call before validation has been run on an interactor instance’s context instance.
191 192 193 194 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 191 def before_context_validation(*args, &block) = (args..dup) set_callback(:validation, :before, *args, , &block) end |
#before_perform(*filters, &block) ⇒ Object
Define a callback to call before #perform has been called on an interactor instance
218 219 220 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 218 def before_perform(*filters, &block) set_callback(:perform, :before, *filters, &block) end |
#before_rollback(*filters, &block) ⇒ Object
Define a callback to call before #rollback has been called on an interactor instance.
248 249 250 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 248 def before_rollback(*filters, &block) set_callback(:rollback, :before, *filters, &block) end |
#defer_after_callbacks_when_organized ⇒ Object
Set after_callbacks_deferred_when_organized to true
260 261 262 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 260 def defer_after_callbacks_when_organized self.after_callbacks_deferred_when_organized = true end |