Class: SmartConfig::Walker
- Inherits:
-
Object
- Object
- SmartConfig::Walker
- Defined in:
- lib/smart_config/walker.rb
Overview
Loads the data from any configured source and walks through it to find values
Instance Method Summary collapse
-
#initialize(sources) ⇒ Walker
constructor
A new instance of Walker.
- #walk(path) ⇒ Object
Constructor Details
#initialize(sources) ⇒ Walker
Returns a new instance of Walker.
11 12 13 |
# File 'lib/smart_config/walker.rb', line 11 def initialize(sources) @sources = sources end |
Instance Method Details
#walk(path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/smart_config/walker.rb', line 15 def walk(path) data.filter_map do |d| next if d[:data].nil? case d[:strategy] when :nested d[:data].dig(*path.split('.')) when :flat d[:data][path.tr('.', '_')] end end end |