Class: Decidim::DestroyEphemeralUser
- Defined in:
- decidim-core/app/commands/decidim/destroy_ephemeral_user.rb
Overview
A command with all the business logic to create an ephemeral user.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(user) ⇒ DestroyEphemeralUser
constructor
Public: Initializes the command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(user) ⇒ DestroyEphemeralUser
Public: Initializes the command.
user - An ephemeral user.
9 10 11 |
# File 'decidim-core/app/commands/decidim/destroy_ephemeral_user.rb', line 9 def initialize(user) @user = user end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the user is not ephemeral
Returns nothing.
19 20 21 22 23 24 25 26 27 28 |
# File 'decidim-core/app/commands/decidim/destroy_ephemeral_user.rb', line 19 def call return broadcast(:invalid) unless user.ephemeral? destroy_account! broadcast(:ok) rescue ActiveRecord::RecordInvalid broadcast(:invalid) end |