Class: RailsErrorDashboard::Commands::AssignError

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

Overview

Command: Assign an error to a user This is a write operation that updates assignment fields on an ErrorLog record

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_id, assigned_to) ⇒ AssignError

Returns a new instance of AssignError.



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

def initialize(error_id, assigned_to)
  @error_id = error_id
  @assigned_to = assigned_to
end

Class Method Details

.call(error_id, assigned_to:) ⇒ Object



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

def self.call(error_id, assigned_to:)
  new(error_id, assigned_to).call
end

Instance Method Details

#callObject



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

def call
  error = ErrorLog.find(@error_id)
  error.update!(
    assigned_to: @assigned_to,
    assigned_at: Time.current,
    status: "in_progress" # Auto-transition to in_progress when assigned
  )
  error
end