Sha256: 838d01e5b96347b2b60806d99da6a5e5481b1016151cf25d3c9306bf5047d4ef
Contents?: true
Size: 922 Bytes
Versions: 64
Compression:
Stored size: 922 Bytes
Contents
# frozen_string_literal: true module Decidim module Proposals # A command with all the business logic when a user unvotes a proposal. class UnvoteProposal < Rectify::Command # Public: Initializes the command. # # proposal - A Decidim::Proposals::Proposal object. # current_user - The current user. def initialize(proposal, current_user) @proposal = proposal @current_user = current_user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid, together with the proposal. # - :invalid if the form wasn't valid and we couldn't proceed. # # Returns nothing. def call destroy_proposal_vote broadcast(:ok, @proposal) end private def destroy_proposal_vote @proposal.votes.where(author: @current_user).destroy_all end end end end
Version data entries
64 entries across 64 versions & 2 rubygems