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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 905e932ce017b63197cd743a2c856e50def0c6d52083d5c287a6d1463124f0e3
4
- data.tar.gz: a6481e11d19e6eb455d5f54c5a2f9e736561cdd9c6dbe7ff3053ac06e9e7a711
3
+ metadata.gz: f333c3ac367e36f34c8612ab1d1860e827414d8bd388171bd18f05d23c61325d
4
+ data.tar.gz: 201294000abe22d929ac1ae77c224635d582438442affffe493bc562dd5f06c8
5
5
  SHA512:
6
- metadata.gz: 8a2ef5b610d4635c521f0a04fef831e19b1b330473054cd2b99d8da340f6433bced83c2683f8b9125d5a186ce5c0a7fca31c8aa54a99501c85d1e629f42a81af
7
- data.tar.gz: 49747836ca7331d9134deaad2ac9840a51c92a7ec0a5e48fc845e862a69300ce1cd1c035ec84be39258fe80d86caf448dd71019b6912b90260be788ad0bf4b2c
6
+ metadata.gz: afe87ce84b348f199062486aef49ee2f65601535245e4a3cf4a250ed3c6fd9e0281eb76a20e48a5f322bc9f4ab727c51842fa535bfd2ed9482dedbd173bbb1fd
7
+ data.tar.gz: 0a377a26091d89683874c25d779641e3e876ce72a0ebd63aca3d968af577a3c1cb58bfb6af3d0adad02faae9ed7ba37b49c852d8a5c995aefac51c36b61afb20
@@ -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, lazy_obj_of, mapping_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
- targets.each do |target|
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(target)
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, lazy_obj_of, mapping_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 |target|
58
- lazy_obj_of[target]&.set(value)
56
+ mapping_of[mapped_target].each do |lazy_obj|
57
+ lazy_obj.set(value)
59
58
  end
60
59
  end
61
60
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulkLoader
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
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.0.0
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 00:00:00.000000000 Z
11
+ date: 2019-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler