Class: Decidim::Admin::TransferUser

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

Overview

A command with all the business logic to transfer a managed user.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ TransferUser

Public: Initializes the command.

form user - The current user managed_user - The managed User


12
13
14
# File 'decidim-admin/app/commands/decidim/admin/transfer_user.rb', line 12

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the impersonation is not valid.

Returns nothing.


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

def call
  return broadcast(:invalid) unless form.valid?

  transaction do
    update_managed_user
    mark_conflict_as_solved
    create_action_log
  end

  broadcast(:ok)
end