bulk_loader 0.1.0 → 0.2.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
- SHA1:
3
- metadata.gz: 291b02e009a7794d095870421c89543837ad2333
4
- data.tar.gz: 186c8a0ab04583ccc99bdfe79769372d1fb34321
2
+ SHA256:
3
+ metadata.gz: 2f597dd144f901e0dfdd7118b2c4b3195f9de24a42344efebfd338bb79b2eb7f
4
+ data.tar.gz: '094b05be80e70f378067597d5197ec849828416513a7a5012b9932f741bca36d'
5
5
  SHA512:
6
- metadata.gz: a5b8fef4a1dbcc0c01fd242dd6d78bbd52ffd0af490e934fe6b7f868f081f0986b43eac89b994e8ef2b8cc24420f6317d952e60a074468eef6d5ed2bc0846893
7
- data.tar.gz: 41d078dca4196b95424f955d30e6da695fe7617dfd64f88e637c2a573e14b717a31ff4c7d73106360589d64f352a706d883499c7c98f655b847fd7558d5f9a11
6
+ metadata.gz: c934949c8af3328af455fd1c0964e594f422346f68efae6a4b5dd58eb0d9cb4ee85b5fb0f0e2d994567d6e2d6ea74760d9dd7186de6ce722bc7d539592ddde2b
7
+ data.tar.gz: 35971ca21b9685d44755697520373484b60bdb68f9f5edbdbca45bec77e30dc5d3a88504526c6beb14ebd1ef55c2d9319fb5ae13db314f09e353d2655162530e
@@ -16,9 +16,10 @@ module BulkLoader
16
16
 
17
17
  def method_missing(name, *args)
18
18
  return super unless @class_attribute.include?(name)
19
+ names = [name].freeze
19
20
  define_singleton_method(name) do
20
21
  attr = lazy(name)
21
- @class_attribute.load([name], [self]) unless attr.loaded?
22
+ @class_attribute.load(names, [self]) unless attr.loaded?
22
23
  attr.get
23
24
  end
24
25
  public_send(name)
@@ -10,6 +10,10 @@ module BulkLoader
10
10
  @loader_of.include?(name)
11
11
  end
12
12
 
13
+ def each(&block)
14
+ @loader_of.each(&block)
15
+ end
16
+
13
17
  def load(loader_names, attributes, *args)
14
18
  attrs = convert_attributes(attributes)
15
19
 
@@ -35,18 +39,14 @@ module BulkLoader
35
39
  end
36
40
 
37
41
  def convert_attributes(attributes)
38
- attrs = []
39
- attributes.each do |attr|
40
- attrs.push(convert_attribute(attr))
41
- end
42
- attrs
42
+ attributes.map(&method(:convert_attribute))
43
43
  end
44
44
 
45
45
  def convert_attribute(attr)
46
- if attr.respond_to?(:lazy)
47
- attr
48
- elsif attr.respond_to?(:bulk_loader)
46
+ if attr.respond_to?(:bulk_loader)
49
47
  attr.bulk_loader
48
+ elsif attr.respond_to?(:lazy)
49
+ attr
50
50
  else
51
51
  raise 'attributes should be BulkLoader::Attribute or BulkLoader::DSL included class!!'
52
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulkLoader
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.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: 0.1.0
4
+ version: 0.2.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: 2017-09-17 00:00:00.000000000 Z
11
+ date: 2017-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 2.5.1
156
+ rubygems_version: 2.6.14
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: utility to avoid N+1 queries