Sha256: 4462ae78b77411c2ad1e0bb840b25aca8aef372bc3b5d05cebcf4b9411c10a33

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    module Admin
      # A command with all the business logic when deleting a ParticipatoryProcessGroup.
      class DestroyParticipatoryProcessGroup < Decidim::Command
        # Public: Initializes the command.
        #
        # participatory_process_group - the ParticipatoryProcessGroup to delete.
        # current_user - the user performing this action
        def initialize(participatory_process_group, current_user)
          @participatory_process_group = participatory_process_group
          @current_user = current_user
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when the record could be deleted.
        # - :invalid when the record couldn't be deleted.
        #
        # Returns nothing.
        def call
          destroy_process_group
          broadcast(:ok)
        rescue ActiveRecord::RecordNotDestroyed
          broadcast(:invalid)
        end

        private

        attr_reader :participatory_process_group, :current_user

        def destroy_process_group
          Decidim.traceability.perform_action!(
            "delete",
            participatory_process_group,
            current_user
          ) do
            participatory_process_group.destroy!
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.27.9 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.8 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.7 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.6 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.5 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.4 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.3 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.2 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.1 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.0 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.0.rc2 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb
decidim-participatory_processes-0.27.0.rc1 app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb