This commit is contained in:
Jeremiah Billmann
2013-07-06 14:21:11 -04:00
parent a366576031
commit 8290aa31fa
6 changed files with 42 additions and 7 deletions
+17 -1
View File
@@ -1,3 +1,5 @@
var Entity = require('../entities/entity');
exports = module.exports = EntityController;
function EntityController () {
@@ -6,7 +8,21 @@ function EntityController () {
EntityController.prototype = {
add: function (id) {
var newEntity, entityFound = false;
this.entities.some(function (entity) {
if (entity.id === id) {
newEntity = entity;
entityFound = true;
return true;
}
});
if (!entityFound) {
newEntity = new Entity(id);
this.entities.push(newEntity);
}
return newEntity;
},
remove: function (id) {