Sha256: df6ad2879731e4b8bceb535f639e867c9172b6b1dd92e432976aeea4b67e65c2

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

/**
@module ember
*/
import {
  NAMESPACES,
  NAMESPACES_BY_ID,
  addNamespace,
  findNamespace,
  findNamespaces,
  get,
  processNamespace,
  processAllNamespaces,
  removeNamespace,
} from '@ember/-internals/metal'; // Preloaded into namespaces
import { getName, guidFor, setName } from '@ember/-internals/utils';
import EmberObject from './object';

/**
  A Namespace is an object usually used to contain other objects or methods
  such as an application or framework. Create a namespace anytime you want
  to define one of these new containers.

  # Example Usage

  ```javascript
  MyFramework = Ember.Namespace.create({
    VERSION: '1.0.0'
  });
  ```

  @class Namespace
  @namespace Ember
  @extends EmberObject
  @public
*/
export default class Namespace extends EmberObject {
  init() {
    addNamespace(this);
  }

  toString() {
    let name = get(this, 'name') || get(this, 'modulePrefix');
    if (name) {
      return name;
    }
    findNamespaces();
    name = getName(this);
    if (name === undefined) {
      name = guidFor(this);
      setName(this, name);
    }
    return name;
  }

  nameClasses() {
    processNamespace(this);
  }

  destroy() {
    removeNamespace(this);
    super.destroy();
  }
}

Namespace.prototype.isNamespace = true;
Namespace.NAMESPACES = NAMESPACES;
Namespace.NAMESPACES_BY_ID = NAMESPACES_BY_ID;
Namespace.processAll = processAllNamespaces;
Namespace.byName = findNamespace;

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/-internals/runtime/lib/system/namespace.js