{I" class:ETI"ProcessedAsset;FI"logical_path;TI""revelry/data/BackboneStore.js;FI" pathname;TI"a/Users/joel/src/revelreact-rails/app/assets/javascripts/revelry/data/BackboneStore.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+>Š1UI" length;Ti¨I" digest;TI"%bbef0b1974b8caa494b786c5feb8baf5;FI" source;TI"¨(function() { var BackboneStore; Rev.registerObject('BackboneStore', BackboneStore = (function() { BackboneStore.prototype.collections = null; BackboneStore.prototype._fetchers = null; function BackboneStore() { this.collections = {}; this._fetchers = {}; } /* Here is how the following section works: A bunch of entities are requesting a lot of models. Some of those are the same. We want to avoid duplicating fetches. We *do* want to give everyone their notification that the operation is complete. So what we do is keep a ledger like this: fetchers: "users/13": [callback1, callback2] "messages/10": [callback3] "messages/13": [callback4, callback5, callback6] So when user 13 has been fetched (be it successful or failed), it will be cleared from the ledger, and all its callbacks will be fired. */ BackboneStore.prototype._addFetcher = function(key, callback) { var shouldFetch; shouldFetch = true; if ((this._fetchers[key] != null) && this._fetchers[key].length > 0) { shouldFetch = false; } else { this._fetchers[key] = []; } this._fetchers[key].push(callback || function() { return {}; }); return shouldFetch; }; BackboneStore.prototype._flushFetchers = function(key) { var callback, fetchers, _i, _len, _results; fetchers = this._fetchers[key]; delete this._fetchers[key]; _results = []; for (_i = 0, _len = fetchers.length; _i < _len; _i++) { callback = fetchers[_i]; _results.push(callback()); } return _results; }; BackboneStore.prototype._maybeFetch = function(collectionName, modelId, callback) { var attributes, collection, idAttribute, key, klass, model; collection = this.collections[collectionName]; model = collection.get(modelId); callback || (callback = function() { return {}; }); if (model != null) { return callback(); } else { key = collectionName + "/" + modelId; if (this._addFetcher(key, callback)) { klass = collection.model; idAttribute = klass.idAttribute || "id"; attributes = {}; attributes[idAttribute] = modelId; model = new klass(attributes); return model.fetch({ silent: true, success: (function(_this) { return function(model) { _this.put(collectionName, model); return _this._flushFetchers(key); }; })(this), error: (function(_this) { return function() { return _this._flushFetchers(key); }; })(this) }); } } }; BackboneStore.prototype.fetch = function(collectionName, modelIds, callback) { var id, _i, _len, _results; if (!(modelIds instanceof Array)) { modelIds = [modelIds]; } _results = []; for (_i = 0, _len = modelIds.length; _i < _len; _i++) { id = modelIds[_i]; _results.push(this._maybeFetch(collectionName, id, callback)); } return _results; }; BackboneStore.prototype.get = function(collectionName, modelId) { return this.collections[collectionName].get(modelId); }; BackboneStore.prototype.put = function(collectionName, model) { return this.collections[collectionName].add(model); }; BackboneStore.prototype.loadCollection = function(collectionName, klass, data) { var _base; return (_base = this.collections)[collectionName] || (_base[collectionName] = new klass(data)); }; BackboneStore.prototype.prepare = function(props) { return React.createFactory(Rev.Components.ModelPrepper)(props, null); }; return BackboneStore; })()); Rev.registerMixin('BackboneStore', { store: new Rev.BackboneStore() }); }).call(this); ;TI"dependency_digest;TI"%1d6c8a57ec52d78748a08677f71c3d48;FI"required_paths;T[I"j/opt/rubies/2.1.2/lib/ruby/gems/2.1.0/gems/backbone-rails-1.1.2/vendor/assets/javascripts/backbone.js;FI"a/Users/joel/src/revelreact-rails/app/assets/javascripts/revelry/data/BackboneStore.js.coffee;FI"dependency_paths;T[{I" path;TI"a/Users/joel/src/revelreact-rails/app/assets/javascripts/revelry/data/BackboneStore.js.coffee;FI" mtime;TI"2015-04-17T17:33:34-05:00;TI" digest;TI"%18821d3e402ee6263c2cafc70c96bbad;F{@I"j/opt/rubies/2.1.2/lib/ruby/gems/2.1.0/gems/backbone-rails-1.1.2/vendor/assets/javascripts/backbone.js;F@ I"2014-10-30T17:17:21-05:00;T@"I"%60c62a7c3e2cac917a92c34c2e0d1bc3;FI" _version;TI"%7015acab0e7ee10d673b8d49cecfb54b;F