Sha256: 3444f411e87ba6f41ffb3c85d9758fcad5cc812decd01f8c62de3953f0f761aa

Contents?: true

Size: 1017 Bytes

Versions: 7

Compression:

Stored size: 1017 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 was not valid and could not 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

7 entries across 7 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.28.3 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.28.2 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.28.1 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.28.0 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.28.0.rc5 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.28.0.rc4 app/commands/decidim/votings/admin/destroy_ballot_style.rb