Sha256: cbccb7d99181576fc48d79907b531f851759736242b4c6202115995ab9ea1e43

Contents?: true

Size: 1015 Bytes

Versions: 12

Compression:

Stored size: 1015 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Admin
      # A command with the business logic to delete the ballot style
      class DestroyBallotStyle < Decidim::Command
        def initialize(ballot_style, current_user)
          @ballot_style = ballot_style
          @current_user = current_user
        end

        # Executes the command. Broadcast this events:
        # - :ok when everything is valid
        # - :invalid when the form wasn't valid and couldn't proceed
        #
        # Returns nothing.
        def call
          destroy_ballot_style!

          broadcast(:ok)
        end

        private

        attr_reader :ballot_style, :current_user

        def destroy_ballot_style!
          Decidim.traceability.perform_action!(
            :delete,
            ballot_style,
            current_user,
            { visibility: "all", code: ballot_style.code }
          ) do
            ballot_style.destroy!
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-elections-0.27.9 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.8 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.7 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.6 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.5 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.4 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.3 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.2 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.1 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.0 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.0.rc2 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.27.0.rc1 app/commands/decidim/votings/admin/destroy_ballot_style.rb