Class: Decidim::Meetings::Admin::CreateAgenda

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/meetings/admin/create_agenda.rb

Overview

This command is executed when the user creates a Meeting from the admin panel.

Instance Method Summary collapse

Constructor Details

#initialize(form, meeting) ⇒ CreateAgenda

Returns a new instance of CreateAgenda.



9
10
11
12
13
# File 'app/commands/decidim/meetings/admin/create_agenda.rb', line 9

def initialize(form, meeting)
  @form = form
  @meeting = meeting
  @agenda = nil
end

Instance Method Details

#callObject

Creates the agenda if valid.

Broadcasts :ok if successful, :invalid otherwise.



18
19
20
21
22
23
24
25
26
27
# File 'app/commands/decidim/meetings/admin/create_agenda.rb', line 18

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

  transaction do
    create_agenda!
    create_agenda_items
  end

  broadcast(:ok, @agenda)
end