Class: Decidim::Votings::Voter::UpdateInPersonVoteStatus

Inherits:
Command
  • Object
show all
Defined in:
decidim-elections/app/commands/decidim/votings/voter/update_in_person_vote_status.rb

Overview

This command updates the in person vote status

Instance Method Summary collapse

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

Constructor Details

#initialize(in_person_vote) ⇒ UpdateInPersonVoteStatus

Public: Initializes the command.

in_person_vote - the in person vote that has been updated



11
12
13
# File 'decidim-elections/app/commands/decidim/votings/voter/update_in_person_vote_status.rb', line 11

def initialize(in_person_vote)
  @in_person_vote = in_person_vote
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

Update status and send notification

Broadcasts :ok if successful, :invalid otherwise



18
19
20
21
22
23
24
25
26
27
28
# File 'decidim-elections/app/commands/decidim/votings/voter/update_in_person_vote_status.rb', line 18

def call
  return broadcast(:ok) unless status_changed?

  transaction do
    update_vote_status
  end

  broadcast(:ok)
rescue StandardError => e
  broadcast(:invalid, e.message)
end