Class: Decidim::Votings::Admin::UpdatePollingStation

Inherits:
ManagePollingStation show all
Defined in:
decidim-elections/app/commands/decidim/votings/admin/update_polling_station.rb

Overview

This command is executed when the user updates a polling station from the admin panel.

Instance Method Summary collapse

Methods inherited from ManagePollingStation

#manage_polling_officers

Methods inherited from Command

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

Constructor Details

#initialize(form, polling_station) ⇒ UpdatePollingStation

Returns a new instance of UpdatePollingStation.



9
10
11
12
# File 'decidim-elections/app/commands/decidim/votings/admin/update_polling_station.rb', line 9

def initialize(form, polling_station)
  @form = form
  @polling_station = polling_station
end

Dynamic Method Handling

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

Instance Method Details

#callObject

Updates the polling station if valid.

Broadcasts :ok if successful, :invalid otherwise.



17
18
19
20
21
22
23
24
# File 'decidim-elections/app/commands/decidim/votings/admin/update_polling_station.rb', line 17

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

  update_polling_station!
  manage_polling_officers(polling_station, form.polling_station_president_id, form.polling_station_manager_ids)

  broadcast(:ok, polling_station)
end