Class: Decidim::Plans::WithdrawPlan
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Plans::WithdrawPlan
- Defined in:
- app/commands/decidim/plans/withdraw_plan.rb
Overview
A command with all the business logic when a user withdraws a plan.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(plan, current_user) ⇒ WithdrawPlan
constructor
Public: Initializes the command.
Constructor Details
#initialize(plan, current_user) ⇒ WithdrawPlan
Public: Initializes the command.
plan - The plan to withdraw. current_user - The current user.
11 12 13 14 |
# File 'app/commands/decidim/plans/withdraw_plan.rb', line 11 def initialize(plan, current_user) @plan = plan @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid, together with the proposal.
-
:invalid if the proposal already has supports or does not belong to current user.
Returns nothing.
22 23 24 25 26 27 28 29 30 31 |
# File 'app/commands/decidim/plans/withdraw_plan.rb', line 22 def call # return broadcast(:invalid) if @plan.votes.any? transaction do change_plan_state_to_withdrawn # reject_emendations_if_any # 0.16+ end broadcast(:ok, @plan) end |