niftie-multiton 0.1.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/multiton.rb +8 -4
- data/multiton.gemspec +3 -2
- metadata +3 -3
data/lib/multiton.rb
CHANGED
@@ -2,20 +2,24 @@ require 'thread'
|
|
2
2
|
|
3
3
|
module Multiton
|
4
4
|
|
5
|
-
POOLS = Hash.new { |hash, key| hash[key] = Hash.new }
|
6
5
|
MUTEX = Mutex.new
|
6
|
+
POOLS = Hash.new { |hash, key| hash[key] = Hash.new }
|
7
7
|
|
8
8
|
def Multiton.append_features(base)
|
9
9
|
|
10
10
|
def base.instance(*args, &block)
|
11
|
-
|
12
|
-
|
11
|
+
key = if respond_to?(:multiton_key)
|
12
|
+
multiton_key(*args, &block)
|
13
13
|
else
|
14
14
|
args
|
15
15
|
end
|
16
16
|
|
17
17
|
Multiton::MUTEX.synchronize do
|
18
|
-
Multiton::POOLS[self][
|
18
|
+
Multiton::POOLS[self][key] ||= if respond_to?(:multiton_new)
|
19
|
+
multiton_new(*args, &block)
|
20
|
+
else
|
21
|
+
new(*args, &block)
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
data/multiton.gemspec
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'multiton'
|
3
|
+
s.homepage = 'http://github.com/niftie/multiton'
|
3
4
|
s.author = 'Nicolas Steenlant'
|
4
5
|
s.email = 'nicolas.steenlant@gmail.com'
|
5
|
-
s.version = '0.
|
6
|
-
s.date = '2008-11-
|
6
|
+
s.version = '0.2'
|
7
|
+
s.date = '2008-11-21'
|
7
8
|
s.summary = ''
|
8
9
|
s.files = ['multiton.gemspec', 'lib/multiton.rb']
|
9
10
|
s.require_path = 'lib'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: niftie-multiton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.2"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Steenlant
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-21 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -25,7 +25,7 @@ files:
|
|
25
25
|
- multiton.gemspec
|
26
26
|
- lib/multiton.rb
|
27
27
|
has_rdoc: false
|
28
|
-
homepage:
|
28
|
+
homepage: http://github.com/niftie/multiton
|
29
29
|
post_install_message:
|
30
30
|
rdoc_options: []
|
31
31
|
|