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

Inherits:
Command
  • Object
show all
Defined in:
decidim-accountability/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

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

Constructor Details

#initialize(form) ⇒ ImportProjectsToAccountability

Public: Initializes the command.

form - A form object with the params.



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

def initialize(form)
  @form = form
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject



16
17
18
19
20
21
# File 'decidim-accountability/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