Class: Decidim::Votings::Voter::InPersonVote

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

Overview

This command allows the user to register an in person vote.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(form) ⇒ InPersonVote

Public: Initializes the command.

form - A form with necessary info to register an in person vote.



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

def initialize(form)
  @form = form
end

Dynamic Method Handling

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

Instance Method Details

#callObject

Store and register the in person vote in the bulletin board

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/in_person_vote.rb', line 18

def call
  return broadcast(:invalid) if form.invalid?

  transaction do
    register_in_person_vote
  end

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