class Decidim::Meetings::WithdrawMeeting

A command with all the business logic when a user withdraws a new proposal.

def call

Returns nothing.

- :invalid if the meeting does not belong to current user.
- :ok when everything is valid, together with the meeting.

Executes the command. Broadcasts these events:
def call
  return broadcast(:invalid) unless @meeting.authored_by?(@current_user)
  transaction do
    change_meeting_state_to_withdrawn
  end
  broadcast(:ok, @meeting)
end

def change_meeting_state_to_withdrawn

def change_meeting_state_to_withdrawn
  @meeting.update state: "withdrawn"
end

def initialize(meeting, current_user)

current_user - The current user.
meeting - The meeting to withdraw.

Public: Initializes the command.
def initialize(meeting, current_user)
  @meeting = meeting
  @current_user = current_user
end