(models, options)
| 21 | } |
| 22 | |
| 23 | initialize (models, options) { |
| 24 | if (options == null) { options = {} } |
| 25 | if (this.model == null) { this.model = options.model } |
| 26 | if (!this.model) { |
| 27 | console.error(this.constructor.name, 'does not have a model defined. This will not do!') |
| 28 | } |
| 29 | super.initialize(models, options) |
| 30 | this.setProjection(options.project) |
| 31 | if (options.url) { this.url = options.url } |
| 32 | this.once('sync', () => { |
| 33 | this.loaded = true |
| 34 | return Array.from(this.models).map((model) => (model.loaded = true)) |
| 35 | }) |
| 36 | if (globalVar.application != null ? globalVar.application.testing : undefined) { |
| 37 | this.fakeRequests = [] |
| 38 | this.on('request', function () { return this.fakeRequests.push(jasmine.Ajax.requests.mostRecent()) }) |
| 39 | } |
| 40 | if (options.saveBackups) { |
| 41 | return this.on('sync', function () { |
| 42 | return (() => { |
| 43 | const result = [] |
| 44 | for (const model of Array.from(this.models)) { |
| 45 | model.saveBackups = true |
| 46 | result.push(model.loadFromBackup()) |
| 47 | } |
| 48 | return result |
| 49 | })() |
| 50 | }) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | getURL () { |
| 55 | if (_.isString(this.url)) { return this.url } else { return this.url() } |
nothing calls this directly
no test coverage detected