Sha256: 3a6bc05bf99e881651100fe1cd6a41cae7224ef7b818cb19190f27de2930e49d

Contents?: true

Size: 927 Bytes

Versions: 18

Compression:

Stored size: 927 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module DirectVerifications
    module Verification
      # A command to destroy an authorization.
      class DestroyUserAuthorization < Rectify::Command
        # Public: Initializes the command.
        #
        # authorization - The authorization object to destroy.
        def initialize(authorization)
          @authorization = authorization
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the authorization couldn't be destroyed.
        #
        # Returns nothing.
        def call
          return broadcast(:invalid) unless authorization

          destroy_authorization
          broadcast(:ok)
        end

        private

        attr_reader :authorization

        def destroy_authorization
          authorization.destroy!
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
decidim-direct_verifications-1.2.1 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-1.2 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-1.0.2 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-1.0.1 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-1.1 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-1.0 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.22.1 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.22 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.21 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.20 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.17.8 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.17.7 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.17.6 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.17.5 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.17.4 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.17.3 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.2.2 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
decidim-direct_verifications-0.2.1 app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb