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

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

Methods inherited from Command

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

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

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



23
24
25
26
27
28
# File 'decidim-participatory_processes/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