csv_step_importer 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec7251ef8072cca79a680527151dc2f4a1660a99be40284aeec178a0d60efb64
4
- data.tar.gz: 560b7c75e61b67b27fca2f3cb3c4074c4c6899ae853e1c3fb97d1201135f7f4d
3
+ metadata.gz: 4101e937149c860c8321d7f620c5108ce505ba6de6bb37602b59405e08ae0d9c
4
+ data.tar.gz: 5c739f6d4cb08a19d11e12618e4844bad5b90a66fe785fc5366142230cb6e90e
5
5
  SHA512:
6
- metadata.gz: e76e8585b7ddae0285cc70c16b6428d31a33f7dd8f820641d72396310a296f0f9dffb8be7eed2623e730ff02832663ffb862a647963214a0933720fc1d981c80
7
- data.tar.gz: 5ccef6b27d06d85a02078ffc0abc84cf8c831853bb19422fcda85d8b6844b21b415ca02b2e22ef0f6898a4b519465a1d9046205d259794d4a5dac8d9fb13fc10
6
+ metadata.gz: d231814e8ce5bbd30f664a52bcde75ff192b03d2cfbd338e1bdb70ed72025b939c43165d6b9a3afef5de9d9a31dfe917e149c5f9db77249dbc4098afeda30900
7
+ data.tar.gz: 5f2f9d7ebebf2c0ffd73106a7fd658a22a0a95d9440202a0769e0ce3f635546ab51c6664cee8f76c490c85c0d402921941363cf30c2427d64dfc87b558b30bc9
@@ -31,7 +31,8 @@ module CSVStepImporter
31
31
  end
32
32
 
33
33
  # example [:email, :updated_at]
34
- def updatable_columns
34
+ # see: https://github.com/zdennis/activerecord-import/wiki/On-Duplicate-Key-Update
35
+ def on_duplicate_key_update
35
36
  raise "please extend and implement"
36
37
  end
37
38
 
@@ -5,18 +5,16 @@ module CSVStepImporter
5
5
  class Importer < CSVStepImporter::Node
6
6
  attr_accessor :dao_values
7
7
 
8
- validate :validate_updatable_columns, unless: -> { updatable_columns.any? { |column| column.is_a?(Hash) } }
9
-
10
8
  delegate :model_class, to: :parent
11
9
  delegate :columns, to: :parent
12
- delegate :updatable_columns, to: :parent
10
+ delegate :on_duplicate_key_update, to: :parent
13
11
  delegate :dao_values, to: :parent
14
12
 
15
13
  def create_or_update
16
14
  model_class.import(
17
15
  columns,
18
16
  dao_values,
19
- on_duplicate_key_update: updatable_columns,
17
+ on_duplicate_key_update: on_duplicate_key_update,
20
18
  validate: false,
21
19
  timestamps: false,
22
20
  )
@@ -28,14 +26,6 @@ module CSVStepImporter
28
26
  self.values = values
29
27
  save!
30
28
  end
31
-
32
- def validate_updatable_columns
33
- return unless errors.empty?
34
-
35
- if (updatable_columns - columns).present?
36
- errors[:updatable_columns] << "updatable_columns must be subset of columns"
37
- end
38
- end
39
29
  end
40
30
  end
41
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CSVStepImporter
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_step_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian-Manuel Butzke