Class: Decidim::Elections::Voter::UpdateVoteStatus
- Inherits:
-
Command
- Object
- Command
- Decidim::Elections::Voter::UpdateVoteStatus
- Defined in:
- app/commands/decidim/elections/voter/update_vote_status.rb
Overview
This command updates the vote status and sends a notification.
Instance Method Summary collapse
-
#call ⇒ Object
Update status and send notification.
-
#initialize(vote) ⇒ UpdateVoteStatus
constructor
Public: Initializes the command.
Constructor Details
#initialize(vote) ⇒ UpdateVoteStatus
Public: Initializes the command.
vote - the vote that has been updated
11 12 13 |
# File 'app/commands/decidim/elections/voter/update_vote_status.rb', line 11 def initialize(vote) @vote = vote end |
Instance Method Details
#call ⇒ Object
Update status and send notification
Broadcasts :ok if successful, :invalid otherwise
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/commands/decidim/elections/voter/update_vote_status.rb', line 18 def call return broadcast(:ok) unless status_changed? transaction do update_vote_status notify_voter end broadcast(:ok) rescue StandardError => e broadcast(:invalid, e.) end |