Class: RailsErrorDashboard::Commands::SnoozeError
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Commands::SnoozeError
- Defined in:
- lib/rails_error_dashboard/commands/snooze_error.rb
Overview
Command: Snooze an error for a given number of hours This is a write operation that sets snoozed_until and optionally creates a comment
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(error_id, hours, reason) ⇒ SnoozeError
constructor
A new instance of SnoozeError.
Constructor Details
#initialize(error_id, hours, reason) ⇒ SnoozeError
Returns a new instance of SnoozeError.
12 13 14 15 16 |
# File 'lib/rails_error_dashboard/commands/snooze_error.rb', line 12 def initialize(error_id, hours, reason) @error_id = error_id @hours = hours @reason = reason end |
Class Method Details
.call(error_id, hours:, reason: nil) ⇒ Object
8 9 10 |
# File 'lib/rails_error_dashboard/commands/snooze_error.rb', line 8 def self.call(error_id, hours:, reason: nil) new(error_id, hours, reason).call end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rails_error_dashboard/commands/snooze_error.rb', line 18 def call error = ErrorLog.find(@error_id) snooze_until = @hours.hours.from_now # Store snooze reason in comments if provided if @reason.present? error.comments.create!( author_name: error.assigned_to || "System", body: "Snoozed for #{@hours} hours: #{@reason}" ) end error.update!(snoozed_until: snooze_until) error end |