Module: Unity::Dependency
- Defined in:
- lib/unity/dependency.rb,
lib/unity/dependency/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
'1.0.1'
Instance Method Summary collapse
- #__dependency_thread_instances__ ⇒ Hash<String, self>
-
#instance ⇒ self
Returns an instance of self attached to the current thread.
Instance Method Details
#__dependency_thread_instances__ ⇒ Hash<String, self>
10 11 12 |
# File 'lib/unity/dependency.rb', line 10 def __dependency_thread_instances__ Thread.current[:__dependency_thread_instances__] ||= {} end |
#instance ⇒ self
Returns an instance of self attached to the current thread
16 17 18 19 20 21 22 |
# File 'lib/unity/dependency.rb', line 16 def instance instances = __dependency_thread_instances__ klass_name = self.name return instances[klass_name] if instances.key?(klass_name) instances[klass_name] = new end |