Class: Decidim::Verifications::PerformAuthorizationStep

Inherits:
Command
  • Object
show all
Defined in:
decidim-verifications/app/commands/decidim/verifications/perform_authorization_step.rb

Overview

A command to create a partial authorization for a user.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(authorization, handler) ⇒ PerformAuthorizationStep

Public: Initializes the command.

authorization - An Authorization object. handler - An AuthorizationHandler object.



11
12
13
14
# File 'decidim-verifications/app/commands/decidim/verifications/perform_authorization_step.rb', line 11

def initialize(authorization, handler)
  @authorization = authorization
  @handler = handler
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the handler was not valid and we could not proceed.

Returns nothing.



22
23
24
25
26
27
28
# File 'decidim-verifications/app/commands/decidim/verifications/perform_authorization_step.rb', line 22

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

  update_verification_data

  broadcast(:ok)
end