Class: SimpleInjector::Inject
- Inherits:
-
Object
- Object
- SimpleInjector::Inject
- Defined in:
- lib/simple_injector/inject.rb
Overview
Singleton class to save instances and retrieve
Class Attribute Summary collapse
-
.injectables ⇒ Object
Returns the value of attribute injectables.
Class Method Summary collapse
Class Attribute Details
.injectables ⇒ Object
Returns the value of attribute injectables.
11 12 13 |
# File 'lib/simple_injector/inject.rb', line 11 def injectables @injectables end |
Class Method Details
.find(contract_name, name) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/simple_injector/inject.rb', line 17 def find(contract_name, name) injectable = (@injectables[contract_name] ||= []).find { |i| i.name == name } raise InjectableNotFound, "An instance with name '#{name}' was not registered" unless injectable injectable end |
.register(contract_name, name, callback) ⇒ Object
13 14 15 |
# File 'lib/simple_injector/inject.rb', line 13 def register(contract_name, name, callback) (@injectables[contract_name] ||= []) << Injectable.new(name, callback) end |