Class: Decidim::Challenges::Admin::UnpublishChallenge
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Challenges::Admin::UnpublishChallenge
- Defined in:
- app/commands/decidim/challenges/admin/unpublish_challenge.rb
Overview
A command that sets a challenge as unpublished.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(challenge, current_user) ⇒ UnpublishChallenge
constructor
Public: Initializes the command.
Constructor Details
#initialize(challenge, current_user) ⇒ UnpublishChallenge
Public: Initializes the command.
challenge - A Challenge that will be published current_user - the user performing the action
12 13 14 15 16 |
# File 'app/commands/decidim/challenges/admin/unpublish_challenge.rb', line 12 def initialize(challenge, current_user) super() @challenge = challenge @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/challenges/admin/unpublish_challenge.rb', line 24 def call return broadcast(:invalid) if challenge.nil? || !challenge.published? Decidim.traceability.perform_action!("unpublish", challenge, current_user) do challenge.unpublish! end broadcast(:ok) end |