Class: Dry::AutoInject::DependencyMap
- Inherits:
-
Object
- Object
- Dry::AutoInject::DependencyMap
- Defined in:
- lib/dry/auto_inject/dependency_map.rb
Instance Method Summary collapse
-
#initialize(*dependencies) ⇒ DependencyMap
constructor
A new instance of DependencyMap.
- #inspect ⇒ Object
- #names ⇒ Object
- #to_h ⇒ Object (also: #to_hash)
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
#inspect ⇒ Object
27 28 29 |
# File 'lib/dry/auto_inject/dependency_map.rb', line 27 def inspect @map.inspect end |
#names ⇒ Object
31 32 33 |
# File 'lib/dry/auto_inject/dependency_map.rb', line 31 def names @names ||= @map.keys end |
#to_h ⇒ Object Also known as: to_hash
35 36 37 |
# File 'lib/dry/auto_inject/dependency_map.rb', line 35 def to_h @map.dup end |