Class: Decidim::Conferences::Admin::UnpublishConferenceSpeaker

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(conference_speaker, current_user) ⇒ UnpublishConferenceSpeaker

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/unpublish_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
33
34
35
36
# File 'app/commands/decidim/conferences/admin/unpublish_conference_speaker.rb', line 24

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

  @conference_speaker = Decidim.traceability.perform_action!(
    :unpublish,
    conference_speaker,
    current_user
  ) do
    conference_speaker.unpublish!
    conference_speaker
  end
  broadcast(:ok, conference_speaker)
end