Class: Decidim::Elections::Admin::DestroyAnswer
- Inherits:
-
Command
- Object
- Command
- Decidim::Elections::Admin::DestroyAnswer
- Includes:
- AttachmentMethods, GalleryMethods
- Defined in:
- decidim-elections/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.
12 13 14 15 16 |
# File 'decidim-elections/app/commands/decidim/elections/admin/destroy_answer.rb', line 12 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.
21 22 23 24 25 26 27 |
# File 'decidim-elections/app/commands/decidim/elections/admin/destroy_answer.rb', line 21 def call return broadcast(:invalid) if invalid? destroy_answer broadcast(:ok, answer) end |