Class: Decidim::Accountability::Admin::ImportProjectsToAccountability

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/accountability/admin/import_projects_to_accountability.rb

Overview

A command with all the business logic when an admin imports projects from one component to accountability.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ ImportProjectsToAccountability

Public: Initializes the command.

form - A form object with the params.



12
13
14
# File 'app/commands/decidim/accountability/admin/import_projects_to_accountability.rb', line 12

def initialize(form)
  @form = form
end

Instance Method Details

#callObject



16
17
18
19
20
21
# File 'app/commands/decidim/accountability/admin/import_projects_to_accountability.rb', line 16

def call
  return broadcast(:invalid) unless @form.valid?

  ImportProjectsJob.perform_later(projects.pluck(:id), @form.current_component, @form.current_user)
  broadcast(:ok, projects.count)
end