Class: Decidim::Comments::UpdateComment
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Comments::UpdateComment
- Defined in:
- 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, form) ⇒ UpdateComment
constructor
Public: Initializes the command.
Constructor Details
#initialize(comment, form) ⇒ UpdateComment
Public: Initializes the command.
comment - Decidim::Comments::Comment form - A form object with the params.
12 13 14 15 |
# File 'app/commands/decidim/comments/update_comment.rb', line 12 def initialize(comment, form) @comment = comment @form = form end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form was not valid and we could not proceed.
Returns nothing.
23 24 25 26 27 28 29 30 31 |
# File 'app/commands/decidim/comments/update_comment.rb', line 23 def call return broadcast(:invalid) if form.invalid? || !comment.(current_user) with_events do update_comment end broadcast(:ok) end |