Class: Decidim::Proposals::EndorseProposal
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Proposals::EndorseProposal
- Defined in:
- app/commands/decidim/proposals/endorse_proposal.rb
Overview
A command with all the business logic when a user endorses a proposal.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(proposal, current_user, current_group_id = nil) ⇒ EndorseProposal
constructor
Public: Initializes the command.
Constructor Details
#initialize(proposal, current_user, current_group_id = nil) ⇒ EndorseProposal
Public: Initializes the command.
proposal - A Decidim::Proposals::Proposal object. current_user - The current user. current_group_id- (optional) The current_grup that is endorsing the Proposal.
12 13 14 15 16 |
# File 'app/commands/decidim/proposals/endorse_proposal.rb', line 12 def initialize(proposal, current_user, current_group_id = nil) @proposal = proposal @current_user = current_user @current_group_id = current_group_id end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid, together with the proposal vote.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
24 25 26 27 28 29 30 31 32 |
# File 'app/commands/decidim/proposals/endorse_proposal.rb', line 24 def call endorsement = build_proposal_endorsement if endorsement.save notify_endorser_followers broadcast(:ok, endorsement) else broadcast(:invalid) end end |