Sha256: b69a3f02a53174ae8c6a741eead071695f866ec31fd78c65db36545ca3ed5358

Contents?: true

Size: 1015 Bytes

Versions: 8

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 < Rectify::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

8 entries across 8 versions & 1 rubygems

Version Path
decidim-elections-0.26.10 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.9 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.8 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.7 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.5 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.4 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.3 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.2 app/commands/decidim/votings/admin/destroy_ballot_style.rb