Class: Decidim::Conferences::Admin::PublishRegistrationType

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

Overview

This command gets called when a registration_type is published from the admin panel.

Instance Method Summary collapse

Constructor Details

#initialize(registration_type, current_user) ⇒ PublishRegistrationType

Public: Initializes the command.

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



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

def initialize(registration_type, current_user)
  @registration_type = registration_type
  @current_user = current_user
end

Instance Method Details

#callObject

Public: Publishes the Component.

Broadcasts :ok if published, :invalid otherwise.



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

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

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

  broadcast(:ok)
end