Module: ActiveAdminImport::Options

Defined in:
lib/active_admin_import/options.rb

Constant Summary collapse

VALID_OPTIONS =
[
  :back,
  :csv_options,
  :validate,
  :batch_size,
  :batch_transaction,
  :before_import,
  :after_import,
  :before_batch_import,
  :after_batch_import,
  :on_duplicate_key_update,
  :timestamps,
  :ignore,
  :template,
  :template_object,
  :resource_class,
  :resource_label,
  :plural_resource_label,
  :error_limit,
  :headers_rewrites,
  :if
].freeze

Class Method Summary collapse

Class Method Details

.options_for(config, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/active_admin_import/options.rb', line 27

def self.options_for(config, options = {})
  unless options.key? :template_object
    options[:template_object] = -> { ActiveAdminImport::Model.new }
  end

  {
    back: { action: :import },
    csv_options: {},
    template: 'admin/import',
    resource_class: config.resource_class,
    resource_label: config.resource_label,
    plural_resource_label: config.plural_resource_label,
    error_limit: 5,
    headers_rewrites: {},
    if: true
  }.deep_merge(options)
end