Class: Decidim::Conferences::Admin::PublishConferenceSpeaker

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

Overview

A command with all the business logic that publishes an existing conference speaker.

Instance Method Summary collapse

Constructor Details

#initialize(conference_speaker, current_user) ⇒ PublishConferenceSpeaker

Public: Initializes the command.

conference_speaker - Decidim::Conferences::Admin::ConferenceSpeaker current_user - the user performing the action



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

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

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the form was not valid and we could not proceed.

Returns nothing.



24
25
26
27
28
29
30
31
32
# File 'app/commands/decidim/conferences/admin/publish_conference_speaker.rb', line 24

def call
  return broadcast(:invalid) if conference_speaker.published?

  transaction do
    publish_conference_speaker
  end

  broadcast(:ok, conference_speaker)
end