Class: Decidim::Elections::Admin::StartVote

Inherits:
Command
  • Object
show all
Defined in:
decidim-elections/app/commands/decidim/elections/admin/start_vote.rb

Overview

This command gets called to start the voting period in the Bulletin Board.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(form) ⇒ StartVote

Public: Initializes the command.

form - A VotePeriodForm object with the information needed to start or end the vote period



11
12
13
# File 'decidim-elections/app/commands/decidim/elections/admin/start_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

Public: Starts the voting period for the Election.

Broadcasts :ok if setup, :invalid otherwise.



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

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

  transaction do
    log_action
    start_vote
  end

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