Class: Decidim::Notify::Admin::UpdateChapter

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/notify/admin/update_chapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form, chapter) ⇒ UpdateChapter

Public: Initializes the command.

form - A chapter form chapter - the chapter to be update



11
12
13
14
# File 'app/commands/decidim/notify/admin/update_chapter.rb', line 11

def initialize(form, chapter)
  @form = form
  @chapter = chapter
end

Instance Attribute Details

#chapterObject (readonly)

Returns the value of attribute chapter.



31
32
33
# File 'app/commands/decidim/notify/admin/update_chapter.rb', line 31

def chapter
  @chapter
end

#formObject (readonly)

Returns the value of attribute form.



31
32
33
# File 'app/commands/decidim/notify/admin/update_chapter.rb', line 31

def form
  @form
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if we couldn’t proceed.

Returns nothing.



22
23
24
25
26
27
28
29
# File 'app/commands/decidim/notify/admin/update_chapter.rb', line 22

def call
  return broadcast(:invalid) if form.invalid?

  unset_actives
  update_chapter!

  broadcast(:ok)
end