Class: Decidim::Admin::ReorderTaxonomies

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/admin/reorder_taxonomies.rb

Overview

A command that reorders a collection of taxonomies the ones that might be missing.

Instance Method Summary collapse

Constructor Details

#initialize(organization, order, offset = 0) ⇒ ReorderTaxonomies

Public: Initializes the command.

organization - the Organization where the content blocks reside order - an Array holding the order of IDs of published content blocks.



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

def initialize(organization, order, offset = 0)
  @organization = organization
  @order = order
  @offset = offset
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the data was not valid and we could not proceed.

Returns nothing.



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

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

  reorder_steps
  broadcast(:ok)
end