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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6366250c8436b7ac8f13cbdb141c00df330b3b3
4
- data.tar.gz: 5539558b8a792c39d348d26dc99ab1eefef1f291
3
+ metadata.gz: 11ba99c68dd1b15fafd5d94f4894771637c61978
4
+ data.tar.gz: c89aedd4e8a66677eeba1d83b6f767b95054f50f
5
5
  SHA512:
6
- metadata.gz: fa432f1b19cef264335f41bada27a5acee05263ba05c5c0ff40ea897b761ee18f6445a5196ee19400c5c2d851d919307de4c556785fc9467aaf3c40dbe04ee12
7
- data.tar.gz: 2dd9517311e3f10047874923c36ad2222b22561c158dd4e43ba86eff2524afdbe4539ebd1eb896702bd8674901679a5a0e8d7fad4b988fc0c7ede1cd74c3b18c
6
+ metadata.gz: e47b532597878dfa9411e07112624e2d7f10a38bf357003c9a1ea5639b1552b8ec7eacab76b590a9b2fc5285b03ebcaa0901723e1cceb8e9e6707f7ace071926
7
+ data.tar.gz: 05d52093ad104295682b173916b0d6541a11d66f1bf122b2523796d12e72f557d6544f1655ab35d8c2bd531ed30e97c0d9d3e9f927385178d4bfcfe0f2a67ff4
@@ -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 &registrator 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) || mutexes[name].synchronize {
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
@@ -1,4 +1,4 @@
1
1
  module DiFtw
2
2
  # Library version
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.3.1'.freeze
4
4
  end
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.0
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-12 00:00:00.000000000 Z
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