Class: Decidim::Elections::Admin::DestroyElection
- Inherits:
-
Command
- Object
- Command
- Decidim::Elections::Admin::DestroyElection
- Includes:
- GalleryMethods
- Defined in:
- app/commands/decidim/elections/admin/destroy_election.rb
Overview
This command is executed when the user destroys an Election from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Destroys the election if valid.
-
#initialize(election, current_user) ⇒ DestroyElection
constructor
A new instance of DestroyElection.
Constructor Details
#initialize(election, current_user) ⇒ DestroyElection
Returns a new instance of DestroyElection.
11 12 13 14 15 |
# File 'app/commands/decidim/elections/admin/destroy_election.rb', line 11 def initialize(election, current_user) @election = election @current_user = current_user @attached_to = election end |
Instance Method Details
#call ⇒ Object
Destroys the election if valid.
Broadcasts :ok if successful, :invalid otherwise.
20 21 22 23 24 25 26 |
# File 'app/commands/decidim/elections/admin/destroy_election.rb', line 20 def call return broadcast(:invalid) if invalid? destroy_election! broadcast(:ok, election) end |