Class: RailsErrorDashboard::Commands::AddErrorComment

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_error_dashboard/commands/add_error_comment.rb

Overview

Command: Add a comment to an error This is a write operation that creates an ErrorComment record

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_id, author_name, body) ⇒ AddErrorComment

Returns a new instance of AddErrorComment.



12
13
14
15
16
# File 'lib/rails_error_dashboard/commands/add_error_comment.rb', line 12

def initialize(error_id, author_name, body)
  @error_id = error_id
  @author_name = author_name
  @body = body
end

Class Method Details

.call(error_id, author_name:, body:) ⇒ Object



8
9
10
# File 'lib/rails_error_dashboard/commands/add_error_comment.rb', line 8

def self.call(error_id, author_name:, body:)
  new(error_id, author_name, body).call
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
# File 'lib/rails_error_dashboard/commands/add_error_comment.rb', line 18

def call
  error = ErrorLog.find(@error_id)
  error.comments.create!(
    author_name: @author_name,
    body: @body
  )
  error
end