bulk_loader 0.4.0 → 1.0.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: 3c541ceae40e662f6293d6ebbe4bc9c8141753c6f981cf45a24bf1ec11321d75
4
- data.tar.gz: fc40676969a8e053ceeb169b5875c7d16db9c35df305d6c7dc8e3b15e3626ed2
3
+ metadata.gz: 905e932ce017b63197cd743a2c856e50def0c6d52083d5c287a6d1463124f0e3
4
+ data.tar.gz: a6481e11d19e6eb455d5f54c5a2f9e736561cdd9c6dbe7ff3053ac06e9e7a711
5
5
  SHA512:
6
- metadata.gz: 5be2829886069c7724ae63448df7c754215b7b77907036d828a969bb4d6c07bde51c63f04b3f33fe2efeba545b87fc8ce4c462aae037c36a25a8208c4f7b21a1
7
- data.tar.gz: 8dd6c6b5fd710cfd8e5650b0027a1b29c8ee27de8424ce1d829ef8cf84ee62ab00ed7644d1e557e85d219561e1b181ac00043838c3ad9db340c71cc6703ebefa
6
+ metadata.gz: 8a2ef5b610d4635c521f0a04fef831e19b1b330473054cd2b99d8da340f6433bced83c2683f8b9125d5a186ce5c0a7fca31c8aa54a99501c85d1e629f42a81af
7
+ data.tar.gz: 49747836ca7331d9134deaad2ac9840a51c92a7ec0a5e48fc845e862a69300ce1cd1c035ec84be39258fe80d86caf448dd71019b6912b90260be788ad0bf4b2c
@@ -2,8 +2,7 @@
2
2
 
3
3
  module BulkLoader
4
4
  class Attribute
5
- def initialize(cattr, target)
6
- @class_attribute = cattr
5
+ def initialize(target)
7
6
  @target = target
8
7
  @lazy_of ||= {}
9
8
  end
@@ -12,22 +11,38 @@ module BulkLoader
12
11
  @lazy_of[name] ||= BulkLoader::Lazy.new(@target)
13
12
  end
14
13
 
14
+ def marshal_dump
15
+ {
16
+ target: @target,
17
+ lazy_of: @lazy_of
18
+ }
19
+ end
20
+
21
+ def marshal_load(obj)
22
+ @target = obj[:target]
23
+ @lazy_of = obj[:lazy_of]
24
+ end
25
+
26
+ def class_attribute
27
+ @target.class.bulk_loader
28
+ end
29
+
15
30
  private
16
31
 
17
32
  def method_missing(name, *args)
18
- return super unless @class_attribute.include?(name)
33
+ return super unless class_attribute.include?(name)
19
34
 
20
35
  names = [name].freeze
21
36
  define_singleton_method(name) do
22
37
  attr = lazy(name)
23
- @class_attribute.load(names, [self]) unless attr.loaded?
38
+ class_attribute.load(names, [self]) unless attr.loaded?
24
39
  attr.get
25
40
  end
26
41
  public_send(name)
27
42
  end
28
43
 
29
44
  def respond_to_missing?(name, include_private)
30
- return true if @class_attribute.include?(name)
45
+ return true if class_attribute.include?(name)
31
46
 
32
47
  super
33
48
  end
@@ -36,8 +36,7 @@ module BulkLoader
36
36
  def bulk_loader
37
37
  return @bulk_loader if @bulk_loader
38
38
 
39
- class_attribute = self.class.bulk_loader
40
- @bulk_loader = BulkLoader::Attribute.new(class_attribute, self)
39
+ @bulk_loader = BulkLoader::Attribute.new(self)
41
40
  end
42
41
  end
43
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulkLoader
4
- VERSION = '0.4.0'
4
+ VERSION = '1.0.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.4.0
4
+ version: 1.0.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-10 00:00:00.000000000 Z
11
+ date: 2019-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler