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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8729f794b1c8ace3c08caeed84399b2ff8a997aeb7d623b05f132de9ac12ce94
4
- data.tar.gz: bdb84ea9e8ad25667a74846581d0e34ac5570d76141e446c4d2e9a3752fe3e91
3
+ metadata.gz: b6c5950fbf60618a001ef18c46c8331faf75113cfdf3342b17268b00dd5be46d
4
+ data.tar.gz: 37b6f77d11d21c8c6f38dd45a3826beb2386e1f4616c929d5d7d289bf3ee77f3
5
5
  SHA512:
6
- metadata.gz: 3470647f410a12da9f6b8d5711ba1b2b49d24b9c3a3995dcb96fd8db306fe50a339a4480d46192b786e1053205285382eeac69850cab7bb6fb5f78631253931a
7
- data.tar.gz: 9e6fba88b0fb93af73c05dd301db9a64ae0874c2d711817279454d3d104d9f3994c4cab12e02767d223defda77945f5e2c147adf78a1e5eb9daa787d1d1bfcd4
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
- perform_model_callback(object, :before_import_attributes, new_attrs)
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
@@ -1,3 +1,3 @@
1
1
  module RailsAdminImport
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
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.1
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-10 00:00:00.000000000 Z
12
+ date: 2022-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails