Sha256: 76610f83084dbd5b22805ba1da38d35b1a35c16042f6155531cbf5c140816e2d

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    module Admin
      # A command with all the business logic when destroying a participatory
      # process type in the system.
      class DestroyParticipatoryProcessType < Decidim::Command
        # Public: Initializes the command.
        #
        # participatory_process_type - A participatory_process_type object to
        # destroy
        # current_user - the user performing the action
        def initialize(participatory_process_type, current_user)
          @participatory_process_type = participatory_process_type
          @current_user = current_user
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form was not valid and we could not proceed.
        #
        # Returns nothing.
        def call
          destroy_participatory_process_type!

          broadcast(:ok)
        end

        private

        attr_reader :current_user

        def destroy_participatory_process_type!
          transaction do
            Decidim.traceability.perform_action!(
              "delete",
              @participatory_process_type,
              current_user
            ) do
              @participatory_process_type.destroy!
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.28.4 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb
decidim-participatory_processes-0.28.3 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb
decidim-participatory_processes-0.28.2 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb
decidim-participatory_processes-0.28.1 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb
decidim-participatory_processes-0.28.0 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb
decidim-participatory_processes-0.28.0.rc5 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb
decidim-participatory_processes-0.28.0.rc4 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb