Class: Decidim::Notify::DeleteChapter
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Notify::DeleteChapter
- Defined in:
- app/commands/decidim/notify/delete_chapter.rb
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(id) ⇒ DeleteChapter
constructor
Public: Initializes the command.
Constructor Details
#initialize(id) ⇒ DeleteChapter
Public: Initializes the command.
8 9 10 |
# File 'app/commands/decidim/notify/delete_chapter.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_chapter.rb', line 18 def call chapter = Chapter.for(current_component).find(@id) chapter.destroy! broadcast(:ok) rescue ActiveRecord::ActiveRecordError => e broadcast(:invalid, e.) end |