 
   lastValue
 
-# We have a special field for components. This allows us to have the namespace with the same name
-# as a component, without overriding anything in the component (we do not want to use component
-# object as a namespace object).
-COMPONENTS_FIELD = ''
+class ComponentsNamespace
+  # We have a special field for components. This allows us to have the namespace with the same name
+  # as a component, without overriding anything in the component (we do not want to use component
+  # object as a namespace object).
+  @COMPONENTS_FIELD: ''
 
 getPathAndName = (name) ->
   assert name


  namespace = createNamespace components, path

  namespace[COMPONENTS_FIELD] ?= {}
  assert name not of namespace[COMPONENTS_FIELD]
  namespace[COMPONENTS_FIELD][name] = component

class BaseComponent
  @components: {}

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

  match = components

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

