tallty_import_export 1.0.29 → 1.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tallty_import_export/import.rb +3 -1
- data/lib/tallty_import_export/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d508c090e1c1bf676c46ae3bb2d3d2d0c9d3e4d123853894a668262d9ac27ee
|
4
|
+
data.tar.gz: 2f6fee166e44b4e82015a1419da3b7aaad57e71880e26ddcfdfa9fe97cf61572
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96486980954a1b12f804bbebf6c6bcd1e75ebf191b39cf4e22dfc11b36a4bed21502555b1bc8cce413e2ac1285cfdb360435d505f899e5db1b3c19d5ce09eeb0
|
7
|
+
data.tar.gz: 6951da2e23d352e485c28a56b13c03d2789ea4bed2a4ae79207dfebcfa1a8543e70143e8eb68bfd04814cf245ea2c47493468672d4418570049b36af79ee3427
|
@@ -17,6 +17,7 @@ module TalltyImportExport
|
|
17
17
|
# json: model_payload,代表存储在某一个列中
|
18
18
|
# finder: 执行代码,可以查找到相关的对象
|
19
19
|
# proc: proc或者lamda,支持call,传入 val 和 context
|
20
|
+
# skip: 用来综合使用的数据,但是不导入
|
20
21
|
|
21
22
|
# xlsx_file 为 file path or file object or TalltyImportExport::Excel.new
|
22
23
|
def import_xlsx xlsx_file, associations, **options
|
@@ -55,6 +56,7 @@ module TalltyImportExport
|
|
55
56
|
options = import_options.merge(options).with_indifferent_access
|
56
57
|
@headers = options.delete(:headers) || import_headers
|
57
58
|
@primary_keys = options.delete(:primary_keys) || @headers.map { |header| header[:primary_key] ? header[:key].to_sym : nil }.compact
|
59
|
+
@skip_keys = options.delete(:skip_keys) || @headers.map { |header| header[:skip] ? header[:key].to_sym : nil }.compact
|
58
60
|
@params = options
|
59
61
|
context.params = @params
|
60
62
|
|
@@ -152,7 +154,7 @@ module TalltyImportExport
|
|
152
154
|
def import_record line_info, associations
|
153
155
|
if primary_keys.present?
|
154
156
|
_record = associations.find_or_initialize_by(line_info.clone.extract!(*primary_keys))
|
155
|
-
_record.update!(line_info.clone.except!(*primary_keys))
|
157
|
+
_record.update!(line_info.clone.except!(*primary_keys, *@skip_keys))
|
156
158
|
else
|
157
159
|
associations.create!(line_info)
|
158
160
|
end
|