diftw 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diftw/injector.rb +11 -1
- data/lib/diftw/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11ba99c68dd1b15fafd5d94f4894771637c61978
|
4
|
+
data.tar.gz: c89aedd4e8a66677eeba1d83b6f767b95054f50f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e47b532597878dfa9411e07112624e2d7f10a38bf357003c9a1ea5639b1552b8ec7eacab76b590a9b2fc5285b03ebcaa0901723e1cceb8e9e6707f7ace071926
|
7
|
+
data.tar.gz: 05d52093ad104295682b173916b0d6541a11d66f1bf122b2523796d12e72f557d6544f1655ab35d8c2bd531ed30e97c0d9d3e9f927385178d4bfcfe0f2a67ff4
|
data/lib/diftw/injector.rb
CHANGED
@@ -50,6 +50,7 @@ module DiFtw
|
|
50
50
|
@singleton = parent ? parent.singleton : singleton
|
51
51
|
@mutexes = (parent ? parent.mutexes.keys : []).
|
52
52
|
inject({}) { |a, name| a[name] = Mutex.new; a }
|
53
|
+
@metamutex = Mutex.new
|
53
54
|
instance_eval ®istrator if registrator
|
54
55
|
end
|
55
56
|
|
@@ -98,7 +99,7 @@ module DiFtw
|
|
98
99
|
def [](name)
|
99
100
|
if singleton
|
100
101
|
var = "@_singleton_#{name}"
|
101
|
-
instance_variable_get(var) ||
|
102
|
+
instance_variable_get(var) || mutex(name).synchronize {
|
102
103
|
instance_variable_get(var) || instance_variable_set(var, resolve!(name))
|
103
104
|
}
|
104
105
|
else
|
@@ -165,5 +166,14 @@ module DiFtw
|
|
165
166
|
parent[dependency]
|
166
167
|
end
|
167
168
|
end
|
169
|
+
|
170
|
+
private
|
171
|
+
|
172
|
+
def mutex(name)
|
173
|
+
return mutexes[name] unless mutexes[name].nil?
|
174
|
+
@metamutex.synchronize {
|
175
|
+
mutexes[name] = Mutex.new
|
176
|
+
}
|
177
|
+
end
|
168
178
|
end
|
169
179
|
end
|
data/lib/diftw/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diftw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A small dependency injection library for Ruby
|
14
14
|
email: jordan.hollinger@gmail.com
|