Sha256: b130f76081f6a88e67f98b4235558620f5e7335c15bb249887d2c2aee2af2c99
Contents?: true
Size: 943 Bytes
Versions: 12
Compression:
Stored size: 943 Bytes
Contents
# frozen_string_literal: true module Decidim module Consultations # A command with all the business logic when a user unvotes a question. class UnvoteQuestion < Decidim::Command # Public: Initializes the command. # # question - A Decidim::Consultations::Question object. # current_user - The current user. def initialize(question, current_user) @question = question @current_user = current_user end # 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. def call destroy_vote broadcast(:ok, @question) end private def destroy_vote @question .votes .where(author: @current_user) .destroy_all end end end end
Version data entries
12 entries across 12 versions & 1 rubygems