class ConfigHound::Loader
Constants
- DEFAULT_INCLUDE_KEY
Attributes
include_key[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/config_hound/loader.rb, line 12 def initialize(options = {}) @include_key = DEFAULT_INCLUDE_KEY options.each do |k, v| public_send("#{k}=", v) end end
Public Instance Methods
load(sources)
click to toggle source
# File lib/config_hound/loader.rb, line 19 def load(sources) raw_hashes = Array(sources).map(&method(:load_source)) raw_hashes.reverse.reduce({}, &ConfigHound.method(:deep_merge_into)) end
Private Instance Methods
load_source(source)
click to toggle source
# File lib/config_hound/loader.rb, line 26 def load_source(source) return source if source.is_a?(Hash) resource = Resource[source] raw_data = resource.load includes = Array(raw_data.delete(include_key)) included_resources = includes.map do |relative_path| resource.resolve(relative_path) end ConfigHound.deep_merge_into(load(included_resources), raw_data) end