Class: Decidim::Consultations::UnvoteQuestion
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Consultations::UnvoteQuestion
- Defined in:
- app/commands/decidim/consultations/unvote_question.rb
Overview
A command with all the business logic when a user unvotes a question.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(question, current_user) ⇒ UnvoteQuestion
constructor
Public: Initializes the command.
Constructor Details
#initialize(question, current_user) ⇒ UnvoteQuestion
Public: Initializes the command.
question - A Decidim::Consultations::Question object. current_user - The current user.
11 12 13 14 |
# File 'app/commands/decidim/consultations/unvote_question.rb', line 11 def initialize(question, current_user) @question = question @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid, together with the question.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
22 23 24 25 |
# File 'app/commands/decidim/consultations/unvote_question.rb', line 22 def call destroy_vote broadcast(:ok, @question) end |