Class: Decidim::Consultations::UnvoteQuestion

Inherits:
Decidim::Command show all
Defined in:
decidim-consultations/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

Methods inherited from Decidim::Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction

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 'decidim-consultations/app/commands/decidim/consultations/unvote_question.rb', line 11

def initialize(question, current_user)
  @question = question
  @current_user = current_user
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

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 'decidim-consultations/app/commands/decidim/consultations/unvote_question.rb', line 22

def call
  destroy_vote
  broadcast(:ok, @question)
end