Class: RailsErrorDashboard::Commands::UpdateErrorStatus
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Commands::UpdateErrorStatus
- Defined in:
- lib/rails_error_dashboard/commands/update_error_status.rb
Overview
Command: Update the status of an error with optional comment This is a write operation that validates transitions and updates status Returns bool, error: ErrorLog
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(error_id, status, comment) ⇒ UpdateErrorStatus
constructor
A new instance of UpdateErrorStatus.
Constructor Details
#initialize(error_id, status, comment) ⇒ UpdateErrorStatus
Returns a new instance of UpdateErrorStatus.
13 14 15 16 17 |
# File 'lib/rails_error_dashboard/commands/update_error_status.rb', line 13 def initialize(error_id, status, comment) @error_id = error_id @status = status @comment = comment end |
Class Method Details
.call(error_id, status:, comment: nil) ⇒ Object
9 10 11 |
# File 'lib/rails_error_dashboard/commands/update_error_status.rb', line 9 def self.call(error_id, status:, comment: nil) new(error_id, status, comment).call end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rails_error_dashboard/commands/update_error_status.rb', line 19 def call error = ErrorLog.find(@error_id) unless error.can_transition_to?(@status) return { success: false, error: error } end error.transaction do error.update!(status: @status) # Auto-resolve if status is "resolved" error.update!(resolved: true) if @status == "resolved" # Add comment about status change if @comment.present? error.comments.create!( author_name: error.assigned_to || "System", body: "Status changed to #{@status}: #{@comment}" ) end end { success: true, error: error } end |