I"](function() { App.IdentityMap = (function() { function IdentityMap() {} IdentityMap.imap = {}; IdentityMap.clear = function() { return this.imap = {}; }; IdentityMap.add = function(obj) { var identity; identity = obj.getIdentity(); if (this.imap[identity] == null) { this.imap[identity] = {}; } if (this.imap[identity][obj.id] == null) { this.imap[identity][obj.id] = []; } return this.imap[identity][obj.id][0] = obj; }; IdentityMap.connect = function(obj, opts) { var model; if (opts == null) { opts = {}; } model = opts["with"]; this.add(model); return this.imap[model.getIdentity()][model.id].push(obj); }; IdentityMap.addCollection = function(identity, opts) { if (opts == null) { opts = {}; } if (this.imap[identity] == null) { this.imap[identity] = {}; } if (this.imap[identity]["collection"] == null) { this.imap[identity]["collection"] = []; } if (_.indexOf(this.imap[identity]["collection"], opts.to) !== -1) { return; } return this.imap[identity]["collection"].push(opts.to); }; IdentityMap.all = function(identity) { var arr, id, objs, ref; if (this.imap[identity] == null) { return null; } arr = []; ref = this.imap[identity]; for (id in ref) { objs = ref[id]; if (id === "collection") { continue; } arr.push(objs[0]); } return arr; }; IdentityMap.find = function(klass, id) { if (this.imap[klass] && this.imap[klass][id]) { return this.imap[klass][id][0]; } else { return null; } }; IdentityMap.findConnected = function(klass, id) { var arr; if (this.imap[klass] && this.imap[klass][id] && this.imap[klass][id].length > 1) { arr = this.imap[klass][id]; return arr.slice(1, +(arr.length - 1) + 1 || 9e9); } else { return []; } }; return IdentityMap; })(); }).call(this); :ET