Class: Decidim::Conferences::Admin::InviteUserToJoinConference

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

Overview

A command with all the business logic to invite users to join a conference.

Instance Method Summary collapse

Constructor Details

#initialize(form, conference, invited_by) ⇒ InviteUserToJoinConference

Public: Initializes the command.

form - A form object with the params. conference - The conference which the user is invited to. invited_by - The user performing the operation



14
15
16
17
18
# File 'app/commands/decidim/conferences/admin/invite_user_to_join_conference.rb', line 14

def initialize(form, conference, invited_by)
  @form = form
  @conference = conference
  @invited_by = invited_by
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the form wasn’t valid and we couldn’t proceed.

Returns nothing.



26
27
28
29
30
31
32
# File 'app/commands/decidim/conferences/admin/invite_user_to_join_conference.rb', line 26

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

  invite_user

  broadcast(:ok)
end