Class: Decidim::Admin::ReorderContentBlocks
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::ReorderContentBlocks
- Defined in:
- app/commands/decidim/admin/reorder_content_blocks.rb
Overview
A command that reorders a collection of content blocks. It also creates the ones that might be missing.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(organization, scope, order, scoped_resource_id = nil) ⇒ ReorderContentBlocks
constructor
Public: Initializes the command.
Constructor Details
#initialize(organization, scope, order, scoped_resource_id = nil) ⇒ ReorderContentBlocks
Public: Initializes the command.
organization - the Organization where the content blocks reside scope - the scope applied to the content blocks order - an Array holding the order of IDs of published content blocks. scoped_resource_id - (optional) The id of the resource the content blocks belongs to.
14 15 16 17 18 19 |
# File 'app/commands/decidim/admin/reorder_content_blocks.rb', line 14 def initialize(organization, scope, order, scoped_resource_id = nil) @organization = organization @scope = scope @order = order @scoped_resource_id = scoped_resource_id end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the data wasn’t valid and we couldn’t proceed.
Returns nothing.
27 28 29 30 31 32 |
# File 'app/commands/decidim/admin/reorder_content_blocks.rb', line 27 def call return broadcast(:invalid) if order.blank? reorder_steps broadcast(:ok) end |