niftie-multiton 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/multiton.rb +3 -5
- data/multiton.gemspec +1 -1
- metadata +1 -1
data/lib/multiton.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'thread'
|
2
2
|
|
3
3
|
module Multiton
|
4
|
-
|
5
4
|
MUTEX = Mutex.new
|
6
|
-
POOLS =
|
5
|
+
POOLS = {}
|
7
6
|
|
8
|
-
def
|
7
|
+
def self.append_features(base)
|
9
8
|
|
10
9
|
def base.instance(*args, &block)
|
11
10
|
key = if respond_to?(:multiton_key)
|
@@ -15,7 +14,7 @@ module Multiton
|
|
15
14
|
end
|
16
15
|
|
17
16
|
Multiton::MUTEX.synchronize do
|
18
|
-
Multiton::POOLS[self][key] ||= if respond_to?(:multiton_new)
|
17
|
+
(Multiton::POOLS[self] ||= {})[key] ||= if respond_to?(:multiton_new)
|
19
18
|
multiton_new(*args, &block)
|
20
19
|
else
|
21
20
|
new(*args, &block)
|
@@ -24,5 +23,4 @@ module Multiton
|
|
24
23
|
end
|
25
24
|
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
data/multiton.gemspec
CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.homepage = 'http://github.com/niftie/multiton'
|
4
4
|
s.author = 'Nicolas Steenlant'
|
5
5
|
s.email = 'nicolas.steenlant@gmail.com'
|
6
|
-
s.version = '0.
|
6
|
+
s.version = '0.3'
|
7
7
|
s.date = '2008-11-21'
|
8
8
|
s.summary = ''
|
9
9
|
s.files = ['multiton.gemspec', 'lib/multiton.rb']
|