Sha256: 21abfcdb98ff1ca463cb0b037b28f344cfdae345bf9e484628d3db94b5b7e3be

Contents?: true

Size: 1.34 KB

Versions: 7

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 could not 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

7 entries across 7 versions & 1 rubygems

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