Class: Decidim::Meetings::CreateMeeting

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-meetings/app/commands/decidim/meetings/create_meeting.rb

Overview

This command is executed when a participant or user group creates a Meeting from the public views.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreateMeeting

Returns a new instance of CreateMeeting.


8
9
10
# File 'decidim-meetings/app/commands/decidim/meetings/create_meeting.rb', line 8

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

Creates the meeting if valid.

Broadcasts :ok if successful, :invalid otherwise.


15
16
17
18
19
20
21
22
23
24
25
# File 'decidim-meetings/app/commands/decidim/meetings/create_meeting.rb', line 15

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

  transaction do
    create_meeting!
    schedule_upcoming_meeting_notification
    send_notification
  end

  broadcast(:ok, meeting)
end