Class: Decidim::ParticipatoryProcesses::Admin::DestroyParticipatoryProcessGroup

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

Overview

A command with all the business logic when deleting a ParticipatoryProcessGroup.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(participatory_process_group, current_user) ⇒ DestroyParticipatoryProcessGroup

Public: Initializes the command.

participatory_process_group - the ParticipatoryProcessGroup to delete. current_user - the user performing this action



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

def initialize(participatory_process_group, current_user)
  @participatory_process_group = participatory_process_group
  @current_user = current_user
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 the record could be deleted.

  • :invalid when the record could not be deleted.

Returns nothing.



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

def call
  destroy_process_group
  broadcast(:ok)
rescue ActiveRecord::RecordNotDestroyed
  broadcast(:invalid)
end