Sha256: 7f609df30514115ed2737d536b30f7423a040e2016457f8358d998716d1c365c

Contents?: true

Size: 900 Bytes

Versions: 13

Compression:

Stored size: 900 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    module ContentBlocks
      # A command with all the business logic to destroy a content block
      class DestroyContentBlock < Decidim::Command
        # Public: Initializes the command.
        #
        # content_block - The content_block to destroy
        def initialize(content_block)
          @content_block = content_block
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form was not valid and we could not proceed.
        #
        # Returns nothing.
        def call
          destroy_content_block
          broadcast(:ok)
        rescue StandardError
          broadcast(:invalid)
        end

        private

        def destroy_content_block
          @content_block.destroy!
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.28.4 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.29.0 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.28.3 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.29.0.rc4 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.29.0.rc3 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.29.0.rc2 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.29.0.rc1 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.28.2 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.28.1 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.28.0 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.28.0.rc5 app/commands/decidim/admin/content_blocks/destroy_content_block.rb
decidim-admin-0.28.0.rc4 app/commands/decidim/admin/content_blocks/destroy_content_block.rb