Sha256: 71ef0f4ae4177e51edcb49eb784198d419cccef37b96a90cdcf13a87ea224160
Contents?: true
Size: 1010 Bytes
Versions: 7
Compression:
Stored size: 1010 Bytes
Contents
# frozen_string_literal: true module Decidim module Meetings # A command with all the business logic when a user withdraws a new proposal. class WithdrawMeeting < Decidim::Command # Public: Initializes the command. # # meeting - The meeting to withdraw. # current_user - The current user. def initialize(meeting, current_user) @meeting = meeting @current_user = current_user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid, together with the meeting. # - :invalid if the meeting does not belong to current user. # # Returns nothing. def call return broadcast(:invalid) unless @meeting.authored_by?(@current_user) transaction do change_meeting_state_to_withdrawn end broadcast(:ok, @meeting) end private def change_meeting_state_to_withdrawn @meeting.withdraw! end end end end
Version data entries
7 entries across 7 versions & 1 rubygems