Class: Dio::InjectorStore Private

Inherits:
Object
  • Object
show all
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.

API:

  • private

Instance Method Summary collapse

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.

API:

  • private



9
10
11
# File 'lib/dio/injector_store.rb', line 9

def initialize(injectors = {})
  @injectors = injectors
end

Instance Method Details

#idsObject

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.

API:

  • private



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.

API:

  • private



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.

API:

  • private



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.

API:

  • private



30
31
32
# File 'lib/dio/injector_store.rb', line 30

def remove(id)
  @injectors.remove(id)
end