Sha256: 834e86fdabbd6b16425a935794fa9a43848be1e4fa02d381aec013c00b478361

Contents?: true

Size: 979 Bytes

Versions: 7

Compression:

Stored size: 979 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Plans
    module Admin
      # A command with all the business logic when a user destroys a tag.
      class DestroyTag < Rectify::Command
        # Public: Initializes the command.
        #
        # tag - The target object to be destroyed.
        # current_user - the user performing the action.
        def initialize(tag, current_user)
          @tag = tag
          @current_user = current_user
        end

        # Destroys the tag if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        #
        # Returns nothing.
        def call
          destroy_tag

          broadcast(:ok)
        end

        private

        attr_reader :tag, :current_user

        def destroy_tag
          Decidim.traceability.perform_action!(
            :delete,
            tag,
            current_user
          ) do
            tag.destroy!
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-plans-0.18.2 app/commands/decidim/plans/admin/destroy_tag.rb
decidim-plans-0.18.1 app/commands/decidim/plans/admin/destroy_tag.rb
decidim-plans-0.18.0 app/commands/decidim/plans/admin/destroy_tag.rb
decidim-plans-0.17.0 app/commands/decidim/plans/admin/destroy_tag.rb
decidim-plans-0.16.9 app/commands/decidim/plans/admin/destroy_tag.rb
decidim-plans-0.16.8 app/commands/decidim/plans/admin/destroy_tag.rb
decidim-plans-0.16.7 app/commands/decidim/plans/admin/destroy_tag.rb