Class: Dry::AutoInject::DependencyMap

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/auto_inject/dependency_map.rb

Instance Method Summary collapse

Constructor Details

#initialize(*dependencies) ⇒ DependencyMap

Returns a new instance of DependencyMap.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dry/auto_inject/dependency_map.rb', line 11

def initialize(*dependencies)
  @map = {}

  dependencies = dependencies.dup
  aliases = dependencies.last.is_a?(Hash) ? dependencies.pop : {}

  dependencies.each do |identifier|
    name = name_for(identifier)
    add_dependency(name, identifier)
  end

  aliases.each do |name, identifier|
    add_dependency(name, identifier)
  end
end

Instance Method Details

#inspectObject



27
28
29
# File 'lib/dry/auto_inject/dependency_map.rb', line 27

def inspect
  @map.inspect
end

#namesObject



31
32
33
# File 'lib/dry/auto_inject/dependency_map.rb', line 31

def names
  @names ||= @map.keys
end

#to_hObject Also known as: to_hash



35
36
37
# File 'lib/dry/auto_inject/dependency_map.rb', line 35

def to_h
  @map.dup
end