MCPcopy Index your code
hub / github.com/codecombat/codecombat / initialize

Method initialize

app/collections/CocoCollection.js:23–52  ·  view source on GitHub ↗
(models, options)

Source from the content-addressed store, hash-verified

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() }

Callers

nothing calls this directly

Calls 3

setProjectionMethod · 0.95
loadFromBackupMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected