Class: Decidim::ParticipatoryProcesses::Admin::DestroyParticipatoryProcessStep

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

Overview

A command that sets all steps in a participatory process as inactive

Instance Method Summary collapse

Constructor Details

#initialize(step) ⇒ DestroyParticipatoryProcessStep

Public: Initializes the command.

step - A ParticipatoryProcessStep that will be deactivated



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

def initialize(step)
  @step = step
  @participatory_process = step.participatory_process
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
28
# File 'app/commands/decidim/participatory_processes/admin/destroy_participatory_process_step.rb', line 22

def call
  return broadcast(:invalid, :active_step) if active_step?

  @step.destroy!
  reorder_steps
  broadcast(:ok)
end