Class: Decidim::Elections::Admin::UpdateAnswerSelection
- Defined in:
- decidim-elections/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.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(answer, selected) ⇒ UpdateAnswerSelection
Returns a new instance of UpdateAnswerSelection.
9 10 11 12 |
# File 'decidim-elections/app/commands/decidim/elections/admin/update_answer_selection.rb', line 9 def initialize(answer, selected) @answer = answer @selected = selected end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Selects the answer if valid.
Broadcasts :ok if successful, :invalid otherwise.
17 18 19 20 21 22 23 |
# File 'decidim-elections/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 |