Class: Decidim::Votings::Admin::UpdatePollingStation
- Inherits:
-
ManagePollingStation
- Object
- Command
- ManagePollingStation
- Decidim::Votings::Admin::UpdatePollingStation
- Defined in:
- 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
-
#call ⇒ Object
Updates the polling station if valid.
-
#initialize(form, polling_station) ⇒ UpdatePollingStation
constructor
A new instance of UpdatePollingStation.
Methods inherited from ManagePollingStation
Constructor Details
#initialize(form, polling_station) ⇒ UpdatePollingStation
Returns a new instance of UpdatePollingStation.
9 10 11 12 |
# File 'app/commands/decidim/votings/admin/update_polling_station.rb', line 9 def initialize(form, polling_station) @form = form @polling_station = polling_station end |
Instance Method Details
#call ⇒ Object
Updates the polling station if valid.
Broadcasts :ok if successful, :invalid otherwise.
17 18 19 20 21 22 23 24 |
# File '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 |