Class: Decidim::Consultations::UnvoteQuestion

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

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

#callObject

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