UNPKG

1.95 kBJavaScriptView Raw
1// Generated by CoffeeScript 1.8.0
2var __hasProp = {}.hasOwnProperty,
3 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
4
5module.exports = function(providerParams) {
6 var $log, ResourceCacheArrayEntry, ResourceCacheEntry;
7 $log = providerParams.$log;
8 ResourceCacheEntry = require('./resource_cache_entry')(providerParams);
9 return ResourceCacheArrayEntry = (function(_super) {
10 __extends(ResourceCacheArrayEntry, _super);
11
12 function ResourceCacheArrayEntry() {
13 return ResourceCacheArrayEntry.__super__.constructor.apply(this, arguments);
14 }
15
16 ResourceCacheArrayEntry.prototype.defaultValue = [];
17
18 ResourceCacheArrayEntry.prototype.cacheKeyPrefix = function() {
19 return "" + this.key + "/array";
20 };
21
22 ResourceCacheArrayEntry.prototype.addInstances = function(instances, dirty) {
23 var cacheArrayReferences, cacheInstanceEntry, cacheInstanceParams, instance, _i, _len;
24 cacheArrayReferences = [];
25 for (_i = 0, _len = instances.length; _i < _len; _i++) {
26 instance = instances[_i];
27 cacheInstanceParams = instance.$params();
28 if (Object.keys(cacheInstanceParams).length === 0) {
29 $log.error("instance " + instance + " doesn't have any boundParams. Please, make sure you specified them in your resource's initialization, f.e. `{id: \"@id\"}`, or it won't be cached.");
30 } else {
31 cacheArrayReferences.push(cacheInstanceParams);
32 cacheInstanceEntry = new ResourceCacheEntry(this.key, cacheInstanceParams).load();
33 cacheInstanceEntry.set(instance, dirty);
34 }
35 }
36 return this.set(cacheArrayReferences, dirty);
37 };
38
39 return ResourceCacheArrayEntry;
40
41 })(ResourceCacheEntry);
42};