Class: Decidim::Plans::Admin::UpdatePlan
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Plans::Admin::UpdatePlan
- Includes:
- Decidim::Plans::AttachmentMethods, NestedUpdater
- Defined in:
- app/commands/decidim/plans/admin/update_plan.rb
Overview
A command with all the business logic when a user updates a plan.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, plan) ⇒ UpdatePlan
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, plan) ⇒ UpdatePlan
Public: Initializes the command.
form - A form object with the params. plan - the plan to update.
15 16 17 18 19 |
# File 'app/commands/decidim/plans/admin/update_plan.rb', line 15 def initialize(form, plan) @form = form @plan = plan @attached_to = plan end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid, together with the plan.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/commands/decidim/plans/admin/update_plan.rb', line 27 def call return broadcast(:invalid) if form.invalid? if return broadcast(:invalid) if end if form.invalid? return broadcast(:invalid) end Decidim::Plans.tracer.trace!(form.current_user) do transaction do update_plan update_plan_contents if end end broadcast(:ok, plan) end |