Sha256: 9d69aaf6ea715178fd1053a04bbe03373c0520d3be0c0e82d5582e154e264336

Contents?: true

Size: 1016 Bytes

Versions: 19

Compression:

Stored size: 1016 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Accountability
    module Admin
      # This command is executed when the user destroys a Result from the admin
      # panel.
      class DestroyResult < Decidim::Command
        # Initializes an UpdateResult Command.
        #
        # result - The current instance of the result to be destroyed.
        # current_user - the user performing the action
        def initialize(result, current_user)
          @result = result
          @current_user = current_user
        end

        # Destroys the result.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          destroy_result

          broadcast(:ok)
        end

        private

        attr_reader :result, :current_user

        def destroy_result
          Decidim.traceability.perform_action!(
            :delete,
            result,
            current_user
          ) do
            result.destroy!
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-accountability-0.28.4 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.9 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.28.3 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.8 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.28.2 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.7 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.28.1 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.6 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.28.0 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.5 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.28.0.rc5 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.28.0.rc4 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.4 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.3 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.2 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.1 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.0 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.0.rc2 app/commands/decidim/accountability/admin/destroy_result.rb
decidim-accountability-0.27.0.rc1 app/commands/decidim/accountability/admin/destroy_result.rb