Sha256: 18ee75623bf04d3670f184ac22179e78f0a74abce71295bfd3682407b393d72f
Contents?: true
Size: 1.14 KB
Versions: 10
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module Decidim module Initiatives module Admin # A command with all the business logic that publishes an # existing initiative. class PublishInitiative < 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) if initiative.published? @initiative = Decidim.traceability.perform_action!( :publish, initiative, current_user ) do initiative.publish! initiative end broadcast(:ok, initiative) end private attr_reader :initiative, :current_user end end end end
Version data entries
10 entries across 10 versions & 1 rubygems