Sha256: 11919ed4fdd526f379181672d126a0356862d547516b7365c161ab7eea7209de

Contents?: true

Size: 1.42 KB

Versions: 12

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module Admin
      # A command with all the business logic when destroying an assembly
      # member in the system.
      class DestroyAssemblyMember < Decidim::Command
        # Public: Initializes the command.
        #
        # assembly_member - the AssemblyMember to destroy
        # current_user - the user performing this action
        def initialize(assembly_member, current_user)
          @assembly_member = assembly_member
          @current_user = current_user
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form wasn't valid and we couldn't proceed.
        #
        # Returns nothing.
        def call
          destroy_member!
          broadcast(:ok)
        end

        private

        attr_reader :assembly_member, :current_user

        def destroy_member!
          log_info = {
            resource: {
              title: assembly_member.full_name
            },
            participatory_space: {
              title: assembly_member.assembly.title
            }
          }

          Decidim.traceability.perform_action!(
            "delete",
            assembly_member,
            current_user,
            log_info
          ) do
            assembly_member.destroy!
            assembly_member
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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