Sha256: 1745d2a91c3ac1a214e62cddc10858843f1645c4db46c29e93a381f89f6b5d5f

Contents?: true

Size: 1.15 KB

Versions: 35

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module Admin
      # A command with all the business logic when destroying an assembly
      # type in the system.
      class DestroyAssembliesType < Rectify::Command
        # Public: Initializes the command.
        #
        # assemblies_type - the AssemblyMember to destroy
        # current_user - the user performing the action
        def initialize(assemblies_type, current_user)
          @assemblies_type = assemblies_type
          @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_assembly_type!
          broadcast(:ok)
        end

        private

        attr_reader :current_user

        def destroy_assembly_type!
          Decidim.traceability.perform_action!(
            "delete",
            @assemblies_type,
            current_user
          ) do
            @assemblies_type.destroy!
          end
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
decidim-assemblies-0.26.10 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.9 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.8 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.7 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.5 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.4 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.3 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.2 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.1 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.0 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.0.rc2 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.26.0.rc1 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.25.2 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.25.1 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.25.0 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.25.0.rc4 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.25.0.rc3 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.25.0.rc2 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.25.0.rc1 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb
decidim-assemblies-0.24.3 app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb