Class: Dio::InjectorStore Private
- Inherits:
-
Object
- Object
- Dio::InjectorStore
- Defined in:
- lib/dio/injector_store.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
InjectorStore manages Dio::Injector instances.
Instance Method Summary collapse
- #ids ⇒ Object private
-
#initialize(injectors = {}) ⇒ InjectorStore
constructor
private
A new instance of InjectorStore.
- #load(id) ⇒ Object private
- #register(id, injector = nil) ⇒ Object private
- #remove(id) ⇒ Object private
Constructor Details
#initialize(injectors = {}) ⇒ InjectorStore
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of InjectorStore.
9 10 11 |
# File 'lib/dio/injector_store.rb', line 9 def initialize(injectors = {}) @injectors = injectors end |
Instance Method Details
#ids ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/dio/injector_store.rb', line 34 def ids @injectors.keys end |
#load(id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/dio/injector_store.rb', line 26 def load(id) @injectors[id] end |
#register(id, injector = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dio/injector_store.rb', line 13 def register(id, injector = nil) if @injectors.key?(id) injector ||= @injectors[id] if injector != @injectors[id] raise "Injector ID #{id} is already used for another injector" end elsif injector.nil? injector = Dio::Injector.new end @injectors[id] = injector end |
#remove(id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/dio/injector_store.rb', line 30 def remove(id) @injectors.remove(id) end |