Class: Decidim::Feeds::Admin::UpdateFeed
- Inherits:
-
Command
- Object
- Command
- Decidim::Feeds::Admin::UpdateFeed
- Includes:
- MultipleAttachmentsMethods
- Defined in:
- app/commands/decidim/feeds/admin/update_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(feed, form) ⇒ UpdateFeed
constructor
Public: Initializes the command.
Constructor Details
#initialize(feed, form) ⇒ UpdateFeed
Public: Initializes the command.
feed - the Feed to update form - A form object with the params.
15 16 17 18 19 |
# File 'app/commands/decidim/feeds/admin/update_feed.rb', line 15 def initialize(feed, form) @feed = feed @form = form @attached_to = feed 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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/commands/decidim/feeds/admin/update_feed.rb', line 27 def call return broadcast(:invalid) if form.invalid? if return broadcast(:invalid) if end update_feed # link_participatory_processes(@feed) document_cleanup!(include_all_attachments: true) if if @feed.valid? broadcast(:ok, @feed) 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 |