Class: Decidim::Conferences::Admin::UnpublishRegistrationType

Inherits:
Decidim::Command
  • Object
show all
Defined in:
decidim-conferences/app/commands/decidim/conferences/admin/unpublish_registration_type.rb

Overview

This command gets called when a registration type is unpublished from the admin panel.

Instance Method Summary collapse

Methods inherited from Decidim::Command

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

Constructor Details

#initialize(registration_type, current_user) ⇒ UnpublishRegistrationType

Public: Initializes the command.

registration_type - The registration_type to unpublish. current_user - the user performing the action



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

def initialize(registration_type, current_user)
  @registration_type = registration_type
  @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

Public: Unpublishes the RegistrationType.

Broadcasts :ok if unpublished, :invalid otherwise.



20
21
22
23
24
25
26
27
28
# File 'decidim-conferences/app/commands/decidim/conferences/admin/unpublish_registration_type.rb', line 20

def call
  return broadcast(:invalid) if registration_type.nil? || !registration_type.published?

  Decidim.traceability.perform_action!(:unpublish, registration_type, current_user) do
    registration_type.unpublish!
  end

  broadcast(:ok)
end