Class: Decidim::Consultations::Admin::UnpublishQuestion
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Consultations::Admin::UnpublishQuestion
- Defined in:
- app/commands/decidim/consultations/admin/unpublish_question.rb
Overview
A command that sets a question as unpublished.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(question) ⇒ UnpublishQuestion
constructor
Public: Initializes the command.
Constructor Details
#initialize(question) ⇒ UnpublishQuestion
Public: Initializes the command.
question - A Question that will be unpublished
11 12 13 |
# File 'app/commands/decidim/consultations/admin/unpublish_question.rb', line 11 def initialize(question) @question = question 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/unpublish_question.rb', line 21 def call return broadcast(:invalid) if question.nil? || !question.published? question.unpublish! broadcast(:ok) end |