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