Show:
Module: parch

Constructor

Registry ()

Defined in src/registry.js:11

Methods

_getLookupDirectory
(
  • lookup
)
String
private

Defined in src/registry.js:143

Get the lookup directory for internal modules

Parameters:

  • lookup String

    string name of object we're looking for (e.g. 'module')

Returns:

String:

directory

_loadModule
(
  • lookup
  • name
)
Object
private

Defined in src/registry.js:154

Attempts to load modules by requiring them in locally. Lookup directory is determined by the type of object we're loading (e.g. 'module' => ./) and the name of the module (e.g. 'model-manager') which is underscored

Parameters:

  • lookup String

    string name of object we're looking for (e.g. 'module')

  • name String

    string module name

Returns:

Object:

required module

inject
(
  • context
  • lookup
  • propertyName
)
Object

Defined in src/registry.js:20

Inject an object into another object

Parameters:

  • context Object

    the object to inject onto

  • lookup String

    name by which to look search for the injection in the registry

  • propertyName String

    optional property name of the newly injected object

Returns:

Object:

context

Example:

registry.inject(object, "service:store");
// object.store

registry.inject(object, "service:model-manager", "modelManager");
// object.modelManager
lookup
(
  • name
)
Object

Defined in src/registry.js:67

Find an object in the registry. If the object isn't found in the registry, lookup will attempt to find it by requiring it in. If the require fails the lookup fails

Parameters:

  • name String

    colon delimited lookup string "service:foo"

Returns:

Example:

registry.lookup("service:foo");
register
(
  • name
  • Obj
  • options
)
Object

Defined in src/registry.js:99

Register an object in the registry by name. If the name exists and it was registered with the { singleton: true } option, an error will be thrown.

Parameters:

  • name String

    the name by which to register the object

  • Obj Object

    the object to store in the registry

  • options Object

    register options

    • instantiate Boolean

      instantiate the object when registering it

    • singleton Boolean

      only allow one registration of this name/object

Returns:

Object:

Obj

Example:

registry.register("service:foo", { foo: "bar" });