The instantiation pipeline element that enforces the singleton multiplicity, on a per-thread basis.
Returns the cached reference, if it has been previously cached for the current thread. Otherwise, invokes the next element in the pipeline and caches the result. The cached reference is returned.
# File lib/needle/lifecycle/threaded.rb, line 36 def call( container, point ) cache = service_cache name = service_point.fullname unless cache.has_key?( name ) service = succ.call( container, point ) cache[ name ] = service end cache[ name ] end
Resets the cached singleton instance, so that the next time it is requested it is re-constructed. Only the cache for the current thread and service point is reset.
# File lib/needle/lifecycle/threaded.rb, line 51 def reset! cache = service_cache cache.delete service_point.fullname end
Generated with the Darkfish Rdoc Generator 2.