Class: Decidim::Assemblies::Admin::ImportAssembly

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

Overview

A command with all the business logic to import a new assembly in the system.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ ImportAssembly

Public: Initializes the command.

form - A form object with the params. assembly - An assembly we want to duplicate



13
14
15
# File 'app/commands/decidim/assemblies/admin/import_assembly.rb', line 13

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the form wasn’t valid and we couldn’t proceed.

Returns nothing.



23
24
25
26
27
28
29
30
31
32
# File 'app/commands/decidim/assemblies/admin/import_assembly.rb', line 23

def call
  return broadcast(:invalid) if form.invalid?

  transaction do
    import_assembly
    add_admins_as_followers(@imported_assembly)
  end

  broadcast(:ok, @imported_assembly)
end