-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9efe04d
commit 7119895
Showing
1 changed file
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,48 @@ | ||
var path = require('canonical-path'); | ||
// Load modules. | ||
var path = require('canonical-path') | ||
, deprecate = require('depd')('electrolyte'); | ||
|
||
|
||
function UsingContainer(c, ns) { | ||
/** | ||
* Container wrapper used when initializing a source. | ||
* | ||
* When a source of objects is `use()`ed, it is given an opportunity to | ||
* initialize the hosting container. This wrapper provides the interface to | ||
* perform initialization, and restricts inadvertent use of other functionality | ||
* in the wrapped container. | ||
* | ||
* @constructor | ||
* @api private | ||
*/ | ||
function HostingContainer(c, ns) { | ||
this._c = c; | ||
this._ns = ns || ''; | ||
} | ||
|
||
UsingContainer.prototype.register = function(id) { | ||
/** | ||
* Declare an object specification. | ||
* | ||
* This function is used by a source to declare an object specification. | ||
* | ||
* By default, specifications are automatically loaded when an object is | ||
* created. As such, there is typically no need to declare specifications | ||
* ahead of time. | ||
* | ||
* Higher-level frameworks implement support for auto-wiring objects and loading | ||
* plugins based on annotations. In such cases, the specification is needed | ||
* prior to the object being created in order to introspect the annotations. | ||
* Sources can provide such specifications by calling this function. | ||
* | ||
* @constructor | ||
* @api public | ||
*/ | ||
HostingContainer.prototype.spec = function(id) { | ||
id = path.join(this._ns, id); | ||
this._c._loadSpec(id); | ||
return this; | ||
} | ||
HostingContainer.prototype.register = deprecate.function(HostingContainer.prototype.spec, 'Container#register: Use Container#spec instead'); | ||
|
||
|
||
module.exports = UsingContainer; | ||
// Expose constructor. | ||
module.exports = HostingContainer; |