electrolyte
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -64,3 +64,3 @@ // Load modules. | ||
*/ | ||
Component.prototype.create = function(container) { | ||
Component.prototype.create = function(container, options) { | ||
debug('create %s', this.id); | ||
@@ -78,4 +78,11 @@ | ||
for (i = 0, len = deps.length; i < len; ++i) { | ||
promise = container.create(deps[i], this); | ||
promises.push(promise); | ||
if (deps[i][0] == ':') { | ||
// TODO: test case for this. | ||
// inject named parameters | ||
var param = deps[i].slice(1); | ||
promises.push(options[param]); | ||
} else { | ||
promise = container.create(deps[i], this); | ||
promises.push(promise); | ||
} | ||
} | ||
@@ -82,0 +89,0 @@ |
@@ -26,12 +26,13 @@ // Load modules. | ||
* specification defines the requirements necessary to create an object. Such | ||
* requirements include the objects required by the object being created. When | ||
* an object requires other objects, the required objects will be created prior | ||
* to the requiring object, and so on, transitively assembling the complete | ||
* graph of objects as necessary. Component specifications, and the objects | ||
* created from them, are often colloquially referred to as simply "components." | ||
* requirements include parameters and other objects required by the object | ||
* being created. When an object requires other objects, the required objects | ||
* will be created prior to the requiring object, and so on, transitively | ||
* assembling the complete graph of objects as necessary. Component | ||
* specifications, and the objects created from them, are often colloquially | ||
* referred to as simply "components." | ||
* | ||
* A component specification can request objects that conform to an interface. | ||
* An interface declares the abstract behavior of an object, without concern | ||
* for implementation details. The container will dynamically create an object | ||
* that conforms to the interface according to the runtime environment and | ||
* for implementation details. The container will create an object that | ||
* conforms to the interface according to the runtime environment and | ||
* configuration. This component-based approach to software development | ||
@@ -131,3 +132,3 @@ * increases modularity of the system. | ||
*/ | ||
Container.prototype.create = function(id, parent, ecomp) { | ||
Container.prototype.create = function(id, parent, ecomp, options) { | ||
// built-ins | ||
@@ -145,3 +146,3 @@ switch (id) { | ||
// assembly, or by the main script. | ||
return resolve(comp.create(self)); | ||
return resolve(comp.create(self, options)); | ||
} else { | ||
@@ -161,3 +162,3 @@ // The object is being created by an object from another assembly. | ||
} | ||
return resolve(comp.create(self)); | ||
return resolve(comp.create(self, options)); | ||
} | ||
@@ -164,0 +165,0 @@ } |
@@ -9,4 +9,4 @@ function ExposedComponent(comp, ic) { | ||
ExposedComponent.prototype.create = function() { | ||
return this._ic.create(this.id, this._comp); | ||
ExposedComponent.prototype.create = function(options) { | ||
return this._ic.create(this.id, this._comp, options); | ||
} | ||
@@ -13,0 +13,0 @@ |
@@ -41,4 +41,4 @@ // Load modules. | ||
*/ | ||
InjectedContainer.prototype.create = function(id, comp) { | ||
return this._c.create(id, this._parent, comp); | ||
InjectedContainer.prototype.create = function(id, comp, options) { | ||
return this._c.create(id, this._parent, comp, options); | ||
} | ||
@@ -45,0 +45,0 @@ |
{ | ||
"name": "electrolyte", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Elegant dependency injection for Node.js.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49371
794