Class: Decidim::RemoveAdmin

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

Overview

A command to remove the admin privilege to an user.

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ RemoveAdmin

Public: Initializes the command.

form - A form object with the params.



9
10
11
# File 'app/commands/decidim/remove_admin.rb', line 9

def initialize(user)
  @user = user
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
# File 'app/commands/decidim/remove_admin.rb', line 13

def call
  return broadcast(:invalid) unless user

  user.update_attributes!(admin: false)

  broadcast(:ok)
end