Module: Injectable::Registry
Overview
The registry keeps track of all objects and their dependencies that need to be injected at construction.
Defined Under Namespace
Classes: NotRegistered
Instance Method Summary collapse
-
#implementation(name) ⇒ Class
Get an implementation for the provided name.
-
#register_implementation(name, klass) ⇒ Object
Add an implementing class for a name to the registry.
-
#register_signature(klass, dependencies) ⇒ Object
Add a constructor method signature to the registry.
-
#signature(klass) ⇒ Array<Class>
Get the constructor method signature for the provided class.
Instance Method Details
#implementation(name) ⇒ Class
Get an implementation for the provided name.
21 22 23 |
# File 'lib/injectable/registry.rb', line 21 def implementation(name) implementations[name] || raise(NotRegistered.new(name)) end |
#register_implementation(name, klass) ⇒ Object
Add an implementing class for a name to the registry.
36 37 38 |
# File 'lib/injectable/registry.rb', line 36 def register_implementation(name, klass) implementations[name] = klass end |
#register_signature(klass, dependencies) ⇒ Object
Add a constructor method signature to the registry.
52 53 54 |
# File 'lib/injectable/registry.rb', line 52 def register_signature(klass, dependencies) signatures[klass] = dependencies.map { |name| name } end |
#signature(klass) ⇒ Array<Class>
Get the constructor method signature for the provided class.
66 67 68 |
# File 'lib/injectable/registry.rb', line 66 def signature(klass) signatures[klass] end |