Class: Decidim::InviteUser

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

Overview

A command with the business logic to invite a user to an organization.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ InviteUser

Public: Initializes the command.

form - A form object with the params.


9
10
11
# File 'decidim-core/app/commands/decidim/invite_user.rb', line 9

def initialize(form)
  @form = form
end

Instance Method Details

#callObject


13
14
15
16
17
18
19
20
21
22
23
# File 'decidim-core/app/commands/decidim/invite_user.rb', line 13

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

  if user.present?
    update_user
  else
    invite_user
  end

  broadcast(:ok, user)
end