Class: Decidim::Feeds::CreateFeed
- Inherits:
-
Command
- Object
- Command
- Decidim::Feeds::CreateFeed
- Includes:
- MultipleAttachmentsMethods
- Defined in:
- app/commands/decidim/feeds/create_feed.rb
Overview
A command with all the business logic when creating a new participatory feed in the system.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form) ⇒ CreateFeed
constructor
Public: Initializes the command.
Constructor Details
#initialize(form) ⇒ CreateFeed
Public: Initializes the command.
form - A form object with the params.
12 13 14 |
# File 'app/commands/decidim/feeds/create_feed.rb', line 12 def initialize(form) @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.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/commands/decidim/feeds/create_feed.rb', line 22 def call return broadcast(:invalid) if form.invalid? if return broadcast(:invalid) if end if feed.persisted? # link_participatory_processes(feed) # Decidim::ContentBlocksCreator.new(feed).create_default! if create_posts_component broadcast(:ok, feed) else broadcast(:invalid) end else # form.errors.add(:hero_image, feed.errors[:hero_image]) if feed.errors.include? :hero_image # form.errors.add(:banner_image, feed.errors[:banner_image]) if feed.errors.include? :banner_image broadcast(:invalid) end end |