Class: Decidim::DestroyAccount

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

Overview

This command destroys the user’s account.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(form) ⇒ DestroyAccount

Destroy a user’s account.

form - The form with the data.



11
12
13
# File 'app/commands/decidim/destroy_account.rb', line 11

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



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/commands/decidim/destroy_account.rb', line 15

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

  Decidim::User.transaction do
    destroy_user_account!
    destroy_user_identities
    destroy_follows
    destroy_user_versions
    destroy_user_private_exports
    destroy_user_access_grants
    destroy_user_access_tokens
    destroy_user_reminders
    destroy_user_notifications
    destroy_user_badges
    destroy_user_likes
    destroy_user_reports
    destroy_participatory_space_private_user
    delegate_destroy_to_participatory_spaces
  end

  broadcast(:ok)
end