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

Author:

Since:

  • 0.0.1

Version:

  • 0.1

Defined Under Namespace

Modules: Callbacks, ClassMethods, Context, Execution Classes: Worker

Instance Method Summary collapse

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.

Returns:

  • (Boolean)

    ‘true` if the context should fail `false` if it should not.

Since:

  • 0.0.1



59
60
61
# File 'lib/active_interactor/interactor.rb', line 59

def fail_on_invalid_context?
  self.class.__fail_on_invalid_context
end

#performObject

This method is abstract.

It is expected that the #perform method is overwritten for each interactor class.

Invoke an Interactor instance without any hooks, tracking, or rollback

Since:

  • 0.0.1



66
# File 'lib/active_interactor/interactor.rb', line 66

def perform; end

#rollbackObject

This method is abstract.

Any interactor class that requires undoing upon downstream failure is expected to overwrite the #rollback method.

Reverse prior invocation of an Interactor instance.

Since:

  • 0.0.1



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`.

Returns:

  • (Boolean)

    ‘true` if the context should be cleaned `false` if it should not be cleaned.

Since:

  • 0.0.1



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