Class: Decidim::ParticipatoryProcesses::Admin::ReorderParticipatoryProcessSteps

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



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

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 was not valid and we could not proceed.

Returns nothing.



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

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

  reorder_steps
  broadcast(:ok)
end