Class: Decidim::Admin::ReorderTaxonomies

Inherits:
Command
  • Object
show all
Defined in:
decidim-admin/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

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

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 'decidim-admin/app/commands/decidim/admin/reorder_taxonomies.rb', line 12

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

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 'decidim-admin/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