Class: Decidim::Elections::Admin::UpdateAnswerSelection

Inherits:
Rectify::Command
  • Object
show all
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

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

Instance Method Details

#callObject

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