Class: Collavre::Comments::CommandProcessor

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

Instance Method Summary collapse

Constructor Details

#initialize(comment:, user:) ⇒ CommandProcessor

Returns a new instance of CommandProcessor.



4
5
6
7
# File 'app/services/collavre/comments/command_processor.rb', line 4

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

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
# File 'app/services/collavre/comments/command_processor.rb', line 9

def call
  command_handlers.each do |command|
    result = command.call
    return result if result.present?
  end
  nil
rescue StandardError => e
  Rails.logger.error("Comment command processing failed: #{e.message}")
  e.message
end