ree_lib 1.0.100 → 1.0.101
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_factory.rb +8 -42
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper.rb +10 -6
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/dsl/dsl_spec.rb +4 -4
- data/lib/ree_lib/packages/ree_mapper/spec/spec_helper.rb +0 -9
- data/lib/ree_lib/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: d1d87d5cb2c9730ec270732d8a4fab58e5b2d2ebd0aca6f5b075c151301a91bf
|
4
|
+
data.tar.gz: 219ad2e3f9543a507985d813c218be53f332e740b376d429f20ce0d68806d75c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 811e76e202564fe0f001c1798bdc6ba91a080581a5c6c16d010e979d227f27298c193d643c3c4ba2553936c39862373dff7153dd8c6639e744a07ca88fed52c3
|
7
|
+
data.tar.gz: 21048d71c59f71efc205d77ae89fcd85c8414ae3fa230a318cb8152fe4c85c28434f13072475d684e7550cf67a6f0b94fdfcdd2b2f614ff89e8c90d1a3efbda9
|
data/Gemfile.lock
CHANGED
@@ -4,56 +4,20 @@ class ReeMapper::BuildMapperFactory
|
|
4
4
|
include Ree::FnDSL
|
5
5
|
|
6
6
|
fn :build_mapper_factory do
|
7
|
-
with_caller
|
8
7
|
link 'ree_mapper/mapper', -> { Mapper }
|
9
8
|
link 'ree_mapper/mapper_factory', -> { MapperFactory }
|
10
9
|
link 'ree_mapper/mapper_strategy', -> { MapperStrategy }
|
11
10
|
end
|
12
11
|
|
13
|
-
SEMAPHORE = Mutex.new
|
14
|
-
|
15
12
|
contract(ArrayOf[MapperStrategy] => SubclassOf[MapperFactory])
|
16
13
|
def call(strategies:)
|
17
|
-
|
18
|
-
get_caller
|
19
|
-
else
|
20
|
-
name = get_caller.class.to_s.split("::").first
|
21
|
-
Object.const_get(name)
|
22
|
-
end
|
23
|
-
|
24
|
-
klass = nil
|
25
|
-
|
26
|
-
SEMAPHORE.synchronize do
|
27
|
-
if klass = mod.instance_variable_get(:@mapper_factory)
|
28
|
-
klass.instance_eval do
|
29
|
-
@strategies = strategies
|
30
|
-
end
|
31
|
-
else
|
32
|
-
klass = Class.new(ReeMapper::MapperFactory)
|
33
|
-
|
34
|
-
klass.instance_eval do
|
35
|
-
@types = {}
|
36
|
-
@wrappers = {}
|
37
|
-
@strategies = strategies
|
38
|
-
end
|
14
|
+
klass = Class.new(ReeMapper::MapperFactory)
|
39
15
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
klass
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def register_default_types(klass)
|
52
|
-
types = klass.instance_variable_get(:@types)
|
53
|
-
strategies = klass.instance_variable_get(:@strategies)
|
54
|
-
|
55
|
-
return if !types.empty?
|
56
|
-
return if strategies.empty?
|
16
|
+
klass.instance_eval {
|
17
|
+
@types = {}
|
18
|
+
@wrappers = {}
|
19
|
+
@strategies = strategies
|
20
|
+
}
|
57
21
|
|
58
22
|
klass.register_type(:bool, ReeMapper::Bool.new)
|
59
23
|
klass.register_type(:date_time, ReeMapper::DateTime.new)
|
@@ -66,5 +30,7 @@ class ReeMapper::BuildMapperFactory
|
|
66
30
|
klass.register_type(:rational, ReeMapper::Rational.new)
|
67
31
|
|
68
32
|
klass.register_wrapper(:array, ReeMapper::Array)
|
33
|
+
|
34
|
+
klass
|
69
35
|
end
|
70
36
|
end
|
@@ -67,13 +67,20 @@ module ReeMapper
|
|
67
67
|
factory = mod.instance_variable_get(:@mapper_factory)
|
68
68
|
return factory if factory
|
69
69
|
|
70
|
-
|
70
|
+
if !mod.instance_variable_get(:@mapper_semaphore)
|
71
|
+
mod.instance_variable_set(:@mapper_semaphore, Mutex.new)
|
72
|
+
end
|
73
|
+
|
74
|
+
mod.instance_variable_get(:@mapper_semaphore).synchronize do
|
75
|
+
factory = self.build_mapper_factory(mod)
|
76
|
+
mod.instance_variable_set(:@mapper_factory, factory)
|
77
|
+
end
|
78
|
+
|
79
|
+
factory
|
71
80
|
end
|
72
81
|
|
73
82
|
private
|
74
83
|
|
75
|
-
require_relative "./ree_mapper/functions/build_mapper_factory"
|
76
|
-
|
77
84
|
def self.build_mapper_factory(mod)
|
78
85
|
pckg_name = ReeString::Underscore.new.call(mod.name)
|
79
86
|
factory_path = "#{pckg_name}/mapper_factory"
|
@@ -82,9 +89,6 @@ module ReeMapper
|
|
82
89
|
return Object.const_get("#{mod.name}::MapperFactory").new
|
83
90
|
end
|
84
91
|
|
85
|
-
factory = ReeMapper::BuildMapperFactory.new
|
86
|
-
factory.set_caller(mod).call(strategies: [])
|
87
|
-
|
88
92
|
mapper_factory_klass = if package_file_exists?(factory_path) && mod != self
|
89
93
|
package_require(factory_path)
|
90
94
|
Object.const_get("#{mod.name}::MapperFactory")
|
@@ -1,12 +1,3 @@
|
|
1
1
|
RSpec.configure do |config|
|
2
2
|
config.extend Ree::RSpecLinkDSL
|
3
|
-
|
4
|
-
config.before :each do
|
5
|
-
reset_mapper_factory(self)
|
6
|
-
end
|
7
3
|
end
|
8
|
-
|
9
|
-
def reset_mapper_factory(mod)
|
10
|
-
mod = Object.const_get(self.class.to_s.split("::").first)
|
11
|
-
mod.instance_variable_set(:@mapper_factory, nil)
|
12
|
-
end
|
data/lib/ree_lib/version.rb
CHANGED