Class: RailsErrorDashboard::Commands::MuteError
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Commands::MuteError
- Defined in:
- lib/rails_error_dashboard/commands/mute_error.rb
Overview
Command: Mute notifications for an error Muted errors still appear in the dashboard but do not trigger any notifications.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(error_id, muted_by, reason) ⇒ MuteError
constructor
A new instance of MuteError.
Constructor Details
#initialize(error_id, muted_by, reason) ⇒ MuteError
Returns a new instance of MuteError.
12 13 14 15 16 |
# File 'lib/rails_error_dashboard/commands/mute_error.rb', line 12 def initialize(error_id, muted_by, reason) @error_id = error_id @muted_by = muted_by @reason = reason end |
Class Method Details
.call(error_id, muted_by: nil, reason: nil) ⇒ Object
8 9 10 |
# File 'lib/rails_error_dashboard/commands/mute_error.rb', line 8 def self.call(error_id, muted_by: nil, reason: nil) new(error_id, muted_by, reason).call end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rails_error_dashboard/commands/mute_error.rb', line 18 def call error = ErrorLog.find(@error_id) if @reason.present? error.comments.create!( author_name: @muted_by || "System", body: "Muted notifications: #{@reason}" ) end error.update!( muted: true, muted_at: Time.current, muted_by: @muted_by, muted_reason: @reason ) PluginRegistry.dispatch(:on_error_muted, error) error end |