Sha256: d6a3bd98a52ae9b3bdea8b87fac1e39ab63d8e57074cbdc2b53a02f8932e0cae

Contents?: true

Size: 587 Bytes

Versions: 25

Compression:

Stored size: 587 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    class CreateImport < Decidim::Command
      def initialize(form)
        @form = form
      end

      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

      attr_reader :form
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/commands/decidim/admin/create_import.rb
decidim-admin-0.28.4 app/commands/decidim/admin/create_import.rb
decidim-admin-0.27.9 app/commands/decidim/admin/create_import.rb
decidim-admin-0.29.0 app/commands/decidim/admin/create_import.rb
decidim-admin-0.28.3 app/commands/decidim/admin/create_import.rb
decidim-admin-0.27.8 app/commands/decidim/admin/create_import.rb
decidim-admin-0.29.0.rc4 app/commands/decidim/admin/create_import.rb
decidim-admin-0.29.0.rc3 app/commands/decidim/admin/create_import.rb
decidim-admin-0.29.0.rc2 app/commands/decidim/admin/create_import.rb
decidim-admin-0.29.0.rc1 app/commands/decidim/admin/create_import.rb
decidim-admin-0.28.2 app/commands/decidim/admin/create_import.rb
decidim-admin-0.27.7 app/commands/decidim/admin/create_import.rb
decidim-admin-0.28.1 app/commands/decidim/admin/create_import.rb
decidim-admin-0.27.6 app/commands/decidim/admin/create_import.rb
decidim-admin-0.28.0 app/commands/decidim/admin/create_import.rb
decidim-admin-0.27.5 app/commands/decidim/admin/create_import.rb
decidim-admin-0.28.0.rc5 app/commands/decidim/admin/create_import.rb
decidim-admin-0.28.0.rc4 app/commands/decidim/admin/create_import.rb
decidim-admin-0.27.4 app/commands/decidim/admin/create_import.rb
decidim-admin-0.27.3 app/commands/decidim/admin/create_import.rb