Class: Decidim::Elections::Admin::UpdateAnswer
- Inherits:
-
Command
- Object
- Command
- Decidim::Elections::Admin::UpdateAnswer
- Includes:
- GalleryMethods
- Defined in:
- app/commands/decidim/elections/admin/update_answer.rb
Overview
This command is executed when the user updates an Answer from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Updates the answer if valid.
-
#initialize(form, answer) ⇒ UpdateAnswer
constructor
A new instance of UpdateAnswer.
Constructor Details
#initialize(form, answer) ⇒ UpdateAnswer
Returns a new instance of UpdateAnswer.
11 12 13 14 15 |
# File 'app/commands/decidim/elections/admin/update_answer.rb', line 11 def initialize(form, answer) @form = form @answer = answer @attached_to = answer end |
Instance Method Details
#call ⇒ Object
Updates the answer if valid.
Broadcasts :ok if successful, :invalid otherwise.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/commands/decidim/elections/admin/update_answer.rb', line 20 def call return broadcast(:invalid) if invalid? if process_gallery? build_gallery return broadcast(:invalid) if gallery_invalid? end transaction do update_answer link_proposals create_gallery if process_gallery? photo_cleanup! end broadcast(:ok, answer) end |