Sha256: 98100d32d0af6156d765386f6c6139f90d530bb3908e15179fa2bd5c514c7f47
Contents?: true
Size: 1.16 KB
Versions: 15
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Decidim module Initiatives module Admin # A command with all the business logic that unpublishes an # existing initiative. class UnpublishInitiative < Decidim::Command # Public: Initializes the command. # # initiative - Decidim::Initiative # current_user - the user performing the action def initialize(initiative, current_user) @initiative = initiative @current_user = current_user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form was not valid and we could not proceed. # # Returns nothing. def call return broadcast(:invalid) unless initiative.published? @initiative = Decidim.traceability.perform_action!( :unpublish, initiative, current_user ) do initiative.unpublish! initiative end broadcast(:ok, initiative) end private attr_reader :initiative, :current_user end end end end
Version data entries
15 entries across 15 versions & 1 rubygems