Class: Decidim::EnhancedTextwork::PublishParagraph
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::EnhancedTextwork::PublishParagraph
- Defined in:
- app/commands/decidim/enhanced_textwork/publish_paragraph.rb
Overview
A command with all the business logic when a user publishes a draft paragraph.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(paragraph, current_user) ⇒ PublishParagraph
constructor
Public: Initializes the command.
Constructor Details
#initialize(paragraph, current_user) ⇒ PublishParagraph
Public: Initializes the command.
paragraph - The paragraph to publish. current_user - The current user.
11 12 13 14 |
# File 'app/commands/decidim/enhanced_textwork/publish_paragraph.rb', line 11 def initialize(paragraph, current_user) @paragraph = paragraph @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid and the paragraph is published.
-
:invalid if the paragraph's author is not the current user.
Returns nothing.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/commands/decidim/enhanced_textwork/publish_paragraph.rb', line 22 def call return broadcast(:invalid) unless @paragraph.(@current_user) transaction do publish_paragraph increment_scores send_notification send_notification_to_participatory_space end broadcast(:ok, @paragraph) end |