Files

Needle::Lifecycle::Threaded

The instantiation pipeline element that enforces the singleton multiplicity, on a per-thread basis.

Public Instance Methods

call( container, point ) click to toggle source

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
36:       def call( container, point )
37:         cache = service_cache
38:         name = service_point.fullname
39: 
40:         unless cache.has_key?( name )
41:           service = succ.call( container, point )
42:           cache[ name ] = service
43:         end
44: 
45:         cache[ name ]
46:       end
reset!() click to toggle source

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
51:       def reset!
52:         cache = service_cache
53:         cache.delete service_point.fullname
54:       end
service_cache() click to toggle source

Returns a Hash of threaded services that are cached by the current thread.

    # File lib/needle/lifecycle/threaded.rb, line 29
29:       def service_cache
30:         Thread.current[ :threaded_services ] ||= Hash.new
31:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.