bulk_loader 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bulk_loader/loader.rb +7 -8
- data/lib/bulk_loader/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: f333c3ac367e36f34c8612ab1d1860e827414d8bd388171bd18f05d23c61325d
|
4
|
+
data.tar.gz: 201294000abe22d929ac1ae77c224635d582438442affffe493bc562dd5f06c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afe87ce84b348f199062486aef49ee2f65601535245e4a3cf4a250ed3c6fd9e0281eb76a20e48a5f322bc9f4ab727c51842fa535bfd2ed9482dedbd173bbb1fd
|
7
|
+
data.tar.gz: 0a377a26091d89683874c25d779641e3e876ce72a0ebd63aca3d968af577a3c1cb58bfb6af3d0adad02faae9ed7ba37b49c852d8a5c995aefac51c36b61afb20
|
data/lib/bulk_loader/loader.rb
CHANGED
@@ -13,15 +13,13 @@ module BulkLoader
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def load(lazy_objs, *args)
|
16
|
-
lazy_obj_of = lazy_objs.each_with_object({}) { |e, h| h[e.target] = e }
|
17
|
-
|
18
16
|
mapping_of = get_mapping(lazy_objs)
|
19
17
|
|
20
18
|
result_of = call_block(mapping_of, *args)
|
21
19
|
|
22
20
|
lazy_objs.each(&:clear)
|
23
21
|
|
24
|
-
set_result_to_lazy_objs(result_of,
|
22
|
+
set_result_to_lazy_objs(result_of, mapping_of)
|
25
23
|
|
26
24
|
fill_default_to_unloaded_obj(lazy_objs)
|
27
25
|
end
|
@@ -42,20 +40,21 @@ module BulkLoader
|
|
42
40
|
def get_mapping(lazy_objs)
|
43
41
|
mapping_of = {}
|
44
42
|
targets = lazy_objs.map(&:target)
|
45
|
-
|
43
|
+
lazy_objs.each do |lazy_obj|
|
44
|
+
target = lazy_obj.target
|
46
45
|
mapped_target = @is_mapping_proc ? @mapping.call(target) : target.public_send(@mapping)
|
47
46
|
mapping_of[mapped_target] = [] unless mapping_of[mapped_target]
|
48
|
-
mapping_of[mapped_target].push(
|
47
|
+
mapping_of[mapped_target].push(lazy_obj)
|
49
48
|
end
|
50
49
|
mapping_of
|
51
50
|
end
|
52
51
|
|
53
|
-
def set_result_to_lazy_objs(result_of,
|
52
|
+
def set_result_to_lazy_objs(result_of, mapping_of)
|
54
53
|
result_of.each do |mapped_target, value|
|
55
54
|
next unless mapping_of[mapped_target]
|
56
55
|
|
57
|
-
mapping_of[mapped_target].each do |
|
58
|
-
|
56
|
+
mapping_of[mapped_target].each do |lazy_obj|
|
57
|
+
lazy_obj.set(value)
|
59
58
|
end
|
60
59
|
end
|
61
60
|
end
|
data/lib/bulk_loader/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulk_loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiji Yoshimi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|