Class: Decidim::Notify::UpdateChapter
- Inherits:
-
Admin::UpdateChapter
- Object
- Admin::UpdateChapter
- Decidim::Notify::UpdateChapter
- Defined in:
- app/commands/decidim/notify/update_chapter.rb
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form) ⇒ UpdateChapter
constructor
Public: Initializes the command.
Constructor Details
#initialize(form) ⇒ UpdateChapter
Public: Initializes the command.
form - A config form
9 10 11 |
# File 'app/commands/decidim/notify/update_chapter.rb', line 9 def initialize(form) @form = form 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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/commands/decidim/notify/update_chapter.rb', line 19 def call return broadcast(:invalid) if form.invalid? begin @chapter = Chapter.find(form.id) unset_actives update_chapter! broadcast(:ok, @chapter) rescue ActiveRecord::ActiveRecordError => e broadcast(:invalid, e.) end end |