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 |
# File 'lib/dry/auto_inject/dependency_map.rb', line 27 def inspect = @map.inspect |
#names ⇒ Object
29 30 31 |
# File 'lib/dry/auto_inject/dependency_map.rb', line 29 def names @names ||= @map.keys end |
#to_h ⇒ Object Also known as: to_hash
33 |
# File 'lib/dry/auto_inject/dependency_map.rb', line 33 def to_h = @map.dup |