Class: Decidim::Meetings::CreateAnswer
- Inherits:
-
Command
- Object
- Command
- Decidim::Meetings::CreateAnswer
- Defined in:
- 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, questionnaire) ⇒ CreateAnswer
constructor
A new instance of CreateAnswer.
Constructor Details
#initialize(form, questionnaire) ⇒ CreateAnswer
Returns a new instance of CreateAnswer.
9 10 11 12 |
# File 'app/commands/decidim/meetings/create_answer.rb', line 9 def initialize(form, questionnaire) @form = form @questionnaire = questionnaire end |
Instance Method Details
#call ⇒ Object
Creates the answer if valid.
Broadcasts :ok if successful, :invalid otherwise.
17 18 19 20 21 22 23 24 25 |
# File 'app/commands/decidim/meetings/create_answer.rb', line 17 def call return broadcast(:invalid) if form.invalid? transaction do answer_question end broadcast(:ok) end |