Class: Decidim::Accountability::Admin::ImportProjectsToAccountability
- Inherits:
-
Command
- Object
- Command
- Decidim::Accountability::Admin::ImportProjectsToAccountability
- 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
- #call ⇒ Object
-
#initialize(form) ⇒ ImportProjectsToAccountability
constructor
Public: Initializes the command.
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
#call ⇒ Object
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 |