Class: Decidim::Challenges::Admin::DestroyChallenge
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Challenges::Admin::DestroyChallenge
- Defined in:
- app/commands/decidim/challenges/admin/destroy_challenge.rb
Overview
This command deals with destroying a Challenge from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Public: Executes the command.
-
#initialize(challenge, current_user) ⇒ DestroyChallenge
constructor
Public: Initializes the command.
Constructor Details
#initialize(challenge, current_user) ⇒ DestroyChallenge
Public: Initializes the command.
page - The Challenge to be destroyed.
11 12 13 14 15 |
# File 'app/commands/decidim/challenges/admin/destroy_challenge.rb', line 11 def initialize(challenge, current_user) super() @challenge = challenge @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Public: Executes the command.
Broadcasts :ok if it got destroyed Broadcasts :has_problems if not destroyed ‘cause dependent Broadcasts :invalid if it not destroyed
22 23 24 25 26 27 28 29 |
# File 'app/commands/decidim/challenges/admin/destroy_challenge.rb', line 22 def call destroy_challenge broadcast(:ok) rescue ActiveRecord::DeleteRestrictionError broadcast(:has_problems) rescue ActiveRecord::RecordNotDestroyed broadcast(:invalid) end |