Class: Decidim::Comments::UpdateComment
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Comments::UpdateComment
- Defined in:
- decidim-comments/app/commands/decidim/comments/update_comment.rb
Overview
A command with all the business logic to update an existing comment
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(comment, current_user, form) ⇒ UpdateComment
constructor
Public: Initializes the command.
Constructor Details
#initialize(comment, current_user, form) ⇒ UpdateComment
Public: Initializes the command.
comment - Decidim::Comments::Comment current_user - Decidim::User form - A form object with the params.
12 13 14 15 16 |
# File 'decidim-comments/app/commands/decidim/comments/update_comment.rb', line 12 def initialize(comment, current_user, form) @comment = comment @current_user = current_user @form = form end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
24 25 26 27 28 29 30 |
# File 'decidim-comments/app/commands/decidim/comments/update_comment.rb', line 24 def call return broadcast(:invalid) if form.invalid? || !comment.(current_user) update_comment broadcast(:ok) end |