Class: Infusible::DependencyMap

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

Overview

Sanitizes and resolves dependencies for use.

Constant Summary collapse

PATTERNS =
{key: /([a-z_][a-zA-Z_0-9]*)$/, valid: /^[\w.]+$/}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*configuration, patterns: PATTERNS) ⇒ DependencyMap

Returns a new instance of DependencyMap.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/infusible/dependency_map.rb', line 10

def initialize *configuration, patterns: PATTERNS
  @patterns = patterns
  @collection = {}

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

  configuration.each { |identifier| add to_key(identifier), identifier }
  aliases.each { |key, identifier| add key, identifier }

  @keys = collection.keys.freeze
end

Instance Attribute Details

#keysObject (readonly)

Returns the value of attribute keys.



8
9
10
# File 'lib/infusible/dependency_map.rb', line 8

def keys
  @keys
end

Instance Method Details

#to_hObject



22
# File 'lib/infusible/dependency_map.rb', line 22

def to_h = collection