Method: ConfigModule::ConfigHelper#load_namespaces_from

Defined in:
lib/config_module/config_helper.rb

#load_namespaces_from(tree) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/config_module/config_helper.rb', line 40

def load_namespaces_from tree
  namespaces.inject(ConfigOption.wrap(tree)) do |subtree, ns|
    if ConfigOption === subtree && ns.respond_to?(:to_sym) && subtree.has_key?(ns)
      ConfigOption.wrap subtree[ns]
    else
      raise(
        InvalidNamespaceError.new(ns, subtree, caller),
        "No subkey with name: #{ns.inspect}", caller(6)
      )
    end
  end
rescue TypeError
  raise(
    InvalidNamespaceError.new(namespaces.first, self, caller),
    "Namespace must be a string or symbol, instead it was: #{namespaces.first.class}", caller(6)
  )
end