Module: ActiveInteractor::Interactor

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/perform_options.rb

Overview

Interactor methods. Base includes Interactor all interactors should inherit from Base.

Author:

Since:

  • 0.0.1

Defined Under Namespace

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Since:

  • 0.0.1


9
10
11
12
13
14
15
16
# File 'lib/active_interactor/interactor.rb', line 9

def self.included(base)
  base.class_eval do
    extend ClassMethods
    include Callbacks
    include Context
    delegate :execute_perform, :execute_perform!, to: :worker
  end
end

Instance Method Details

#optionsPerformOptions

Options for invokation of #perform

Returns:

Since:

  • 1.0.0


53
54
55
# File 'lib/active_interactor/interactor.rb', line 53

def options
  @options ||= PerformOptions.new
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


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

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


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

def rollback; end

#with_options(options) ⇒ Base

Set options for invokation of #perform

Parameters:

Returns:

Since:

  • 1.0.0


71
72
73
74
# File 'lib/active_interactor/interactor.rb', line 71

def with_options(options)
  @options = options.is_a?(PerformOptions) ? options : PerformOptions.new(options)
  self
end