Class: Decidim::InviteUser

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

Methods inherited from Command

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

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

Dynamic Method Handling

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

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