Class: Decidim::Admin::ParticipatorySpace::Unpublish
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::ParticipatorySpace::Unpublish
- Defined in:
- app/commands/decidim/admin/participatory_space/unpublish.rb
Overview
A command that sets a ParticipatorySpace as unpublished.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(participatory_space, user) ⇒ Unpublish
constructor
Public: Initializes the command.
Constructor Details
#initialize(participatory_space, user) ⇒ Unpublish
Public: Initializes the command.
participatory_space - A ParticipatorySpace that will be unpublished user - the user performing the action
12 13 14 15 |
# File 'app/commands/decidim/admin/participatory_space/unpublish.rb', line 12 def initialize(participatory_space, user) @participatory_space = participatory_space @user = user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the data was not valid and we could not proceed.
Returns nothing.
23 24 25 26 27 28 29 30 31 |
# File 'app/commands/decidim/admin/participatory_space/unpublish.rb', line 23 def call return broadcast(:invalid) if participatory_space.nil? || !participatory_space.published? Decidim.traceability.perform_action!(:unpublish, participatory_space, user, **) do participatory_space.unpublish! end broadcast(:ok, participatory_space) end |