Class: ActiveAdmin::Exportable::Importer

Inherits:
Object
  • Object
show all
Defined in:
lib/active_admin/exportable/importer.rb

Instance Method Summary collapse

Constructor Details

#initialize(path: nil, data: nil, json: nil, yaml: nil, allow_update: false, ignore_ids: false, format: nil) ⇒ Importer

Returns a new instance of Importer.



6
7
8
9
10
11
12
13
# File 'lib/active_admin/exportable/importer.rb', line 6

def initialize(path: nil, data: nil, json: nil, yaml: nil, allow_update: false, ignore_ids: false, format: nil)
  @data = data if data.present?
  @data ||= path_to_data(path, format: format) if path.present?
  @data ||= json_to_data(json) if json.present?
  @data ||= yaml_to_data(yaml) if yaml.present?
  @allow_update = allow_update
  @ignore_ids = ignore_ids
end

Instance Method Details

#importObject



15
16
17
18
19
# File 'lib/active_admin/exportable/importer.rb', line 15

def import
  ActiveRecord::Base.transaction do
    process_associations_content(@data)
  end
end