Class: Decidim::Consultations::Admin::PublishConsultation
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Consultations::Admin::PublishConsultation
- Defined in:
- app/commands/decidim/consultations/admin/publish_consultation.rb
Overview
A command that sets a consultation as published.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(consultation, current_user) ⇒ PublishConsultation
constructor
Public: Initializes the command.
Constructor Details
#initialize(consultation, current_user) ⇒ PublishConsultation
Public: Initializes the command.
consultation - A Consultation that will be published current_user - the user performing the action
12 13 14 15 |
# File 'app/commands/decidim/consultations/admin/publish_consultation.rb', line 12 def initialize(consultation, current_user) @consultation = consultation @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the data wasn’t valid and we couldn’t proceed.
Returns nothing.
23 24 25 26 27 28 29 30 31 |
# File 'app/commands/decidim/consultations/admin/publish_consultation.rb', line 23 def call return broadcast(:invalid) if consultation.nil? || consultation.published? Decidim.traceability.perform_action!("publish", consultation, current_user, visibility: "all") do consultation.publish! end broadcast(:ok) end |