Class: ActiveInteractor::Interactor::Worker Private

Inherits:
Object
  • Object
show all
Defined in:
lib/active_interactor/interactor/worker.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A worker class to call interactor #perform and #rollback methods in a thread safe manner.

Author:

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(interactor) ⇒ Worker

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a new instance of ActiveInteractor::Interactor::Worker

Parameters:

Since:

  • 0.1.0



16
17
18
# File 'lib/active_interactor/interactor/worker.rb', line 16

def initialize(interactor)
  @interactor = interactor.deep_dup
end

Instance Method Details

#execute_performClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run the interactor instance's #perform with callbacks and validation.

Returns:

Since:

  • 0.1.0



23
24
25
26
27
28
# File 'lib/active_interactor/interactor/worker.rb', line 23

def execute_perform
  execute_perform!
rescue Error::ContextFailure => e
  ActiveInteractor.logger.error("ActiveInteractor: #{e}")
  context
end

#execute_perform!Class

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run the interactor instance's #perform with callbacks and validation without rescuing Error::ContextFailure.

Returns:

Raises:

Since:

  • 0.1.0



35
36
37
38
39
# File 'lib/active_interactor/interactor/worker.rb', line 35

def execute_perform!
  execute_context!
rescue StandardError => e
  handle_error(e)
end

#execute_rollbackBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run the interactor instance's #rollback with callbacks

Returns:

  • (Boolean)

    true if context was successfully rolled back

Since:

  • 0.1.0



44
45
46
47
48
# File 'lib/active_interactor/interactor/worker.rb', line 44

def execute_rollback
  return if interactor.options.skip_rollback

  execute_interactor_rollback!
end