Class: Decidim::Verifications::IdDocuments::Admin::ConfirmUserOfflineAuthorization

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

Overview

A command to confirm a previous partial offline authorization.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(form) ⇒ ConfirmUserOfflineAuthorization

Public: Initializes the command.

form - A form object with the verification data to confirm it.



12
13
14
# File 'decidim-verifications/app/commands/decidim/verifications/id_documents/admin/confirm_user_offline_authorization.rb', line 12

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

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
29
30
31
32
# File 'decidim-verifications/app/commands/decidim/verifications/id_documents/admin/confirm_user_offline_authorization.rb', line 22

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

  if confirmation_successful?
    grant_authorization
    broadcast(:ok)
  else
    broadcast(:invalid)
  end
end