Class: Decidim::Admin::ReorderContentBlocks

Inherits:
Rectify::Command
  • Object
show all
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

Constructor Details

#initialize(organization, scope, order) ⇒ 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.



13
14
15
16
17
# File 'app/commands/decidim/admin/reorder_content_blocks.rb', line 13

def initialize(organization, scope, order)
  @organization = organization
  @scope = scope
  @order = order
end

Instance Method Details

#callObject

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.



25
26
27
28
29
30
# File 'app/commands/decidim/admin/reorder_content_blocks.rb', line 25

def call
  return broadcast(:invalid) if order.blank?

  reorder_steps
  broadcast(:ok)
end