Class: Decidim::Notify::DeleteNote
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Notify::DeleteNote
- Defined in:
- app/commands/decidim/notify/delete_note.rb
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(id) ⇒ DeleteNote
constructor
Public: Initializes the command.
Constructor Details
#initialize(id) ⇒ DeleteNote
Public: Initializes the command.
8 9 10 |
# File 'app/commands/decidim/notify/delete_note.rb', line 8 def initialize(id) @id = id end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if we couldn’t proceed.
Returns nothing.
18 19 20 21 22 23 24 25 |
# File 'app/commands/decidim/notify/delete_note.rb', line 18 def call note = Note.for(current_component).find(@id) note.destroy! broadcast(:ok) rescue ActiveRecord::ActiveRecordError => e broadcast(:invalid, e.) end |