Class: Decidim::Problems::Admin::PublishProblem
- Inherits:
-
Command
- Object
- Command
- Decidim::Problems::Admin::PublishProblem
- Defined in:
- app/commands/decidim/problems/admin/publish_problem.rb
Overview
A command that sets a problem as published.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(problem, current_user) ⇒ PublishProblem
constructor
Public: Initializes the command.
Constructor Details
#initialize(problem, current_user) ⇒ PublishProblem
Public: Initializes the command.
problem - A Problem that will be published current_user - the user performing the action
12 13 14 15 16 |
# File 'app/commands/decidim/problems/admin/publish_problem.rb', line 12 def initialize(problem, current_user) super() @problem = problem @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.
24 25 26 27 28 29 30 31 32 |
# File 'app/commands/decidim/problems/admin/publish_problem.rb', line 24 def call return broadcast(:invalid) if problem.nil? || problem.published? Decidim.traceability.perform_action!("publish", problem, current_user, visibility: "all") do problem.publish! end broadcast(:ok) end |