Class: Decidim::Notify::Admin::CreateChapter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreateChapter

Public: Initializes the command.

form - A chapter form



10
11
12
# File 'app/commands/decidim/notify/admin/create_chapter.rb', line 10

def initialize(form)
  @form = form
end

Instance Attribute Details

#formObject (readonly)

Returns the value of attribute form.



29
30
31
# File 'app/commands/decidim/notify/admin/create_chapter.rb', line 29

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.



20
21
22
23
24
25
26
27
# File 'app/commands/decidim/notify/admin/create_chapter.rb', line 20

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

  unset_actives
  create_chapter!

  broadcast(:ok, @chapter)
end