Permalink
Browse files

Bumped version to 0.1.3 and rebuilt

  • Loading branch information...
1 parent 9684982 commit 2ccab4f43613ae14981acda9a191bb5e22decc63 @RoyJacobs committed Jul 2, 2012
Showing with 39 additions and 17 deletions.
  1. +1 −1 build/fragments/version.txt
  2. +28 −7 build/output/intravenous-latest.debug.js
  3. +10 −9 build/output/intravenous-latest.js
@@ -1 +1 @@
-0.1.2-beta
+0.1.3-beta
@@ -1,4 +1,4 @@
-// Intravenous JavaScript library v0.1.1-beta
+// Intravenous JavaScript library v0.1.3-beta
// (c) Roy Jacobs
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
@@ -30,7 +30,7 @@ var exportSymbol = function(path, object) {
var exportProperty = function(owner, publicName, object) {
owner[publicName] = object;
};
-intravenous.version = "0.1.1-beta";
+intravenous.version = "0.1.3-beta";
exportSymbol('version', intravenous.version);
(function() {
"use strict";
@@ -84,12 +84,14 @@ exportSymbol('version', intravenous.version);
set: function(cacheItem) {
this.cache.push(cacheItem);
- this.refCounts[cacheItem.registration.key] = this.refCounts[cacheItem.registration.key]++ || 1;
cacheItem.tag = this.tag;
+
+ this.refCounts[cacheItem.tag] = this.refCounts[cacheItem.tag] || {};
+ this.refCounts[cacheItem.tag][cacheItem.registration.key] = this.refCounts[cacheItem.tag][cacheItem.registration.key]++ || 1;
},
release: function(cacheItem) {
- return !--this.refCounts[cacheItem.registration.key];
+ return !--this.refCounts[cacheItem.tag][cacheItem.registration.key];
},
resolveStarted: function(key) {
@@ -103,6 +105,7 @@ exportSymbol('version', intravenous.version);
var singletonLifecycle = function(container, parentLifecycle) {
this.container = container;
this.cache = [];
+ this.refCounts = {};
this.parent = parentLifecycle;
};
@@ -125,10 +128,11 @@ exportSymbol('version', intravenous.version);
set: function(cacheItem) {
this.cache.push(cacheItem);
+ this.refCounts[cacheItem.registration.key] = this.refCounts[cacheItem.registration.key]++ || 1;
},
release: function(cacheItem) {
- return cacheItem.registration.container === this.container;
+ return !--this.refCounts[cacheItem.registration.key];
},
resolveStarted: function(key) {
@@ -321,6 +325,8 @@ exportSymbol('version', intravenous.version);
return instance;
}
+ var returnValue;
+
// Lifecycle didn't have an instance, so we need to create it.
// If the registered value is a function we use it as a constructor.
// Otherwise, we simply return the registered value.
@@ -343,14 +349,29 @@ exportSymbol('version', intravenous.version);
resolvedInjections.push(extraInjections[t]);
}
- reg.value.apply(instance, resolvedInjections);
+ // If the callback returns a function, we consider it to be a custom factory.
+ // This factory is then registered under the same key in the child container.
+ returnValue = reg.value.apply(instance, resolvedInjections);
+ if (returnValue instanceof Function) {
+ instance = new factoryInstance(container, key);
+ instance.container.register(key, returnValue);
+
+ // Copy any static properties owned by the factory
+ for (var propertyName in returnValue) {
+ if (returnValue.hasOwnProperty(propertyName)) instance[propertyName] = returnValue[propertyName];
+ }
+
+ returnValue = undefined;
+ }
} else {
// The registered value is an existing instance.
instance = reg.value;
}
container.lifecycles[reg.lifecycle].set(new cacheItem(reg, instance));
- return instance;
+
+ // If the returnValue is set, we should return that instead of the instance.
+ return returnValue || instance;
};
container.prototype = {

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 2ccab4f

Please sign in to comment.