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