Sha256: 9ccd1af4714d5fd4a2ba96f650dd9fcba3ef86474addca2cdfce1d250022db43
Contents?: true
Size: 937 Bytes
Versions: 8
Compression:
Stored size: 937 Bytes
Contents
# frozen_string_literal: true module Decidim module DecidimAwesome module Admin class DestroyConstraint < Command include NeedsConstraintHelpers # Public: Initializes the command. # # constraint - A constraint constraint def initialize(constraint) @constraint = constraint end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid, I18n.t("cannot_be_destroyed", scope: "decidim.decidim_awesome.admin.config.constraints")) unless constraint_can_be_destroyed?(constraint) constraint.destroy! broadcast(:ok) rescue StandardError => e broadcast(:invalid, e.message) end attr_reader :constraint end end end end
Version data entries
8 entries across 8 versions & 1 rubygems