Class: Decidim::DirectVerifications::Verification::DestroyUserAuthorization

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

Overview

A command to destroy an authorization.

Instance Method Summary collapse

Constructor Details

#initialize(authorization) ⇒ DestroyUserAuthorization

Public: Initializes the command.

authorization - The authorization object to destroy.



11
12
13
# File 'app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb', line 11

def initialize(authorization)
  @authorization = authorization
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the authorization couldn’t be destroyed.

Returns nothing.



21
22
23
24
25
26
# File 'app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb', line 21

def call
  return broadcast(:invalid) unless authorization

  destroy_authorization
  broadcast(:ok)
end