Sha256: 25ae927ce49df668dfa2cbf15e555d4c3dfbeb14d4dcc031b1945cc8f00c8df5
Contents?: true
Size: 1.15 KB
Versions: 63
Compression:
Stored size: 1.15 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 < Rectify::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 wasn't valid and we couldn't 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
63 entries across 63 versions & 1 rubygems