Class: Decidim::Proposals::UnendorseProposal

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/proposals/unendorse_proposal.rb

Overview

A command with all the business logic when a user or organization unendorses a proposal.

Instance Method Summary collapse

Constructor Details

#initialize(proposal, current_user, current_group = nil) ⇒ UnendorseProposal

Public: Initializes the command.

proposal - A Decidim::Proposals::Proposal object. current_user - The current user. current_group- (optional) The current_group that is unendorsing from the Proposal.



12
13
14
15
16
# File 'app/commands/decidim/proposals/unendorse_proposal.rb', line 12

def initialize(proposal, current_user, current_group = nil)
  @proposal = proposal
  @current_user = current_user
  @current_group = current_group
end

Instance Method Details

#callObject

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.



24
25
26
27
# File 'app/commands/decidim/proposals/unendorse_proposal.rb', line 24

def call
  destroy_proposal_endorsement
  broadcast(:ok, @proposal)
end