Class: Decidim::Admin::ReorderParticipatoryProcessSteps

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

Overview

A command that reorders the steps in a participatory process.

Instance Method Summary collapse

Constructor Details

#initialize(collection, order) ⇒ ReorderParticipatoryProcessSteps

Public: Initializes the command.

collection - an ActiveRecord::Relation of steps order - an Array holding the order of IDs of steps



11
12
13
14
# File 'decidim-admin/app/commands/decidim/admin/reorder_participatory_process_steps.rb', line 11

def initialize(collection, order)
  @collection = collection
  @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.



22
23
24
25
26
27
# File 'decidim-admin/app/commands/decidim/admin/reorder_participatory_process_steps.rb', line 22

def call
  return broadcast(:invalid) unless order.present?

  reorder_steps
  broadcast(:ok)
end