niftie-multiton 0.2 → 0.3

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.
Files changed (3) hide show
  1. data/lib/multiton.rb +3 -5
  2. data/multiton.gemspec +1 -1
  3. 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 = Hash.new { |hash, key| hash[key] = Hash.new }
5
+ POOLS = {}
7
6
 
8
- def Multiton.append_features(base)
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.2'
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']
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.2"
4
+ version: "0.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Steenlant