Class: Decidim::Accountability::Admin::ImportComponentToAccountability
- Inherits:
-
Command
- Object
- Command
- Decidim::Accountability::Admin::ImportComponentToAccountability
- Defined in:
- app/commands/decidim/accountability/admin/import_component_to_accountability.rb
Overview
A command with all the business logic when an admin imports projects from one component to accountability.
Instance Attribute Summary collapse
-
#form ⇒ Object
readonly
Returns the value of attribute form.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form) ⇒ ImportComponentToAccountability
constructor
Public: Initializes the command.
Constructor Details
#initialize(form) ⇒ ImportComponentToAccountability
Public: Initializes the command.
form - A form object with the params.
14 15 16 |
# File 'app/commands/decidim/accountability/admin/import_component_to_accountability.rb', line 14 def initialize(form) @form = form end |
Instance Attribute Details
#form ⇒ Object (readonly)
Returns the value of attribute form.
9 10 11 |
# File 'app/commands/decidim/accountability/admin/import_component_to_accountability.rb', line 9 def form @form end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 |
# File 'app/commands/decidim/accountability/admin/import_component_to_accountability.rb', line 18 def call return broadcast(:invalid) unless form.valid? job_class.perform_later(selected_items.pluck(:id), form.current_component, form.current_user) broadcast(:ok, selected_items.count) end |