Class: Decidim::Votings::Admin::DestroyPollingStation

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

Overview

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

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(polling_station, current_user) ⇒ DestroyPollingStation

Returns a new instance of DestroyPollingStation.


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

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

Dynamic Method Handling

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

Instance Method Details

#callObject

Destroys the polling station if valid.

Broadcasts :ok if successful, :invalid otherwise.


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

def call
  destroy_polling_station!

  broadcast(:ok, polling_station)
end