   match = components
 
   while (segment = path.shift())?
-    match[segment] = {} unless segment of match
+    match[segment] = new components.constructor() unless segment of match
     match = match[segment]
     assert _.isObject match
 

  namespace = getNamespace components, path
  return null unless namespace

  namespace[COMPONENTS_FIELD]?[name] or null

setComponent = (components, name, component) ->
  assert _.isObject components


  namespace = createNamespace components, path

  namespace[components.constructor.COMPONENTS_FIELD] ?= new components.constructor()
  assert name not of namespace[components.constructor.COMPONENTS_FIELD]
  namespace[components.constructor.COMPONENTS_FIELD][name] = component

class BaseComponent
  @components: new ComponentsNamespace()

  @register: (componentName, componentClass) ->
    throw new Error "Component name is required for registration." unless componentName
