Class: Decidim::Meetings::UpdateMeeting

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(form, current_user, meeting) ⇒ UpdateMeeting

Initializes a UpdateMeeting Command.

form - The form from which to get the data. current_user - The current user. meeting - The current instance of the page to be updated.


13
14
15
16
17
# File 'decidim-meetings/app/commands/decidim/meetings/update_meeting.rb', line 13

def initialize(form, current_user, meeting)
  @form = form
  @current_user = current_user
  @meeting = meeting
end

Instance Method Details

#callObject

Updates the meeting if valid.

Broadcasts :ok if successful, :invalid otherwise.


22
23
24
25
26
27
28
29
30
31
32
# File 'decidim-meetings/app/commands/decidim/meetings/update_meeting.rb', line 22

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

  transaction do
    update_meeting!
    send_notification if should_notify_followers?
    schedule_upcoming_meeting_notification if start_time_changed?
  end

  broadcast(:ok, meeting)
end