ree_lib 1.0.99 → 1.0.100
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 +40 -11
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper.rb +5 -0
- data/lib/ree_lib/packages/ree_mapper/spec/spec_helper.rb +9 -0
- 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: 436304224d3a8af781f3fe62abf15b08d1843205b69a709bf2bbd441c31e246e
|
4
|
+
data.tar.gz: 2cdb3e48efa52939a43178dd9cae363cdbdbd1bef33509d359e13db0f6c1d017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe254bd39aaae6cd9c3c9d902dcdc48e3ae2c83d6fd1a868aedef47e80209fe6ff51f17c186d8ffe41d3d6e8486c24847ed7cf10670f5c1ac08756f508b5f712
|
7
|
+
data.tar.gz: c9e0f059aea5fd18804149e6e153f58934db60b57de76e3abd421a7f87fb4c28b8f5b8445523cc39a32df293c54584a6853020de12f4a0822a41049e55de218e
|
data/Gemfile.lock
CHANGED
@@ -10,19 +10,50 @@ class ReeMapper::BuildMapperFactory
|
|
10
10
|
link 'ree_mapper/mapper_strategy', -> { MapperStrategy }
|
11
11
|
end
|
12
12
|
|
13
|
+
SEMAPHORE = Mutex.new
|
14
|
+
|
13
15
|
contract(ArrayOf[MapperStrategy] => SubclassOf[MapperFactory])
|
14
16
|
def call(strategies:)
|
15
|
-
|
16
|
-
|
17
|
+
mod = if get_caller.is_a?(Module)
|
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
|
39
|
+
|
40
|
+
mod.instance_variable_set(:@mapper_factory, klass)
|
41
|
+
end
|
42
|
+
|
43
|
+
register_default_types(klass)
|
44
|
+
end
|
17
45
|
|
18
|
-
klass
|
19
|
-
|
46
|
+
klass
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
20
50
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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?
|
26
57
|
|
27
58
|
klass.register_type(:bool, ReeMapper::Bool.new)
|
28
59
|
klass.register_type(:date_time, ReeMapper::DateTime.new)
|
@@ -35,7 +66,5 @@ class ReeMapper::BuildMapperFactory
|
|
35
66
|
klass.register_type(:rational, ReeMapper::Rational.new)
|
36
67
|
|
37
68
|
klass.register_wrapper(:array, ReeMapper::Array)
|
38
|
-
|
39
|
-
klass
|
40
69
|
end
|
41
70
|
end
|
@@ -72,6 +72,8 @@ module ReeMapper
|
|
72
72
|
|
73
73
|
private
|
74
74
|
|
75
|
+
require_relative "./ree_mapper/functions/build_mapper_factory"
|
76
|
+
|
75
77
|
def self.build_mapper_factory(mod)
|
76
78
|
pckg_name = ReeString::Underscore.new.call(mod.name)
|
77
79
|
factory_path = "#{pckg_name}/mapper_factory"
|
@@ -80,6 +82,9 @@ module ReeMapper
|
|
80
82
|
return Object.const_get("#{mod.name}::MapperFactory").new
|
81
83
|
end
|
82
84
|
|
85
|
+
factory = ReeMapper::BuildMapperFactory.new
|
86
|
+
factory.set_caller(mod).call(strategies: [])
|
87
|
+
|
83
88
|
mapper_factory_klass = if package_file_exists?(factory_path) && mod != self
|
84
89
|
package_require(factory_path)
|
85
90
|
Object.const_get("#{mod.name}::MapperFactory")
|
@@ -1,3 +1,12 @@
|
|
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
|
3
7
|
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