Sha256: b86af4e319202c29d4b56f9edd5f40a0bfb212243a7f86a73da1555f2e19314d

Contents?: true

Size: 986 Bytes

Versions: 4

Compression:

Stored size: 986 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"
          ) do
            ballot_style.destroy!
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-elections-0.26.1 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.0 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.0.rc2 app/commands/decidim/votings/admin/destroy_ballot_style.rb
decidim-elections-0.26.0.rc1 app/commands/decidim/votings/admin/destroy_ballot_style.rb