Class: Decidim::Elections::Admin::CreateAnswer
- Includes:
- GalleryMethods
- Defined in:
- decidim-elections/app/commands/decidim/elections/admin/create_answer.rb
Overview
This command is executed when the user creates an Answer from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Creates the answer if valid.
-
#initialize(form) ⇒ CreateAnswer
constructor
A new instance of CreateAnswer.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(form) ⇒ CreateAnswer
Returns a new instance of CreateAnswer.
11 12 13 |
# File 'decidim-elections/app/commands/decidim/elections/admin/create_answer.rb', line 11 def initialize(form) @form = form end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Creates the answer if valid.
Broadcasts :ok if successful, :invalid otherwise.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'decidim-elections/app/commands/decidim/elections/admin/create_answer.rb', line 18 def call return broadcast(:invalid) if invalid? if process_gallery? build_gallery return broadcast(:invalid) if gallery_invalid? end transaction do create_answer link_proposals create_gallery if process_gallery? end broadcast(:ok, answer) end |