Class: Decidim::Admin::UpdateContentBlock
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Admin::UpdateContentBlock
- Defined in:
- app/commands/decidim/admin/update_content_block.rb
Overview
This command gets called when a content block is updated from the admin panel.
Instance Attribute Summary collapse
-
#content_block ⇒ Object
readonly
Returns the value of attribute content_block.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#call ⇒ Object
Public: Updates the content block settings and its attachments.
-
#initialize(form, content_block, scope) ⇒ UpdateContentBlock
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, content_block, scope) ⇒ UpdateContentBlock
Public: Initializes the command.
form - The form from which the data in this component comes from. component - The component to update. scope - the scope where the content block belongs to.
15 16 17 18 19 |
# File 'app/commands/decidim/admin/update_content_block.rb', line 15 def initialize(form, content_block, scope) @form = form @content_block = content_block @scope = scope end |
Instance Attribute Details
#content_block ⇒ Object (readonly)
Returns the value of attribute content_block.
8 9 10 |
# File 'app/commands/decidim/admin/update_content_block.rb', line 8 def content_block @content_block end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
8 9 10 |
# File 'app/commands/decidim/admin/update_content_block.rb', line 8 def form @form end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
8 9 10 |
# File 'app/commands/decidim/admin/update_content_block.rb', line 8 def scope @scope end |
Instance Method Details
#call ⇒ Object
Public: Updates the content block settings and its attachments.
Broadcasts :ok if created, :invalid otherwise.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/commands/decidim/admin/update_content_block.rb', line 24 def call return broadcast(:invalid) if form.invalid? transaction do update_content_block_settings update_content_block_images content_block.save! end broadcast(:ok) end |