Class: Decidim::Admin::CreateNewsletter
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::CreateNewsletter
- Defined in:
- app/commands/decidim/admin/create_newsletter.rb
Overview
Creates a newsletter and assigns the right author and organization.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form, content_block, user) ⇒ CreateNewsletter
constructor
Initializes the command.
Constructor Details
#initialize(form, content_block, user) ⇒ CreateNewsletter
Initializes the command.
form - The source fo data for this newsletter. content_block - An instance of ‘Decidim::ContentBlock` that holds the
newsletter attributes.
user - The User that authored this newsletter.
14 15 16 17 18 |
# File 'app/commands/decidim/admin/create_newsletter.rb', line 14 def initialize(form, content_block, user) @form = form @content_block = content_block @user = user end |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'app/commands/decidim/admin/create_newsletter.rb', line 20 def call return broadcast(:invalid) unless form.valid? transaction do create_content_block end broadcast(:ok, ) end |