Class: Collavre::Comments::ActionExecutor

Inherits:
Object
  • Object
show all
Defined in:
app/services/collavre/comments/action_executor.rb

Defined Under Namespace

Classes: ExecutionContext, ExecutionError

Instance Method Summary collapse

Constructor Details

#initialize(comment:, executor:) ⇒ ActionExecutor

Returns a new instance of ActionExecutor.



8
9
10
11
# File 'app/services/collavre/comments/action_executor.rb', line 8

def initialize(comment:, executor:)
  @comment = comment
  @executor = executor
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/collavre/comments/action_executor.rb', line 13

def call
  comment.with_lock do
    prepare_for_execution!

    execute_within_transaction!
  end
rescue ExecutionError
  raise
rescue StandardError, ScriptError => e
  Rails.logger.error("Comment action execution failed: #{e.class} #{e.message}")
  raise ExecutionError, I18n.t("collavre.comments.approve_execution_failed", message: e.message)
end