Class: Decidim::Assemblies::Admin::UnpublishAssembly

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-assemblies/app/commands/decidim/assemblies/admin/unpublish_assembly.rb

Overview

A command that sets an assembly as unpublished.

Instance Method Summary collapse

Constructor Details

#initialize(assembly) ⇒ UnpublishAssembly

Public: Initializes the command.

assembly - A Assembly that will be unpublished



11
12
13
# File 'decidim-assemblies/app/commands/decidim/assemblies/admin/unpublish_assembly.rb', line 11

def initialize(assembly)
  @assembly = assembly
end

Instance Method Details

#callObject

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.



21
22
23
24
25
26
# File 'decidim-assemblies/app/commands/decidim/assemblies/admin/unpublish_assembly.rb', line 21

def call
  return broadcast(:invalid) if assembly.nil? || !assembly.published?

  assembly.unpublish!
  broadcast(:ok)
end