Class: Decidim::Elections::Admin::DestroyQuestion
- Inherits:
-
Command
- Object
- Command
- Decidim::Elections::Admin::DestroyQuestion
- Defined in:
- app/commands/decidim/elections/admin/destroy_question.rb
Overview
This command is executed when the user destroys a Question from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Destroys the question if valid.
-
#initialize(question, current_user) ⇒ DestroyQuestion
constructor
A new instance of DestroyQuestion.
Constructor Details
#initialize(question, current_user) ⇒ DestroyQuestion
Returns a new instance of DestroyQuestion.
9 10 11 12 |
# File 'app/commands/decidim/elections/admin/destroy_question.rb', line 9 def initialize(question, current_user) @question = question @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Destroys the question if valid.
Broadcasts :ok if successful, :invalid otherwise.
17 18 19 20 21 22 23 |
# File 'app/commands/decidim/elections/admin/destroy_question.rb', line 17 def call return broadcast(:invalid) if invalid? destroy_question! broadcast(:ok, question) end |