Class: Decidim::Meetings::CreateAnswer
- Defined in:
- decidim-meetings/app/commands/decidim/meetings/create_answer.rb
Overview
This command is executed when the user creates an Answer in a meeting poll.
Instance Method Summary collapse
-
#call ⇒ Object
Creates the answer if valid.
-
#initialize(form, current_user, questionnaire) ⇒ 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, current_user, questionnaire) ⇒ CreateAnswer
Returns a new instance of CreateAnswer.
7 8 9 10 11 |
# File 'decidim-meetings/app/commands/decidim/meetings/create_answer.rb', line 7 def initialize(form, current_user, questionnaire) @form = form @current_user = current_user @questionnaire = questionnaire 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.
16 17 18 19 20 21 22 23 24 |
# File 'decidim-meetings/app/commands/decidim/meetings/create_answer.rb', line 16 def call return broadcast(:invalid) if form.invalid? transaction do answer_question end broadcast(:ok) end |