Class: Decidim::Elections::Admin::DestroyElection
- Includes:
- GalleryMethods
- Defined in:
- decidim-elections/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.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(election, current_user) ⇒ DestroyElection
Returns a new instance of DestroyElection.
11 12 13 14 15 |
# File 'decidim-elections/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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Destroys the election if valid.
Broadcasts :ok if successful, :invalid otherwise.
20 21 22 23 24 25 26 |
# File 'decidim-elections/app/commands/decidim/elections/admin/destroy_election.rb', line 20 def call return broadcast(:invalid) if invalid? destroy_election! broadcast(:ok, election) end |