Class: RailsErrorDashboard::Commands::ResolveError

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

Overview

Command: Mark an error as resolved This is a write operation that updates an ErrorLog record

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_id, resolution_data = {}) ⇒ ResolveError

Returns a new instance of ResolveError.



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

def initialize(error_id, resolution_data = {})
  @error_id = error_id
  @resolution_data = resolution_data
end

Class Method Details

.call(error_id, resolution_data = {}) ⇒ Object



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

def self.call(error_id, resolution_data = {})
  new(error_id, resolution_data).call
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rails_error_dashboard/commands/resolve_error.rb', line 17

def call
  error = ErrorLog.find(@error_id)

  error.update!(
    resolved: true,
    resolved_at: Time.current,
    resolved_by_name: @resolution_data[:resolved_by_name],
    resolution_comment: @resolution_data[:resolution_comment],
    resolution_reference: @resolution_data[:resolution_reference]
  )

  # Dispatch plugin event for resolved error
  PluginRegistry.dispatch(:on_error_resolved, error)

  error
end