Class: Copland::ServiceModel::ThreadedServiceModel
- Inherits:
-
AbstractServiceModel
- Object
- AbstractServiceModel
- Copland::ServiceModel::ThreadedServiceModel
- Defined in:
- lib/copland/models/threaded.rb
Overview
The threaded service model is much like the singleton service model, except it has one instance of the service point per thread.
Instance Attribute Summary
Attributes inherited from AbstractServiceModel
Instance Method Summary collapse
-
#instance(&init) ⇒ Object
Return the current thread’s instance of the service point.
Methods inherited from AbstractServiceModel
Constructor Details
This class inherits a constructor from Copland::ServiceModel::AbstractServiceModel
Instance Method Details
#instance(&init) ⇒ Object
Return the current thread’s instance of the service point. If no such instance exists, instantiate one.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/copland/models/threaded.rb', line 46 def instance( &init ) Thread.current[ :threaded_services ] ||= Hash.new service = Thread.current[ :threaded_services ][ @service_point.full_name ] unless service service = Proxy.new( @service_point, &init ) Thread.current[ :threaded_services ][ @service_point.full_name ] = service end return service end |