Class: Decidim::Comments::DeleteComment
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Comments::DeleteComment
- Defined in:
- decidim-comments/app/commands/decidim/comments/delete_comment.rb
Overview
A command with all the business logic to delete a comment
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(comment, current_user) ⇒ DeleteComment
constructor
Public: Initializes the command.
Methods inherited from Decidim::Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(comment, current_user) ⇒ DeleteComment
Public: Initializes the command.
comment - The comment to delete. current_user - The user performing the action.
11 12 13 14 |
# File 'decidim-comments/app/commands/decidim/comments/delete_comment.rb', line 11 def initialize(comment, current_user) @comment = comment @current_user = current_user end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if comment is not authored by current_user.
Returns nothing.
22 23 24 25 26 27 28 |
# File 'decidim-comments/app/commands/decidim/comments/delete_comment.rb', line 22 def call return broadcast(:invalid) unless comment.(current_user) delete_comment broadcast(:ok) end |