rails_admin_import 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_admin_import/importer.rb +10 -7
- data/lib/rails_admin_import/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6c5950fbf60618a001ef18c46c8331faf75113cfdf3342b17268b00dd5be46d
|
4
|
+
data.tar.gz: 37b6f77d11d21c8c6f38dd45a3826beb2386e1f4616c929d5d7d289bf3ee77f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b763676e2157bf7c352633aee545766fe38e9cb97ac75d8bd2edfca5dced0a839f0ede5a6100569f9757a4dc8e5601a93daf89028b61da94b7e56034d79494a9
|
7
|
+
data.tar.gz: f934b8e2f28165b793fdf6f78e5d6b591dbaeef7a8eab8fce94b4f0574a5137025fa3834c9a7131c5f9dbe4bc8cca52ffd85fa726bfa4b783c241407a9c8a03e
|
@@ -190,11 +190,6 @@ module RailsAdminImport
|
|
190
190
|
end
|
191
191
|
|
192
192
|
def find_or_create_object(record, update)
|
193
|
-
field_names = import_model.model_fields.map(&:name)
|
194
|
-
new_attrs = record.select do |field_name, value|
|
195
|
-
field_names.include?(field_name) && !value.blank?
|
196
|
-
end
|
197
|
-
|
198
193
|
model = import_model.model
|
199
194
|
object = if update.present?
|
200
195
|
query = update.each_with_object({}) do
|
@@ -205,10 +200,18 @@ module RailsAdminImport
|
|
205
200
|
|
206
201
|
if object.nil?
|
207
202
|
object = model.new
|
208
|
-
|
203
|
+
end
|
204
|
+
|
205
|
+
perform_model_callback(object, :before_import_attributes, record)
|
206
|
+
|
207
|
+
field_names = import_model.model_fields.map(&:name)
|
208
|
+
new_attrs = record.select do |field_name, value|
|
209
|
+
field_names.include?(field_name) && !value.blank?
|
210
|
+
end
|
211
|
+
|
212
|
+
if object.new_record?
|
209
213
|
object.attributes = new_attrs
|
210
214
|
else
|
211
|
-
perform_model_callback(object, :before_import_attributes, new_attrs)
|
212
215
|
object.attributes = new_attrs.except(update.map(&:to_sym))
|
213
216
|
end
|
214
217
|
object
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steph Skardal
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-04-
|
12
|
+
date: 2022-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|