Sha256: ca92433af0573012fecde3f448d99b25b6a416e50520f623ed9f98f233dde0ab

Contents?: true

Size: 944 Bytes

Versions: 22

Compression:

Stored size: 944 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A command with all the business logic to destroy an area.
    class DestroyArea < Rectify::Command
      # Public: Initializes the command.
      #
      # area - The area to destroy
      # current_user - the user performing the action
      def initialize(area, current_user)
        @area = area
        @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_area
        broadcast(:ok)
      end

      private

      attr_reader :current_user

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
decidim-admin-0.17.2 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.17.1 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.16.1 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.17.0 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.16.0 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.15.2 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.15.1 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.15.0 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.14.4 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.14.3 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.14.2 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.14.1 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.13.1 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.12.2 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.13.0 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.12.1 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.13.0.pre1 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.12.0 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.11.2 app/commands/decidim/admin/destroy_area.rb
decidim-admin-0.12.0.pre app/commands/decidim/admin/destroy_area.rb