Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
Bumped version to 0.1.3 and rebuilt
Browse files Browse the repository at this point in the history
  • Loading branch information
sagacity committed Jul 2, 2012
1 parent 9684982 commit 2ccab4f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build/fragments/version.txt
@@ -1 +1 @@
0.1.2-beta
0.1.3-beta
35 changes: 28 additions & 7 deletions build/output/intravenous-latest.debug.js
@@ -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)

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand All @@ -103,6 +105,7 @@ exportSymbol('version', intravenous.version);
var singletonLifecycle = function(container, parentLifecycle) {
this.container = container;
this.cache = [];
this.refCounts = {};
this.parent = parentLifecycle;
};

Expand All @@ -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) {
Expand Down Expand Up @@ -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.
Expand All @@ -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 = {
Expand Down
19 changes: 10 additions & 9 deletions build/output/intravenous-latest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ccab4f

Please sign in to comment.