Class: Decidim::Consultations::Admin::PublishQuestion
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Consultations::Admin::PublishQuestion
- Defined in:
- app/commands/decidim/consultations/admin/publish_question.rb
Overview
A command that sets a question as published.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(question, current_user) ⇒ PublishQuestion
constructor
Public: Initializes the command.
Constructor Details
#initialize(question, current_user) ⇒ PublishQuestion
Public: Initializes the command.
question - A Question that will be published current_user - the user performing the action
12 13 14 15 |
# File 'app/commands/decidim/consultations/admin/publish_question.rb', line 12 def initialize(question, current_user) @question = question @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_question.rb', line 23 def call return broadcast(:invalid) if question.nil? || question.published? Decidim.traceability.perform_action!("publish", question, @current_user, visibility: "all") do question.publish! end broadcast(:ok) end |