Class: Decidim::Budgets::Admin::UpdateProject
- Includes:
- GalleryMethods
- Defined in:
- decidim-budgets/app/commands/decidim/budgets/admin/update_project.rb
Overview
This command is executed when the user changes a Project from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Updates the project if valid.
-
#initialize(form, project) ⇒ UpdateProject
constructor
Initializes an UpdateProject Command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(form, project) ⇒ UpdateProject
Initializes an UpdateProject Command.
form - The form from which to get the data. project - The current instance of the project to be updated.
15 16 17 18 19 |
# File 'decidim-budgets/app/commands/decidim/budgets/admin/update_project.rb', line 15 def initialize(form, project) @form = form @project = project @attached_to = project end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Updates the project if valid.
Broadcasts :ok if successful, :invalid otherwise.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'decidim-budgets/app/commands/decidim/budgets/admin/update_project.rb', line 24 def call return broadcast(:invalid) if form.invalid? if process_gallery? build_gallery return broadcast(:invalid) if gallery_invalid? end transaction do update_project link_proposals create_gallery if process_gallery? photo_cleanup! end broadcast(:ok) end |