Sha256: f9ec849d0a5df28e7723846792d8a836a0bff08ab185fb4dcd786ebe63e7668b

Contents?: true

Size: 943 Bytes

Versions: 3

Compression:

Stored size: 943 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Slider
    module Admin
      # A command with all the business logic to destroy a content block
      # TODO: Remove when upgrading to Decidim 0.28
      class DestroyContentBlock < Rectify::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 wasn't valid and we couldn't 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

3 entries across 3 versions & 1 rubygems

Version Path
decidim-slider-0.0.3 app/commands/decidim/slider/admin/destroy_content_block.rb
decidim-slider-0.0.2 app/commands/decidim/slider/admin/destroy_content_block.rb
decidim-slider-0.0.1 app/commands/decidim/slider/admin/destroy_content_block.rb