Class: Decidim::Consultations::Admin::PublishConsultationResults
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Consultations::Admin::PublishConsultationResults
- Defined in:
- app/commands/decidim/consultations/admin/publish_consultation_results.rb
Overview
A command that sets a consultation results as published.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(consultation) ⇒ PublishConsultationResults
constructor
Public: Initializes the command.
Constructor Details
#initialize(consultation) ⇒ PublishConsultationResults
Public: Initializes the command.
consultation - A Consultation that will get its results published
11 12 13 |
# File 'app/commands/decidim/consultations/admin/publish_consultation_results.rb', line 11 def initialize(consultation) @consultation = consultation 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.
21 22 23 24 25 26 |
# File 'app/commands/decidim/consultations/admin/publish_consultation_results.rb', line 21 def call return broadcast(:invalid) if consultation.nil? || consultation.results_published? consultation.publish_results! broadcast(:ok) end |