Sha256: 7bd51efc2a829d7da1c839e000191872d8af19524679d3cabe8464ff7021a9af
Contents?: true
Size: 439 Bytes
Versions: 1
Compression:
Stored size: 439 Bytes
Contents
require 'weakref' # http://endofline.wordpress.com/2011/01/09/getting-to-know-the-ruby-standard-library-weakref/ class PoroRepository::WeakHash < Hash class AmbivalentRef < WeakRef def __getobj__ super rescue nil end alias actual __getobj__ end def []= key, object super(key, AmbivalentRef.new(object)) end def [] key ref = super(key) self.delete(key) if !ref.weakref_alive? ref end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
poro_repository-0.0.1 | lib/poro_repository/weak_hash.rb |