Module: Injectable::Registry
- Extended by:
- Registry
- Includes:
- Registerable
- Included in:
- Registry
- Defined in:
- lib/injectable/registry.rb
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_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.
Methods included from Registerable
Instance Method Details
#implementation(name) ⇒ Class
Get an implementation for the provided name.
24 25 26 27 28 |
# File 'lib/injectable/registry.rb', line 24 def implementation(name) impl = implementations[name] raise(NotRegistered.new(name)) unless impl && !impl.empty? impl end |
#register_signature(klass, dependencies) ⇒ Object
Add a constructor method signature to the registry.
42 43 44 |
# File 'lib/injectable/registry.rb', line 42 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.
56 57 58 |
# File 'lib/injectable/registry.rb', line 56 def signature(klass) signatures[klass] end |