| Class | Needle::Lifecycle::Singleton |
| In: |
lib/needle/lifecycle/singleton.rb
|
| Parent: | Needle::Pipeline::Element |
The instantiation pipeline element that enforces the singleton multiplicity.
Returns the cached reference, if it has been previously cached. Otherwise, invokes the next element in the pipeline and caches the result. The cached reference is returned.
# File lib/needle/lifecycle/singleton.rb, line 38
38: def call( container, point )
39: unless @is_cached
40: @mutex.synchronize do
41: unless @is_cached
42: @cached = succ.call( container, point )
43: @is_cached = true
44: end
45: end
46: end
47:
48: @cached
49: end