Class: Decidim::Admin::CreateImport
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::CreateImport
- Defined in:
- app/commands/decidim/admin/create_import.rb
Instance Attribute Summary collapse
-
#form ⇒ Object
readonly
Returns the value of attribute form.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form) ⇒ CreateImport
constructor
A new instance of CreateImport.
Constructor Details
#initialize(form) ⇒ CreateImport
Returns a new instance of CreateImport.
6 7 8 |
# File 'app/commands/decidim/admin/create_import.rb', line 6 def initialize(form) @form = form end |
Instance Attribute Details
#form ⇒ Object (readonly)
Returns the value of attribute form.
25 26 27 |
# File 'app/commands/decidim/admin/create_import.rb', line 25 def form @form end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/commands/decidim/admin/create_import.rb', line 10 def call return broadcast(:invalid) if form.invalid? imported_data = form.importer.prepare transaction do form.importer.import! broadcast(:ok, imported_data) rescue StandardError # Something went wrong with import/finish broadcast(:invalid) raise ActiveRecord::Rollback end end |