Class: Decidim::Meetings::CreateMeeting

Inherits:
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

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

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
26
# 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

  create_follow_form_resource(form.current_user)
  broadcast(:ok, meeting)
end