Class: Decidim::Elections::Voter::UpdateVoteStatus
- Defined in:
- decidim-elections/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.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(vote) ⇒ UpdateVoteStatus
Public: Initializes the command.
vote - the vote that has been updated
11 12 13 |
# File 'decidim-elections/app/commands/decidim/elections/voter/update_vote_status.rb', line 11 def initialize(vote) @vote = vote end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
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 'decidim-elections/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 |