Class: Ettin::HashFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/ettin/hash_factory.rb

Overview

Loads and deeply merges targets into a hash structure.

Instance Method Summary collapse

Instance Method Details

#build(*targets) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/ettin/hash_factory.rb', line 11

def build(*targets)
  hash = Hash.new(nil)
  targets
    .flatten
    .map {|target| Source.for(target) }
    .map(&:load)
    .map {|h| h.deep_transform_keys {|key| key.to_s.to_sym } }
    .each {|h| hash.deeper_merge!(h, overwrite_arrays: true) }
  hash
end