Class: Decidim::Elections::Admin::UpdateAnswerSelection
- Inherits:
-
Command
- Object
- Command
- Decidim::Elections::Admin::UpdateAnswerSelection
- Defined in:
- app/commands/decidim/elections/admin/update_answer_selection.rb
Overview
This command is executed when an admin marks an answer as selected.
Instance Method Summary collapse
-
#call ⇒ Object
Selects the answer if valid.
-
#initialize(answer, selected) ⇒ UpdateAnswerSelection
constructor
A new instance of UpdateAnswerSelection.
Constructor Details
#initialize(answer, selected) ⇒ UpdateAnswerSelection
Returns a new instance of UpdateAnswerSelection.
9 10 11 12 |
# File 'app/commands/decidim/elections/admin/update_answer_selection.rb', line 9 def initialize(answer, selected) @answer = answer @selected = selected end |
Instance Method Details
#call ⇒ Object
Selects the answer if valid.
Broadcasts :ok if successful, :invalid otherwise.
17 18 19 20 21 22 23 |
# File 'app/commands/decidim/elections/admin/update_answer_selection.rb', line 17 def call return broadcast(:invalid) if invalid? update_answer_selection! broadcast(:ok, answer) end |