Module: ActiveInteractor::Interactor::Callbacks::ClassMethods
- Defined in:
- lib/active_interactor/interactor/callbacks.rb
Overview
Instance Method Summary collapse
-
#after_context_validation(*args, &block) ⇒ Object
Define a callback to call after ‘#valid?` has been invoked on an interactor’s context.
-
#after_perform(*filters, &block) ⇒ Object
Define a callback to call after Base.perform has been invoked.
-
#after_rollback(*filters, &block) ⇒ Object
Define a callback to call after Base#rollback has been invoked.
-
#allow_context_to_be_invalid ⇒ Object
By default an interactor context will fail if it is deemed invalid before or after the Base.perform method is invoked.
-
#around_perform(*filters, &block) ⇒ Object
Define a callback to call around Base.perform invokation.
-
#around_rollback(*filters, &block) ⇒ Object
Define a callback to call around Base#rollback invokation.
-
#before_context_validation(*args, &block) ⇒ Object
Define a callback to call before ‘#valid?` has been invoked on an interactor’s context.
-
#before_perform(*filters, &block) ⇒ Object
Define a callback to call before Base.perform has been invoked.
-
#before_rollback(*filters, &block) ⇒ Object
Define a callback to call before Base#rollback has been invoked.
-
#clean_context_on_completion ⇒ Object
Calling this method on an interactor class will invoke Context::Base#clean! on the interactor’s context instance after Base.perform is invoked.
Instance Method Details
#after_context_validation(*args, &block) ⇒ Object
Define a callback to call after ‘#valid?` has been invoked on an
interactor's context
53 54 55 56 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 53 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 Base.perform has been invoked
77 78 79 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 77 def after_perform(*filters, &block) set_callback(:perform, :after, *filters, &block) end |
#after_rollback(*filters, &block) ⇒ Object
Define a callback to call after Base#rollback has been invoked
102 103 104 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 102 def after_rollback(*filters, &block) set_callback(:rollback, :after, *filters, &block) end |
#allow_context_to_be_invalid ⇒ Object
By default an interactor context will fail if it is deemed
invalid before or after the {ActiveInteractor::Base.perform} method
is invoked. Calling this method on an interactor class
will not invoke {ActiveInteractor::Context::Base#fail!} if the
context is invalid.
111 112 113 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 111 def allow_context_to_be_invalid self.__fail_on_invalid_context = false end |
#around_perform(*filters, &block) ⇒ Object
Define a callback to call around Base.perform invokation
140 141 142 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 140 def around_perform(*filters, &block) set_callback(:perform, :around, *filters, &block) end |
#around_rollback(*filters, &block) ⇒ Object
Define a callback to call around Base#rollback invokation
172 173 174 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 172 def around_rollback(*filters, &block) set_callback(:rollback, :around, *filters, &block) end |
#before_context_validation(*args, &block) ⇒ Object
Define a callback to call before ‘#valid?` has been invoked on an
interactor's context
197 198 199 200 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 197 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 Base.perform has been invoked
221 222 223 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 221 def before_perform(*filters, &block) set_callback(:perform, :before, *filters, &block) end |
#before_rollback(*filters, &block) ⇒ Object
Define a callback to call before Base#rollback has been invoked
247 248 249 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 247 def before_rollback(*filters, &block) set_callback(:rollback, :before, *filters, &block) end |
#clean_context_on_completion ⇒ Object
Calling this method on an interactor class will invoke
{ActiveInteractor::Context::Base#clean!} on the interactor's
context instance after {ActiveInteractor::Base.perform}
is invoked.
255 256 257 |
# File 'lib/active_interactor/interactor/callbacks.rb', line 255 def clean_context_on_completion self.__clean_after_perform = true end |