ember-data-source 1.13.4 → 1.13.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -396,8 +396,8 @@
396
396
  This method is used by the store to determine if the store should
397
397
  reload a record from the adapter when a record is requested by
398
398
  `store.findRecord`.
399
- If this method returns true the store will re fetch a record from
400
- the adapter. If is method returns false the store will resolve
399
+ If this method returns true, the store will re-fetch a record from
400
+ the adapter. If this method returns false, the store will resolve
401
401
  immediately using the cached record.
402
402
  @method shouldReloadRecord
403
403
  @param {DS.Store} store
@@ -412,10 +412,10 @@
412
412
  This method is used by the store to determine if the store should
413
413
  reload all records from the adapter when records are requested by
414
414
  `store.findAll`.
415
- If this method returns true the store will re fetch all records from
416
- the adapter. If is method returns false the store will resolve
415
+ If this method returns true, the store will re-fetch all records from
416
+ the adapter. If this method returns false, the store will resolve
417
417
  immediately using the cached record.
418
- @method shouldReloadRecord
418
+ @method shouldReloadAll
419
419
  @param {DS.Store} store
420
420
  @param {DS.SnapshotRecordArray} snapshotRecordArray
421
421
  @return {Boolean}
@@ -783,13 +783,13 @@
783
783
  }
784
784
  });
785
785
 
786
+ var ember$data$lib$system$object$polyfills$$keysFunc = Object.keys || Ember.keys;
787
+ var ember$data$lib$system$object$polyfills$$create = Object.create || Ember.create;
788
+
786
789
  var ember$data$lib$adapters$errors$$EmberError = Ember.Error;
787
- var ember$data$lib$adapters$errors$$create = Ember.create;
788
790
 
789
791
  var ember$data$lib$adapters$errors$$forEach = Ember.ArrayPolyfills.forEach;
790
- var ember$data$lib$adapters$errors$$SOURCE_POINTER_REGEXP = /data\/(attributes|relationships)\/(.*)/;
791
-
792
- /**
792
+ var ember$data$lib$adapters$errors$$SOURCE_POINTER_REGEXP = /data\/(attributes|relationships)\/(.*)/;/**
793
793
  @class AdapterError
794
794
  @namespace DS
795
795
  */
@@ -800,11 +800,11 @@
800
800
 
801
801
  this.errors = errors || [{
802
802
  title: "Adapter Error",
803
- details: message
803
+ detail: message
804
804
  }];
805
805
  }
806
806
 
807
- ember$data$lib$adapters$errors$$AdapterError.prototype = ember$data$lib$adapters$errors$$create(ember$data$lib$adapters$errors$$EmberError.prototype);
807
+ ember$data$lib$adapters$errors$$AdapterError.prototype = ember$data$lib$system$object$polyfills$$create(ember$data$lib$adapters$errors$$EmberError.prototype);
808
808
 
809
809
  /**
810
810
  A `DS.InvalidError` is used by an adapter to signal the external API
@@ -843,11 +843,11 @@
843
843
  // Fictional adapter that always rejects
844
844
  return Ember.RSVP.reject(new DS.InvalidError([
845
845
  {
846
- details: 'Must be unique',
846
+ detail: 'Must be unique',
847
847
  source: { pointer: 'data/attributes/title' }
848
848
  },
849
849
  {
850
- details: 'Must not be blank',
850
+ detail: 'Must not be blank',
851
851
  source: { pointer: 'data/attributes/content'}
852
852
  }
853
853
  ]));
@@ -872,7 +872,7 @@
872
872
  ember$data$lib$adapters$errors$$AdapterError.call(this, errors, "The adapter rejected the commit because it was invalid");
873
873
  }
874
874
 
875
- ember$data$lib$adapters$errors$$InvalidError.prototype = ember$data$lib$adapters$errors$$create(ember$data$lib$adapters$errors$$AdapterError.prototype);
875
+ ember$data$lib$adapters$errors$$InvalidError.prototype = ember$data$lib$system$object$polyfills$$create(ember$data$lib$adapters$errors$$AdapterError.prototype);
876
876
 
877
877
  /**
878
878
  @class TimeoutError
@@ -882,7 +882,7 @@
882
882
  ember$data$lib$adapters$errors$$AdapterError.call(this, null, "The adapter operation timed out");
883
883
  }
884
884
 
885
- ember$data$lib$adapters$errors$$TimeoutError.prototype = ember$data$lib$adapters$errors$$create(ember$data$lib$adapters$errors$$AdapterError.prototype);
885
+ ember$data$lib$adapters$errors$$TimeoutError.prototype = ember$data$lib$system$object$polyfills$$create(ember$data$lib$adapters$errors$$AdapterError.prototype);
886
886
 
887
887
  /**
888
888
  @class AbortError
@@ -892,7 +892,7 @@
892
892
  ember$data$lib$adapters$errors$$AdapterError.call(this, null, "The adapter operation was aborted");
893
893
  }
894
894
 
895
- ember$data$lib$adapters$errors$$AbortError.prototype = ember$data$lib$adapters$errors$$create(ember$data$lib$adapters$errors$$AdapterError.prototype);
895
+ ember$data$lib$adapters$errors$$AbortError.prototype = ember$data$lib$system$object$polyfills$$create(ember$data$lib$adapters$errors$$AdapterError.prototype);
896
896
 
897
897
  /**
898
898
  @private
@@ -901,12 +901,12 @@
901
901
  var out = [];
902
902
 
903
903
  if (Ember.isPresent(errors)) {
904
- ember$data$lib$adapters$errors$$forEach.call(Ember.keys(errors), function (key) {
904
+ ember$data$lib$adapters$errors$$forEach.call(ember$data$lib$system$object$polyfills$$keysFunc(errors), function (key) {
905
905
  var messages = Ember.makeArray(errors[key]);
906
906
  for (var i = 0; i < messages.length; i++) {
907
907
  out.push({
908
908
  title: "Invalid Attribute",
909
- details: messages[i],
909
+ detail: messages[i],
910
910
  source: {
911
911
  pointer: "data/attributes/" + key
912
912
  }
@@ -929,7 +929,7 @@
929
929
  if (key) {
930
930
  key = key[2];
931
931
  out[key] = out[key] || [];
932
- out[key].push(error.details || error.title);
932
+ out[key].push(error.detail || error.title);
933
933
  }
934
934
  }
935
935
  });
@@ -1458,7 +1458,7 @@
1458
1458
  @return {Object}
1459
1459
  */
1460
1460
  sortQueryParams: function (obj) {
1461
- var keys = Ember.keys(obj);
1461
+ var keys = ember$data$lib$system$object$polyfills$$keysFunc(obj);
1462
1462
  var len = keys.length;
1463
1463
  if (len < 2) {
1464
1464
  return obj;
@@ -2085,7 +2085,7 @@
2085
2085
  var headers = ember$data$lib$adapters$rest$adapter$$get(this, "headers");
2086
2086
  if (headers !== undefined) {
2087
2087
  hash.beforeSend = function (xhr) {
2088
- ember$data$lib$adapters$rest$adapter$$forEach.call(Ember.keys(headers), function (key) {
2088
+ ember$data$lib$adapters$rest$adapter$$forEach.call(ember$data$lib$system$object$polyfills$$keysFunc(headers), function (key) {
2089
2089
  xhr.setRequestHeader(key, headers[key]);
2090
2090
  });
2091
2091
  };
@@ -2125,14 +2125,14 @@
2125
2125
  return [{
2126
2126
  status: "" + status,
2127
2127
  title: "The backend responded with an error",
2128
- details: "" + payload
2128
+ detail: "" + payload
2129
2129
  }];
2130
2130
  }
2131
2131
  }
2132
2132
  });
2133
2133
 
2134
2134
  function ember$data$lib$adapters$rest$adapter$$parseResponseHeaders(headerStr) {
2135
- var headers = Ember.create(null);
2135
+ var headers = ember$data$lib$system$object$polyfills$$create(null);
2136
2136
  if (!headerStr) {
2137
2137
  return headers;
2138
2138
  }
@@ -2985,8 +2985,8 @@
2985
2985
  normalizeResponse hook
2986
2986
  -To customize how JSONSerializer normalizes a specific response from the server,
2987
2987
  use one of the many specific normalizeResponse hooks
2988
- -To customize how JSONSerializer normalizes your attributes or relationships,
2989
- use the extractAttributes and extractRelationships hooks.
2988
+ -To customize how JSONSerializer normalizes your id, attributes or relationships,
2989
+ use the extractId, extractAttributes and extractRelationships hooks.
2990
2990
 
2991
2991
  JSONSerializer normalization process follows these steps:
2992
2992
  - `normalizeResponse` - entry method to the Serializer
@@ -3433,10 +3433,11 @@
3433
3433
  /*
3434
3434
  Returns the resource's ID.
3435
3435
  @method extractId
3436
+ @param {Object} modelClass
3436
3437
  @param {Object} resourceHash
3437
3438
  @return {String}
3438
3439
  */
3439
- extractId: function (resourceHash) {
3440
+ extractId: function (modelClass, resourceHash) {
3440
3441
  var primaryKey = ember$data$lib$serializers$json$serializer$$get(this, "primaryKey");
3441
3442
  var id = resourceHash[primaryKey];
3442
3443
  return ember$data$lib$system$coerce$id$$default(id);
@@ -3445,7 +3446,8 @@
3445
3446
  /*
3446
3447
  Returns the resource's attributes formatted as a JSON-API "attributes object".
3447
3448
  http://jsonapi.org/format/#document-resource-object-attributes
3448
- @method extractId
3449
+ @method extractAttributes
3450
+ @param {Object} modelClass
3449
3451
  @param {Object} resourceHash
3450
3452
  @return {Object}
3451
3453
  */
@@ -3560,6 +3562,7 @@
3560
3562
  @method normalizePayload
3561
3563
  @param {Object} payload
3562
3564
  @return {Object} the normalized payload
3565
+ @deprecated
3563
3566
  */
3564
3567
  normalizePayload: function (payload) {
3565
3568
  return payload;
@@ -4285,6 +4288,7 @@
4285
4288
  @return {Object} json The deserialized payload
4286
4289
  */
4287
4290
  extractSingle: function (store, typeClass, payload, id, requestType) {
4291
+ Ember.deprecate("`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.", this.normalizePayload === ember$data$lib$serializers$json$serializer$$JSONSerializer.prototype.normalizePayload);
4288
4292
  var normalizedPayload = this.normalizePayload(payload);
4289
4293
  return this.normalize(typeClass, normalizedPayload);
4290
4294
  },
@@ -4312,6 +4316,7 @@
4312
4316
  @return {Array} array An array of deserialized objects
4313
4317
  */
4314
4318
  extractArray: function (store, typeClass, arrayPayload, id, requestType) {
4319
+ Ember.deprecate("`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.", this.normalizePayload === ember$data$lib$serializers$json$serializer$$JSONSerializer.prototype.normalizePayload);
4315
4320
  var normalizedPayload = this.normalizePayload(arrayPayload);
4316
4321
  var serializer = this;
4317
4322
 
@@ -4472,7 +4477,7 @@
4472
4477
  this.normalizeUsingDeclaredMapping(modelClass, resourceHash);
4473
4478
 
4474
4479
  data = {
4475
- id: this.extractId(resourceHash),
4480
+ id: this.extractId(modelClass, resourceHash),
4476
4481
  type: modelClass.modelName,
4477
4482
  attributes: this.extractAttributes(modelClass, resourceHash),
4478
4483
  relationships: this.extractRelationships(modelClass, resourceHash)
@@ -5433,9 +5438,9 @@
5433
5438
  changedAttributes: function () {
5434
5439
  var oldData = ember$data$lib$system$model$model$$get(this._internalModel, "_data");
5435
5440
  var newData = ember$data$lib$system$model$model$$get(this._internalModel, "_attributes");
5436
- var diffData = Ember.create(null);
5441
+ var diffData = ember$data$lib$system$object$polyfills$$create(null);
5437
5442
 
5438
- var newDataKeys = Ember.keys(newData);
5443
+ var newDataKeys = ember$data$lib$system$object$polyfills$$keysFunc(newData);
5439
5444
 
5440
5445
  for (var i = 0, _length = newDataKeys.length; i < _length; i++) {
5441
5446
  var key = newDataKeys[i];
@@ -5599,7 +5604,7 @@
5599
5604
  // rely on the data property.
5600
5605
  willMergeMixin: function (props) {
5601
5606
  var constructor = this.constructor;
5602
- Ember.assert("`" + ember$data$lib$system$model$model$$intersection(Ember.keys(props), ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS)[0] + "` is a reserved property name on DS.Model objects. Please choose a different property name for " + constructor.toString(), !ember$data$lib$system$model$model$$intersection(Ember.keys(props), ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS)[0]);
5607
+ Ember.assert("`" + ember$data$lib$system$model$model$$intersection(ember$data$lib$system$object$polyfills$$keysFunc(props), ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS)[0] + "` is a reserved property name on DS.Model objects. Please choose a different property name for " + constructor.toString(), !ember$data$lib$system$model$model$$intersection(ember$data$lib$system$object$polyfills$$keysFunc(props), ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS)[0]);
5603
5608
  },
5604
5609
 
5605
5610
  attr: function () {
@@ -5658,7 +5663,7 @@
5658
5663
  }
5659
5664
  });
5660
5665
  ```
5661
- @property
5666
+ @property modelName
5662
5667
  @type String
5663
5668
  @readonly
5664
5669
  */
@@ -5690,7 +5695,7 @@
5690
5695
  @return {Object} JSON-API Document
5691
5696
  */
5692
5697
  function ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, modelClass, payload, id, requestType) {
5693
- if (serializer.get('isNewSerializerAPI')) {
5698
+ if (ember$data$lib$system$store$serializer$response$$get(serializer, 'isNewSerializerAPI')) {
5694
5699
  var normalizedResponse = serializer.normalizeResponse(store, modelClass, payload, id, requestType);
5695
5700
  // TODO: Remove after metadata refactor
5696
5701
  if (normalizedResponse.meta) {
@@ -5914,14 +5919,14 @@
5914
5919
  };
5915
5920
 
5916
5921
  if (payload.attributes) {
5917
- var attributeKeys = Ember.keys(payload.attributes);
5922
+ var attributeKeys = ember$data$lib$system$object$polyfills$$keysFunc(payload.attributes);
5918
5923
  ember$data$lib$system$store$serializer$response$$forEach.call(attributeKeys, function (key) {
5919
5924
  var attribute = payload.attributes[key];
5920
5925
  data[key] = attribute;
5921
5926
  });
5922
5927
  }
5923
5928
  if (payload.relationships) {
5924
- var relationshipKeys = Ember.keys(payload.relationships);
5929
+ var relationshipKeys = ember$data$lib$system$object$polyfills$$keysFunc(payload.relationships);
5925
5930
  ember$data$lib$system$store$serializer$response$$forEach.call(relationshipKeys, function (key) {
5926
5931
  var relationship = payload.relationships[key];
5927
5932
  if (relationship.hasOwnProperty('data')) {
@@ -6026,6 +6031,7 @@
6026
6031
  @property normalizeHash
6027
6032
  @type {Object}
6028
6033
  @default undefined
6034
+ @deprecated
6029
6035
  */
6030
6036
 
6031
6037
  /**
@@ -6095,6 +6101,7 @@
6095
6101
  this.normalizeUsingDeclaredMapping(typeClass, hash);
6096
6102
 
6097
6103
  if (this.normalizeHash && this.normalizeHash[prop]) {
6104
+ Ember.deprecate("`RESTSerializer.normalizeHash` has been deprecated. Please use `serializer.normalize` to modify the payload of single resources.");
6098
6105
  this.normalizeHash[prop](hash);
6099
6106
  }
6100
6107
 
@@ -6121,7 +6128,7 @@
6121
6128
  var modelClass = store.modelFor(modelName);
6122
6129
  var serializer = store.serializerFor(modelName);
6123
6130
 
6124
- Ember.assert("" + this.toString() + " has opted into the new serializer API and expects the " + serializer.toString() + " it collaborates with to also support the new serializer API by setting its `isNewSerializerAPI` property to true.", ember$data$lib$serializers$rest$serializer$$get(serializer, "isNewSerializerAPI"));
6131
+ Ember.assert(this.toString() + " has opted into the new serializer API and expects the " + serializer.toString() + " it collaborates with to also support the new serializer API by setting its `isNewSerializerAPI` property to true.", ember$data$lib$serializers$rest$serializer$$get(serializer, "isNewSerializerAPI"));
6125
6132
 
6126
6133
  /*jshint loopfunc:true*/
6127
6134
  ember$data$lib$serializers$rest$serializer$$forEach.call(arrayHash, function (hash) {
@@ -6164,7 +6171,7 @@
6164
6171
  documentHash.meta = meta;
6165
6172
  }
6166
6173
 
6167
- var keys = Ember.keys(payload);
6174
+ var keys = ember$data$lib$system$object$polyfills$$keysFunc(payload);
6168
6175
 
6169
6176
  for (var i = 0, _length = keys.length; i < _length; i++) {
6170
6177
  var prop = keys[i];
@@ -6342,6 +6349,7 @@
6342
6349
  @return {Object} the primary response to the original request
6343
6350
  */
6344
6351
  extractSingle: function (store, primaryTypeClass, rawPayload, recordId) {
6352
+ Ember.deprecate("`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.", this.normalizePayload === ember$data$lib$serializers$json$serializer$$default.prototype.normalizePayload);
6345
6353
  var payload = this.normalizePayload(rawPayload);
6346
6354
  var primaryRecord;
6347
6355
 
@@ -6371,6 +6379,8 @@
6371
6379
  var type = store.modelFor(typeName);
6372
6380
  var typeSerializer = store.serializerFor(type.modelName);
6373
6381
 
6382
+ Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this, "isNewSerializerAPI") ? "new" : "old") + " serializer API and expects " + typeSerializer.toString() + " it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.", ember$data$lib$serializers$rest$serializer$$get(this, "isNewSerializerAPI") === ember$data$lib$serializers$rest$serializer$$get(typeSerializer, "isNewSerializerAPI"));
6383
+
6374
6384
  hash = typeSerializer.normalize(type, hash, prop);
6375
6385
 
6376
6386
  var isFirstCreatedRecord = isPrimary && !recordId && !primaryRecord;
@@ -6479,6 +6489,7 @@
6479
6489
  to the original query.
6480
6490
  */
6481
6491
  extractArray: function (store, primaryTypeClass, rawPayload) {
6492
+ Ember.deprecate("`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.", this.normalizePayload === ember$data$lib$serializers$json$serializer$$default.prototype.normalizePayload);
6482
6493
  var payload = this.normalizePayload(rawPayload);
6483
6494
  var primaryArray;
6484
6495
 
@@ -6498,6 +6509,9 @@
6498
6509
  }
6499
6510
  var type = store.modelFor(typeName);
6500
6511
  var typeSerializer = store.serializerFor(type.modelName);
6512
+
6513
+ Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this, "isNewSerializerAPI") ? "new" : "old") + " serializer API and expects " + typeSerializer.toString() + " it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.", ember$data$lib$serializers$rest$serializer$$get(this, "isNewSerializerAPI") === ember$data$lib$serializers$rest$serializer$$get(typeSerializer, "isNewSerializerAPI"));
6514
+
6501
6515
  var isPrimary = !forcedSecondary && this.isPrimaryType(store, typeName, primaryTypeClass);
6502
6516
 
6503
6517
  /*jshint loopfunc:true*/
@@ -6554,6 +6568,7 @@
6554
6568
  return;
6555
6569
  }
6556
6570
 
6571
+ Ember.deprecate("`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.", this.normalizePayload === ember$data$lib$serializers$json$serializer$$default.prototype.normalizePayload);
6557
6572
  var payload = this.normalizePayload(rawPayload);
6558
6573
 
6559
6574
  for (var prop in payload) {
@@ -6565,6 +6580,8 @@
6565
6580
  var typeClass = store.modelFor(modelName);
6566
6581
  var typeSerializer = store.serializerFor(modelName);
6567
6582
 
6583
+ Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this, "isNewSerializerAPI") ? "new" : "old") + " serializer API and expects " + typeSerializer.toString() + " it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.", ember$data$lib$serializers$rest$serializer$$get(this, "isNewSerializerAPI") === ember$data$lib$serializers$rest$serializer$$get(typeSerializer, "isNewSerializerAPI"));
6584
+
6568
6585
  /*jshint loopfunc:true*/
6569
6586
  var normalizedArray = ember$data$lib$serializers$rest$serializer$$map.call(Ember.makeArray(payload[prop]), function (hash) {
6570
6587
  return typeSerializer.normalize(typeClass, hash, prop);
@@ -6863,6 +6880,7 @@
6863
6880
  */
6864
6881
  function ember$data$lib$serializers$rest$serializer$$_newNormalize(modelClass, resourceHash, prop) {
6865
6882
  if (this.normalizeHash && this.normalizeHash[prop]) {
6883
+ Ember.deprecate("`RESTSerializer.normalizeHash` has been deprecated. Please use `serializer.normalize` to modify the payload of single resources.");
6866
6884
  this.normalizeHash[prop](resourceHash);
6867
6885
  }
6868
6886
  }
@@ -6877,6 +6895,8 @@
6877
6895
  data: [],
6878
6896
  included: []
6879
6897
  };
6898
+
6899
+ Ember.deprecate("`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.", this.normalizePayload === ember$data$lib$serializers$json$serializer$$default.prototype.normalizePayload);
6880
6900
  var payload = this.normalizePayload(rawPayload);
6881
6901
 
6882
6902
  for (var prop in payload) {
@@ -6888,6 +6908,8 @@
6888
6908
  var type = store.modelFor(modelName);
6889
6909
  var typeSerializer = store.serializerFor(type.modelName);
6890
6910
 
6911
+ Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this, "isNewSerializerAPI") ? "new" : "old") + " serializer API and expects " + typeSerializer.toString() + " it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.", ember$data$lib$serializers$rest$serializer$$get(this, "isNewSerializerAPI") === ember$data$lib$serializers$rest$serializer$$get(typeSerializer, "isNewSerializerAPI"));
6912
+
6891
6913
  /*jshint loopfunc:true*/
6892
6914
  ember$data$lib$serializers$rest$serializer$$forEach.call(Ember.makeArray(payload[prop]), function (hash) {
6893
6915
  var _typeSerializer$normalize = typeSerializer.normalize(type, hash, prop);
@@ -7254,7 +7276,7 @@
7254
7276
  registry.register("adapter:-active-model", activemodel$adapter$lib$system$active$model$adapter$$default);
7255
7277
  }
7256
7278
  var ember$data$lib$core$$DS = Ember.Namespace.create({
7257
- VERSION: '1.13.4'
7279
+ VERSION: '1.13.5'
7258
7280
  });
7259
7281
 
7260
7282
  if (Ember.libraries) {
@@ -7298,6 +7320,7 @@
7298
7320
  }
7299
7321
 
7300
7322
  if (serializer === null || serializer === undefined) {
7323
+ Ember.deprecate('Ember Data 2.0 will no longer support adapters with a null serializer property. Please define `defaultSerializer: "-default"` your adapter and make sure the `serializer` property is not null.');
7301
7324
  serializer = {
7302
7325
  extract: function (store, type, payload) {
7303
7326
  return payload;
@@ -7389,7 +7412,7 @@
7389
7412
  var recordArray = ember$data$lib$system$store$finders$$map.call(records, function (record) {
7390
7413
  return record._internalModel;
7391
7414
  });
7392
- if (serializer.get("isNewSerializerAPI")) {
7415
+ if (ember$data$lib$system$store$finders$$get(serializer, "isNewSerializerAPI")) {
7393
7416
  recordArray.meta = payload.meta;
7394
7417
  }
7395
7418
  return recordArray;
@@ -7744,9 +7767,8 @@
7744
7767
  });
7745
7768
 
7746
7769
  var ember$data$lib$system$clone$null$$default = ember$data$lib$system$clone$null$$cloneNull;
7747
-
7748
7770
  function ember$data$lib$system$clone$null$$cloneNull(source) {
7749
- var clone = Ember.create(null);
7771
+ var clone = ember$data$lib$system$object$polyfills$$create(null);
7750
7772
  for (var key in source) {
7751
7773
  clone[key] = source[key];
7752
7774
  }
@@ -7821,7 +7843,7 @@
7821
7843
  return new Constructor();
7822
7844
  };
7823
7845
 
7824
- ember$data$lib$system$ordered$set$$OrderedSet.prototype = Ember.create(ember$data$lib$system$ordered$set$$EmberOrderedSet.prototype);
7846
+ ember$data$lib$system$ordered$set$$OrderedSet.prototype = ember$data$lib$system$object$polyfills$$create(ember$data$lib$system$ordered$set$$EmberOrderedSet.prototype);
7825
7847
  ember$data$lib$system$ordered$set$$OrderedSet.prototype.constructor = ember$data$lib$system$ordered$set$$OrderedSet;
7826
7848
  ember$data$lib$system$ordered$set$$OrderedSet.prototype._super$constructor = ember$data$lib$system$ordered$set$$EmberOrderedSet;
7827
7849
 
@@ -8169,15 +8191,15 @@
8169
8191
  */
8170
8192
  function ember$data$lib$system$store$container$instance$cache$$ContainerInstanceCache(container) {
8171
8193
  this._container = container;
8172
- this._cache = ember$lib$main$$default.create(null);
8194
+ this._cache = ember$data$lib$system$object$polyfills$$create(null);
8173
8195
  }
8174
8196
 
8175
- ember$data$lib$system$store$container$instance$cache$$ContainerInstanceCache.prototype = ember$lib$main$$default.create(null);
8197
+ ember$data$lib$system$store$container$instance$cache$$ContainerInstanceCache.prototype = ember$data$lib$system$object$polyfills$$create(null);
8176
8198
 
8177
8199
  ember$lib$main$$default.merge(ember$data$lib$system$store$container$instance$cache$$ContainerInstanceCache.prototype, {
8178
8200
  get: function (type, preferredKey, fallbacks) {
8179
8201
  var cache = this._cache;
8180
- var preferredLookupKey = '' + type + ':' + preferredKey;
8202
+ var preferredLookupKey = type + ':' + preferredKey;
8181
8203
 
8182
8204
  if (!(preferredLookupKey in cache)) {
8183
8205
  var instance = this.instanceFor(preferredLookupKey) || this._findInstance(type, fallbacks);
@@ -8191,7 +8213,7 @@
8191
8213
  _findInstance: function (type, fallbacks) {
8192
8214
  for (var i = 0, _length = fallbacks.length; i < _length; i++) {
8193
8215
  var fallback = fallbacks[i];
8194
- var lookupKey = '' + type + ':' + fallback;
8216
+ var lookupKey = type + ':' + fallback;
8195
8217
  var instance = this.instanceFor(lookupKey);
8196
8218
 
8197
8219
  if (instance) {
@@ -8217,7 +8239,7 @@
8217
8239
 
8218
8240
  destroy: function () {
8219
8241
  var cache = this._cache;
8220
- var cacheEntries = ember$lib$main$$default.keys(cache);
8242
+ var cacheEntries = ember$data$lib$system$object$polyfills$$keysFunc(cache);
8221
8243
 
8222
8244
  for (var i = 0, _length2 = cacheEntries.length; i < _length2; i++) {
8223
8245
  var cacheKey = cacheEntries[i];
@@ -8237,12 +8259,12 @@
8237
8259
  });
8238
8260
 
8239
8261
  var ember$data$lib$system$store$container$instance$cache$$default = ember$data$lib$system$store$container$instance$cache$$ContainerInstanceCache;
8262
+
8240
8263
  function ember$data$lib$system$merge$$merge(original, updates) {
8241
8264
  if (!updates || typeof updates !== 'object') {
8242
8265
  return original;
8243
8266
  }
8244
-
8245
- var props = Ember.keys(updates);
8267
+ var props = ember$data$lib$system$object$polyfills$$keysFunc(updates);
8246
8268
  var prop;
8247
8269
  var length = props.length;
8248
8270
 
@@ -8256,6 +8278,10 @@
8256
8278
 
8257
8279
  var ember$data$lib$system$merge$$default = ember$data$lib$system$merge$$merge;
8258
8280
 
8281
+ /**
8282
+ @module ember-data
8283
+ */
8284
+
8259
8285
  var ember$data$lib$system$model$states$$get = Ember.get;
8260
8286
  /*
8261
8287
  This file encapsulates the various states that a record can transition
@@ -8500,7 +8526,7 @@
8500
8526
  loadingData: Ember.K,
8501
8527
 
8502
8528
  propertyWasReset: function (internalModel, name) {
8503
- var length = Ember.keys(internalModel._attributes).length;
8529
+ var length = ember$data$lib$system$object$polyfills$$keysFunc(internalModel._attributes).length;
8504
8530
  var stillDirty = length > 0;
8505
8531
 
8506
8532
  if (!stillDirty) {
@@ -8610,7 +8636,7 @@
8610
8636
  },
8611
8637
 
8612
8638
  exit: function (internalModel) {
8613
- internalModel._inFlightAttributes = Ember.create(null);
8639
+ internalModel._inFlightAttributes = ember$data$lib$system$object$polyfills$$create(null);
8614
8640
  }
8615
8641
  }
8616
8642
  };
@@ -8801,7 +8827,7 @@
8801
8827
  saved: {
8802
8828
  setup: function (internalModel) {
8803
8829
  var attrs = internalModel._attributes;
8804
- var isDirty = Ember.keys(attrs).length > 0;
8830
+ var isDirty = ember$data$lib$system$object$polyfills$$keysFunc(attrs).length > 0;
8805
8831
 
8806
8832
  if (isDirty) {
8807
8833
  internalModel.adapterDidDirty();
@@ -8994,7 +9020,7 @@
8994
9020
  function ember$data$lib$system$model$states$$wireState(object, parent, name) {
8995
9021
  /*jshint proto:true*/
8996
9022
  // TODO: Use Object.create and copy instead
8997
- object = ember$data$lib$system$model$states$$mixin(parent ? Ember.create(parent) : {}, object);
9023
+ object = ember$data$lib$system$model$states$$mixin(parent ? ember$data$lib$system$object$polyfills$$create(parent) : {}, object);
8998
9024
  object.parentState = parent;
8999
9025
  object.stateName = name;
9000
9026
 
@@ -9567,7 +9593,7 @@
9567
9593
  this.manyArray.isPolymorphic = this.isPolymorphic;
9568
9594
  };
9569
9595
 
9570
- ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype = Ember.create(ember$data$lib$system$relationships$state$relationship$$default.prototype);
9596
+ ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype = ember$data$lib$system$object$polyfills$$create(ember$data$lib$system$relationships$state$relationship$$default.prototype);
9571
9597
  ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype.constructor = ember$data$lib$system$relationships$state$has$many$$ManyRelationship;
9572
9598
  ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype._super$constructor = ember$data$lib$system$relationships$state$relationship$$default;
9573
9599
 
@@ -9767,7 +9793,7 @@
9767
9793
  this.canonicalState = null;
9768
9794
  };
9769
9795
 
9770
- ember$data$lib$system$relationships$state$belongs$to$$BelongsToRelationship.prototype = Ember.create(ember$data$lib$system$relationships$state$relationship$$default.prototype);
9796
+ ember$data$lib$system$relationships$state$belongs$to$$BelongsToRelationship.prototype = ember$data$lib$system$object$polyfills$$create(ember$data$lib$system$relationships$state$relationship$$default.prototype);
9771
9797
  ember$data$lib$system$relationships$state$belongs$to$$BelongsToRelationship.prototype.constructor = ember$data$lib$system$relationships$state$belongs$to$$BelongsToRelationship;
9772
9798
  ember$data$lib$system$relationships$state$belongs$to$$BelongsToRelationship.prototype._super$constructor = ember$data$lib$system$relationships$state$relationship$$default;
9773
9799
 
@@ -9923,7 +9949,7 @@
9923
9949
 
9924
9950
  var ember$data$lib$system$relationships$state$create$$Relationships = function (record) {
9925
9951
  this.record = record;
9926
- this.initializedRelationships = Ember.create(null);
9952
+ this.initializedRelationships = ember$data$lib$system$object$polyfills$$create(null);
9927
9953
  };
9928
9954
 
9929
9955
  ember$data$lib$system$relationships$state$create$$Relationships.prototype.has = function (key) {
@@ -9941,9 +9967,11 @@
9941
9967
 
9942
9968
  var ember$data$lib$system$relationships$state$create$$default = ember$data$lib$system$relationships$state$create$$Relationships;
9943
9969
 
9944
- var ember$data$lib$system$snapshot$$get = Ember.get;
9945
-
9946
9970
  /**
9971
+ @module ember-data
9972
+ */
9973
+
9974
+ var ember$data$lib$system$snapshot$$get = Ember.get;/**
9947
9975
  @class Snapshot
9948
9976
  @namespace DS
9949
9977
  @private
@@ -9951,11 +9979,11 @@
9951
9979
  @param {DS.Model} internalModel The model to create a snapshot from
9952
9980
  */
9953
9981
  function ember$data$lib$system$snapshot$$Snapshot(internalModel) {
9954
- this._attributes = Ember.create(null);
9955
- this._belongsToRelationships = Ember.create(null);
9956
- this._belongsToIds = Ember.create(null);
9957
- this._hasManyRelationships = Ember.create(null);
9958
- this._hasManyIds = Ember.create(null);
9982
+ this._attributes = ember$data$lib$system$object$polyfills$$create(null);
9983
+ this._belongsToRelationships = ember$data$lib$system$object$polyfills$$create(null);
9984
+ this._belongsToIds = ember$data$lib$system$object$polyfills$$create(null);
9985
+ this._hasManyRelationships = ember$data$lib$system$object$polyfills$$create(null);
9986
+ this._hasManyIds = ember$data$lib$system$object$polyfills$$create(null);
9959
9987
 
9960
9988
  var record = internalModel.getRecord();
9961
9989
  this.record = record;
@@ -10086,8 +10114,8 @@
10086
10114
  @return {Object} All changed attributes of the current snapshot
10087
10115
  */
10088
10116
  changedAttributes: function () {
10089
- var changedAttributes = Ember.create(null);
10090
- var changedAttributeKeys = Ember.keys(this._changedAttributes);
10117
+ var changedAttributes = ember$data$lib$system$object$polyfills$$create(null);
10118
+ var changedAttributeKeys = ember$data$lib$system$object$polyfills$$keysFunc(this._changedAttributes);
10091
10119
 
10092
10120
  for (var i = 0, _length = changedAttributeKeys.length; i < _length; i++) {
10093
10121
  var key = changedAttributeKeys[i];
@@ -10342,8 +10370,8 @@
10342
10370
  var ember$data$lib$system$model$internal$model$$forEach = Ember.ArrayPolyfills.forEach;
10343
10371
  var ember$data$lib$system$model$internal$model$$map = Ember.ArrayPolyfills.map;
10344
10372
 
10345
- var ember$data$lib$system$model$internal$model$$_extractPivotNameCache = Ember.create(null);
10346
- var ember$data$lib$system$model$internal$model$$_splitOnDotCache = Ember.create(null);
10373
+ var ember$data$lib$system$model$internal$model$$_extractPivotNameCache = ember$data$lib$system$object$polyfills$$create(null);
10374
+ var ember$data$lib$system$model$internal$model$$_splitOnDotCache = ember$data$lib$system$object$polyfills$$create(null);
10347
10375
 
10348
10376
  function ember$data$lib$system$model$internal$model$$splitOnDot(name) {
10349
10377
  return ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] || (ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] = name.split("."));
@@ -10380,13 +10408,13 @@
10380
10408
  this.id = id;
10381
10409
  this.store = store;
10382
10410
  this.container = container;
10383
- this._data = data || Ember.create(null);
10411
+ this._data = data || ember$data$lib$system$object$polyfills$$create(null);
10384
10412
  this.modelName = type.modelName;
10385
10413
  this.dataHasInitialized = false;
10386
10414
  //Look into making this lazy
10387
10415
  this._deferredTriggers = [];
10388
- this._attributes = Ember.create(null);
10389
- this._inFlightAttributes = Ember.create(null);
10416
+ this._attributes = ember$data$lib$system$object$polyfills$$create(null);
10417
+ this._inFlightAttributes = ember$data$lib$system$object$polyfills$$create(null);
10390
10418
  this._relationships = new ember$data$lib$system$relationships$state$create$$default(this);
10391
10419
  this.currentState = ember$data$lib$system$model$states$$default.empty;
10392
10420
  this.isReloading = false;
@@ -10413,7 +10441,7 @@
10413
10441
  would have a implicit post relationship in order to be do things like remove ourselves from the post
10414
10442
  when we are deleted
10415
10443
  */
10416
- this._implicitRelationships = Ember.create(null);
10444
+ this._implicitRelationships = ember$data$lib$system$object$polyfills$$create(null);
10417
10445
  };
10418
10446
 
10419
10447
  ember$data$lib$system$model$internal$model$$InternalModel.prototype = {
@@ -10589,7 +10617,7 @@
10589
10617
 
10590
10618
  flushChangedAttributes: function () {
10591
10619
  this._inFlightAttributes = this._attributes;
10592
- this._attributes = Ember.create(null);
10620
+ this._attributes = ember$data$lib$system$object$polyfills$$create(null);
10593
10621
  },
10594
10622
 
10595
10623
  /**
@@ -10650,12 +10678,12 @@
10650
10678
  },
10651
10679
 
10652
10680
  rollbackAttributes: function () {
10653
- var dirtyKeys = Ember.keys(this._attributes);
10681
+ var dirtyKeys = ember$data$lib$system$object$polyfills$$keysFunc(this._attributes);
10654
10682
 
10655
- this._attributes = Ember.create(null);
10683
+ this._attributes = ember$data$lib$system$object$polyfills$$create(null);
10656
10684
 
10657
10685
  if (ember$data$lib$system$model$internal$model$$get(this, "isError")) {
10658
- this._inFlightAttributes = Ember.create(null);
10686
+ this._inFlightAttributes = ember$data$lib$system$object$polyfills$$create(null);
10659
10687
  this.didCleanError();
10660
10688
  }
10661
10689
 
@@ -10673,7 +10701,7 @@
10673
10701
  }
10674
10702
 
10675
10703
  if (this.isValid()) {
10676
- this._inFlightAttributes = Ember.create(null);
10704
+ this._inFlightAttributes = ember$data$lib$system$object$polyfills$$create(null);
10677
10705
  }
10678
10706
 
10679
10707
  this.send("rolledBack");
@@ -10786,7 +10814,7 @@
10786
10814
  }
10787
10815
  }, this);
10788
10816
  var model = this;
10789
- ember$data$lib$system$model$internal$model$$forEach.call(Ember.keys(this._implicitRelationships), function (key) {
10817
+ ember$data$lib$system$model$internal$model$$forEach.call(ember$data$lib$system$object$polyfills$$keysFunc(this._implicitRelationships), function (key) {
10790
10818
  model._implicitRelationships[key].clear();
10791
10819
  model._implicitRelationships[key].destroy();
10792
10820
  });
@@ -10797,7 +10825,7 @@
10797
10825
  this._relationships.get(name).disconnect();
10798
10826
  }, this);
10799
10827
  var model = this;
10800
- ember$data$lib$system$model$internal$model$$forEach.call(Ember.keys(this._implicitRelationships), function (key) {
10828
+ ember$data$lib$system$model$internal$model$$forEach.call(ember$data$lib$system$object$polyfills$$keysFunc(this._implicitRelationships), function (key) {
10801
10829
  model._implicitRelationships[key].disconnect();
10802
10830
  });
10803
10831
  },
@@ -10807,7 +10835,7 @@
10807
10835
  this._relationships.get(name).reconnect();
10808
10836
  }, this);
10809
10837
  var model = this;
10810
- ember$data$lib$system$model$internal$model$$forEach.call(Ember.keys(this._implicitRelationships), function (key) {
10838
+ ember$data$lib$system$model$internal$model$$forEach.call(ember$data$lib$system$object$polyfills$$keysFunc(this._implicitRelationships), function (key) {
10811
10839
  model._implicitRelationships[key].reconnect();
10812
10840
  });
10813
10841
  },
@@ -10828,7 +10856,7 @@
10828
10856
  _preloadData: function (preload) {
10829
10857
  var record = this;
10830
10858
  //TODO(Igor) consider the polymorphic case
10831
- ember$data$lib$system$model$internal$model$$forEach.call(Ember.keys(preload), function (key) {
10859
+ ember$data$lib$system$model$internal$model$$forEach.call(ember$data$lib$system$object$polyfills$$keysFunc(preload), function (key) {
10832
10860
  var preloadValue = ember$data$lib$system$model$internal$model$$get(preload, key);
10833
10861
  var relationshipMeta = record.type.metaForProperty(key);
10834
10862
  if (relationshipMeta.isRelationship) {
@@ -10934,7 +10962,7 @@
10934
10962
  ember$data$lib$system$merge$$default(this._data, data);
10935
10963
  }
10936
10964
 
10937
- this._inFlightAttributes = Ember.create(null);
10965
+ this._inFlightAttributes = ember$data$lib$system$object$polyfills$$create(null);
10938
10966
 
10939
10967
  this.send("didCommit");
10940
10968
  this.updateRecordArraysLater();
@@ -11003,18 +11031,17 @@
11003
11031
  },
11004
11032
 
11005
11033
  _saveWasRejected: function () {
11006
- var keys = Ember.keys(this._inFlightAttributes);
11034
+ var keys = ember$data$lib$system$object$polyfills$$keysFunc(this._inFlightAttributes);
11007
11035
  for (var i = 0; i < keys.length; i++) {
11008
11036
  if (this._attributes[keys[i]] === undefined) {
11009
11037
  this._attributes[keys[i]] = this._inFlightAttributes[keys[i]];
11010
11038
  }
11011
11039
  }
11012
- this._inFlightAttributes = Ember.create(null);
11040
+ this._inFlightAttributes = ember$data$lib$system$object$polyfills$$create(null);
11013
11041
  },
11014
11042
 
11015
11043
  /**
11016
- @method _changedKeys
11017
- Ember Data has 3 buckets for storing the value of an attribute on an internalModel.
11044
+ Ember Data has 3 buckets for storing the value of an attribute on an internalModel.
11018
11045
  `_data` holds all of the attributes that have been acknowledged by
11019
11046
  a backend via the adapter. When rollbackAttributes is called on a model all
11020
11047
  attributes will revert to the record's state in `_data`.
@@ -11042,17 +11069,18 @@
11042
11069
  `_inFlightAttributes` has priority) then that means the backend
11043
11070
  has updated the value and the key is added to the list of changed
11044
11071
  keys.
11045
- @private
11072
+ @method _changedKeys
11073
+ @private
11046
11074
  */
11047
11075
  _changedKeys: function (updates) {
11048
11076
  var changedKeys = [];
11049
11077
 
11050
11078
  if (updates) {
11051
11079
  var original, i, value, key;
11052
- var keys = Ember.keys(updates);
11080
+ var keys = ember$data$lib$system$object$polyfills$$keysFunc(updates);
11053
11081
  var length = keys.length;
11054
11082
 
11055
- original = ember$data$lib$system$merge$$default(Ember.create(null), this._data);
11083
+ original = ember$data$lib$system$merge$$default(ember$data$lib$system$object$polyfills$$create(null), this._data);
11056
11084
  original = ember$data$lib$system$merge$$default(original, this._inFlightAttributes);
11057
11085
 
11058
11086
  for (i = 0; i < length; i++) {
@@ -11320,11 +11348,19 @@
11320
11348
  /**
11321
11349
  Create a new record in the current store. The properties passed
11322
11350
  to this method are set on the newly created record.
11323
- To create a new instance of `App.Post`:
11351
+ To create a new instance of a `Post`:
11324
11352
  ```js
11325
11353
  store.createRecord('post', {
11326
11354
  title: "Rails is omakase"
11327
11355
  });
11356
+ ```
11357
+ To create a new instance of a `Post` that has a relationship with a `User` record:
11358
+ ```js
11359
+ var user = this.store.peekRecord('user', 1);
11360
+ store.createRecord('post', {
11361
+ title: "Rails is omakase",
11362
+ user: user
11363
+ });
11328
11364
  ```
11329
11365
  @method createRecord
11330
11366
  @param {String} modelName
@@ -11335,7 +11371,7 @@
11335
11371
  createRecord: function (modelName, inputProperties) {
11336
11372
  Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName === "string");
11337
11373
  var typeClass = this.modelFor(modelName);
11338
- var properties = ember$data$lib$system$store$$copy(inputProperties) || Ember.create(null);
11374
+ var properties = ember$data$lib$system$store$$copy(inputProperties) || ember$data$lib$system$object$polyfills$$create(null);
11339
11375
 
11340
11376
  // If the passed properties do not include a primary key,
11341
11377
  // give the adapter an opportunity to generate one. Typically,
@@ -11592,34 +11628,16 @@
11592
11628
  var internalModel = this._internalModelForId(modelName, id);
11593
11629
  options = options || {};
11594
11630
 
11595
- return this._findByInternalModel(internalModel, options);
11596
- },
11597
-
11598
- _findByInternalModel: function (internalModel, options) {
11599
- options = options || {};
11600
-
11601
- if (options.preload) {
11602
- internalModel._preloadData(options.preload);
11631
+ if (!this.hasRecordForId(modelName, id)) {
11632
+ return this._findByInternalModel(internalModel, options);
11603
11633
  }
11604
11634
 
11605
- var fetchedInternalModel = this._fetchOrResolveInternalModel(internalModel, options);
11635
+ var fetchedInternalModel = this._findRecord(internalModel, options);
11606
11636
 
11607
11637
  return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel, "id"));
11608
11638
  },
11609
11639
 
11610
- _fetchOrResolveInternalModel: function (internalModel, options) {
11611
- var typeClass = internalModel.type;
11612
- var adapter = this.adapterFor(typeClass.modelName);
11613
- // Always fetch the model if it is not loaded
11614
- if (internalModel.isEmpty()) {
11615
- return this.scheduleFetch(internalModel, options);
11616
- }
11617
-
11618
- //TODO double check about reloading
11619
- if (internalModel.isLoading()) {
11620
- return internalModel._loadingPromise;
11621
- }
11622
-
11640
+ _findRecord: function (internalModel, options) {
11623
11641
  // Refetch if the reload option is passed
11624
11642
  if (options.reload) {
11625
11643
  return this.scheduleFetch(internalModel, options);
@@ -11628,6 +11646,8 @@
11628
11646
  // Refetch the record if the adapter thinks the record is stale
11629
11647
  var snapshot = internalModel.createSnapshot();
11630
11648
  snapshot.adapterOptions = options && options.adapterOptions;
11649
+ var typeClass = internalModel.type;
11650
+ var adapter = this.adapterFor(typeClass.modelName);
11631
11651
  if (adapter.shouldReloadRecord(this, snapshot)) {
11632
11652
  return this.scheduleFetch(internalModel, options);
11633
11653
  }
@@ -11640,6 +11660,32 @@
11640
11660
  // Return the cached record
11641
11661
  return ember$data$lib$system$store$$Promise.resolve(internalModel);
11642
11662
  },
11663
+
11664
+ _findByInternalModel: function (internalModel, options) {
11665
+ options = options || {};
11666
+
11667
+ if (options.preload) {
11668
+ internalModel._preloadData(options.preload);
11669
+ }
11670
+
11671
+ var fetchedInternalModel = this._findEmptyInternalModel(internalModel, options);
11672
+
11673
+ return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel, "id"));
11674
+ },
11675
+
11676
+ _findEmptyInternalModel: function (internalModel, options) {
11677
+ if (internalModel.isEmpty()) {
11678
+ return this.scheduleFetch(internalModel, options);
11679
+ }
11680
+
11681
+ //TODO double check about reloading
11682
+ if (internalModel.isLoading()) {
11683
+ return internalModel._loadingPromise;
11684
+ }
11685
+
11686
+ return ember$data$lib$system$store$$Promise.resolve(internalModel);
11687
+ },
11688
+
11643
11689
  /**
11644
11690
  This method makes a series of requests to the adapter's `find` method
11645
11691
  and returns a promise that resolves once they are all loaded.
@@ -12188,7 +12234,7 @@
12188
12234
  Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), !modelName || typeof modelName === "string");
12189
12235
  if (arguments.length === 0) {
12190
12236
  var typeMaps = this.typeMaps;
12191
- var keys = Ember.keys(typeMaps);
12237
+ var keys = ember$data$lib$system$object$polyfills$$keysFunc(typeMaps);
12192
12238
 
12193
12239
  var types = ember$data$lib$system$store$$map.call(keys, byType);
12194
12240
 
@@ -12205,7 +12251,7 @@
12205
12251
  record.destroy(); // maybe within unloadRecord
12206
12252
  }
12207
12253
 
12208
- typeMap.metadata = Ember.create(null);
12254
+ typeMap.metadata = ember$data$lib$system$object$polyfills$$create(null);
12209
12255
  }
12210
12256
 
12211
12257
  function byType(entry) {
@@ -12525,9 +12571,9 @@
12525
12571
  }
12526
12572
 
12527
12573
  typeMap = {
12528
- idToRecord: Ember.create(null),
12574
+ idToRecord: ember$data$lib$system$object$polyfills$$create(null),
12529
12575
  records: [],
12530
- metadata: Ember.create(null),
12576
+ metadata: ember$data$lib$system$object$polyfills$$create(null),
12531
12577
  type: typeClass
12532
12578
  };
12533
12579
 
@@ -12743,9 +12789,9 @@
12743
12789
  // contains unknown keys, log a warning.
12744
12790
 
12745
12791
  if (Ember.ENV.DS_WARN_ON_UNKNOWN_KEYS) {
12746
- Ember.warn("The payload for '" + type.modelName + "' contains these unknown keys: " + Ember.inspect(filter.call(Ember.keys(data), function (key) {
12792
+ Ember.warn("The payload for '" + type.modelName + "' contains these unknown keys: " + Ember.inspect(filter.call(ember$data$lib$system$object$polyfills$$keysFunc(data), function (key) {
12747
12793
  return !(key === "id" || key === "links" || ember$data$lib$system$store$$get(type, "fields").has(key) || key.match(/Type$/));
12748
- })) + ". Make sure they've been defined in your model.", filter.call(Ember.keys(data), function (key) {
12794
+ })) + ". Make sure they've been defined in your model.", filter.call(ember$data$lib$system$object$polyfills$$keysFunc(data), function (key) {
12749
12795
  return !(key === "id" || key === "links" || ember$data$lib$system$store$$get(type, "fields").has(key) || key.match(/Type$/));
12750
12796
  }).length === 0);
12751
12797
  }
@@ -12826,7 +12872,7 @@
12826
12872
  var payload;
12827
12873
  if (!inputPayload) {
12828
12874
  payload = modelName;
12829
- serializer = ember$data$lib$system$store$$defaultSerializer(this.container);
12875
+ serializer = ember$data$lib$system$store$$defaultSerializer(this);
12830
12876
  Ember.assert("You cannot use `store#pushPayload` without a modelName unless your default serializer defines `pushPayload`", typeof serializer.pushPayload === "function");
12831
12877
  } else {
12832
12878
  payload = inputPayload;
@@ -13147,8 +13193,8 @@
13147
13193
 
13148
13194
  // Delegation to the adapter and promise management
13149
13195
 
13150
- function ember$data$lib$system$store$$defaultSerializer(container) {
13151
- return container.lookup("serializer:application") || container.lookup("serializer:-default");
13196
+ function ember$data$lib$system$store$$defaultSerializer(store) {
13197
+ return store.serializerFor("application");
13152
13198
  }
13153
13199
 
13154
13200
  function ember$data$lib$system$store$$_commit(adapter, store, operation, snapshot) {
@@ -13259,6 +13305,7 @@
13259
13305
  var ember$data$lib$system$store$$default = ember$data$lib$system$store$$Store;
13260
13306
 
13261
13307
  var ember$data$lib$serializers$json$api$serializer$$dasherize = Ember.String.dasherize;
13308
+ var ember$data$lib$serializers$json$api$serializer$$get = Ember.get;
13262
13309
  var ember$data$lib$serializers$json$api$serializer$$map = Ember.ArrayPolyfills.map;
13263
13310
 
13264
13311
  var ember$data$lib$serializers$json$api$serializer$$default = ember$data$lib$serializers$json$serializer$$default.extend({
@@ -13281,7 +13328,7 @@
13281
13328
 
13282
13329
  if (Ember.typeOf(documentHash.data) === 'object') {
13283
13330
  documentHash.data = this._normalizeResourceHelper(documentHash.data);
13284
- } else {
13331
+ } else if (Ember.typeOf(documentHash.data) === 'array') {
13285
13332
  documentHash.data = ember$data$lib$serializers$json$api$serializer$$map.call(documentHash.data, this._normalizeResourceHelper, this);
13286
13333
  }
13287
13334
 
@@ -13315,6 +13362,8 @@
13315
13362
  var modelClass = this.store.modelFor(modelName);
13316
13363
  var serializer = this.store.serializerFor(modelName);
13317
13364
 
13365
+ Ember.assert(this.toString() + ' is using the ' + (ember$data$lib$serializers$json$api$serializer$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + ' serializer API and expects ' + serializer.toString() + ' it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.', ember$data$lib$serializers$json$api$serializer$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$json$api$serializer$$get(serializer, 'isNewSerializerAPI'));
13366
+
13318
13367
  var _serializer$normalize = serializer.normalize(modelClass, resourceHash);
13319
13368
 
13320
13369
  var data = _serializer$normalize.data;
@@ -13454,7 +13503,7 @@
13454
13503
  this.normalizeUsingDeclaredMapping(modelClass, resourceHash);
13455
13504
 
13456
13505
  var data = {
13457
- id: this.extractId(resourceHash),
13506
+ id: this.extractId(modelClass, resourceHash),
13458
13507
  type: this._extractType(modelClass, resourceHash),
13459
13508
  attributes: this.extractAttributes(modelClass, resourceHash),
13460
13509
  relationships: this.extractRelationships(modelClass, resourceHash)
@@ -13641,7 +13690,7 @@
13641
13690
 
13642
13691
  if (store) {
13643
13692
  registry.register("service:store", store, { instantiate: false });
13644
- } else {
13693
+ } else if (!registry.has("service:store")) {
13645
13694
  registry.register("service:store", application && application.Store || ember$data$lib$system$store$$default);
13646
13695
  }
13647
13696
  }
@@ -13863,7 +13912,8 @@
13863
13912
  return ember$new$computed$lib$main$$computed.apply(undefined, polyfillArguments);
13864
13913
  }
13865
13914
 
13866
- var ember$new$computed$lib$main$$computedKeys = ember$lib$main$$default.keys(ember$new$computed$lib$main$$computed);
13915
+ var ember$new$computed$lib$main$$getKeys = Object.keys || ember$lib$main$$default.keys;
13916
+ var ember$new$computed$lib$main$$computedKeys = ember$new$computed$lib$main$$getKeys(ember$new$computed$lib$main$$computed);
13867
13917
 
13868
13918
  for (var ember$new$computed$lib$main$$i = 0, ember$new$computed$lib$main$$l = ember$new$computed$lib$main$$computedKeys.length; ember$new$computed$lib$main$$i < ember$new$computed$lib$main$$l; ember$new$computed$lib$main$$i++) {
13869
13919
  ember$new$computed$lib$main$$newComputed[ember$new$computed$lib$main$$computedKeys[ember$new$computed$lib$main$$i]] = ember$new$computed$lib$main$$computed[ember$new$computed$lib$main$$computedKeys[ember$new$computed$lib$main$$i]];
@@ -14876,6 +14926,9 @@
14876
14926
  if (parentRecord) {
14877
14927
  var name = parentRecord.name;
14878
14928
  var embeddedSerializer = this.store.serializerFor(embeddedSnapshot.modelName);
14929
+
14930
+ Ember.assert(this.toString() + ' is using the ' + (ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + ' serializer API and expects ' + embeddedSerializer.toString() + ' it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.', ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$embedded$records$mixin$$get(embeddedSerializer, 'isNewSerializerAPI'));
14931
+
14879
14932
  var parentKey = embeddedSerializer.keyForRelationship(name, parentRecord.kind, 'deserialize');
14880
14933
  if (parentKey) {
14881
14934
  delete json[parentKey];
@@ -14971,6 +15024,9 @@
14971
15024
  var ids = [];
14972
15025
 
14973
15026
  var embeddedSerializer = store.serializerFor(embeddedTypeClass.modelName);
15027
+
15028
+ Ember.assert(this.toString() + ' is using the ' + (ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + ' serializer API and expects ' + embeddedSerializer.toString() + ' it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.', ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$embedded$records$mixin$$get(embeddedSerializer, 'isNewSerializerAPI'));
15029
+
14974
15030
  ember$data$lib$serializers$embedded$records$mixin$$forEach.call(hash[key], function (data) {
14975
15031
  var embeddedRecord = embeddedSerializer.normalize(embeddedTypeClass, data, null);
14976
15032
  store.push(embeddedTypeClass.modelName, embeddedRecord);
@@ -14986,6 +15042,8 @@
14986
15042
  @private
14987
15043
  */
14988
15044
  _extractEmbeddedHasManyPolymorphic: function (store, key, hash) {
15045
+ var _this = this;
15046
+
14989
15047
  if (!hash[key]) {
14990
15048
  return hash;
14991
15049
  }
@@ -14995,6 +15053,9 @@
14995
15053
  ember$data$lib$serializers$embedded$records$mixin$$forEach.call(hash[key], function (data) {
14996
15054
  var modelName = data.type;
14997
15055
  var embeddedSerializer = store.serializerFor(modelName);
15056
+
15057
+ Ember.assert(_this.toString() + ' is using the ' + (ember$data$lib$serializers$embedded$records$mixin$$get(_this, 'isNewSerializerAPI') ? 'new' : 'old') + ' serializer API and expects ' + embeddedSerializer.toString() + ' it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.', ember$data$lib$serializers$embedded$records$mixin$$get(_this, 'isNewSerializerAPI') === ember$data$lib$serializers$embedded$records$mixin$$get(embeddedSerializer, 'isNewSerializerAPI'));
15058
+
14998
15059
  var embeddedTypeClass = store.modelFor(modelName);
14999
15060
  // var primaryKey = embeddedSerializer.get('primaryKey');
15000
15061
 
@@ -15021,6 +15082,9 @@
15021
15082
  }
15022
15083
 
15023
15084
  var embeddedSerializer = store.serializerFor(embeddedTypeClass.modelName);
15085
+
15086
+ Ember.assert(this.toString() + ' is using the ' + (ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + ' serializer API and expects ' + embeddedSerializer.toString() + ' it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.', ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$embedded$records$mixin$$get(embeddedSerializer, 'isNewSerializerAPI'));
15087
+
15024
15088
  var embeddedRecord = embeddedSerializer.normalize(embeddedTypeClass, hash[key], null);
15025
15089
  store.push(embeddedTypeClass.modelName, embeddedRecord);
15026
15090
 
@@ -15040,6 +15104,9 @@
15040
15104
  var data = hash[key];
15041
15105
  var modelName = data.type;
15042
15106
  var embeddedSerializer = store.serializerFor(modelName);
15107
+
15108
+ Ember.assert(this.toString() + ' is using the ' + (ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + ' serializer API and expects ' + embeddedSerializer.toString() + ' it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.', ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$embedded$records$mixin$$get(embeddedSerializer, 'isNewSerializerAPI'));
15109
+
15043
15110
  var embeddedTypeClass = store.modelFor(modelName);
15044
15111
  // var primaryKey = embeddedSerializer.get('primaryKey');
15045
15112
 
@@ -15063,6 +15130,8 @@
15063
15130
  var modelClass = store.modelFor(modelName);
15064
15131
  var serializer = store.serializerFor(modelName);
15065
15132
 
15133
+ Ember.assert(this.toString() + ' is using the ' + (ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + ' serializer API and expects ' + serializer.toString() + ' it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.', ember$data$lib$serializers$embedded$records$mixin$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$embedded$records$mixin$$get(serializer, 'isNewSerializerAPI'));
15134
+
15066
15135
  return serializer.normalize(modelClass, relationshipHash, null);
15067
15136
  }
15068
15137
 
@@ -15075,15 +15144,15 @@
15075
15144
  @private
15076
15145
  */
15077
15146
  function ember$data$lib$serializers$embedded$records$mixin$$_newExtractEmbeddedRecords(serializer, store, typeClass, partial) {
15078
- var _this = this;
15147
+ var _this2 = this;
15079
15148
 
15080
15149
  typeClass.eachRelationship(function (key, relationship) {
15081
15150
  if (serializer.hasDeserializeRecordsOption(key)) {
15082
15151
  if (relationship.kind === 'hasMany') {
15083
- _this._extractEmbeddedHasMany(store, key, partial, relationship);
15152
+ _this2._extractEmbeddedHasMany(store, key, partial, relationship);
15084
15153
  }
15085
15154
  if (relationship.kind === 'belongsTo') {
15086
- _this._extractEmbeddedBelongsTo(store, key, partial, relationship);
15155
+ _this2._extractEmbeddedBelongsTo(store, key, partial, relationship);
15087
15156
  }
15088
15157
  }
15089
15158
  }, this);
@@ -15095,7 +15164,7 @@
15095
15164
  @private
15096
15165
  */
15097
15166
  function ember$data$lib$serializers$embedded$records$mixin$$_newExtractEmbeddedHasMany(store, key, hash, relationshipMeta) {
15098
- var _this2 = this;
15167
+ var _this3 = this;
15099
15168
 
15100
15169
  var relationshipHash = ember$data$lib$serializers$embedded$records$mixin$$get(hash, 'data.relationships.' + key + '.data');
15101
15170
  if (!relationshipHash) {
@@ -15103,7 +15172,7 @@
15103
15172
  }
15104
15173
 
15105
15174
  var hasMany = relationshipHash.map(function (item) {
15106
- var _normalizeEmbeddedRelationship = _this2._normalizeEmbeddedRelationship(store, relationshipMeta, item);
15175
+ var _normalizeEmbeddedRelationship = _this3._normalizeEmbeddedRelationship(store, relationshipMeta, item);
15107
15176
 
15108
15177
  var data = _normalizeEmbeddedRelationship.data;
15109
15178
  var included = _normalizeEmbeddedRelationship.included;
@@ -15657,7 +15726,7 @@
15657
15726
  },
15658
15727
 
15659
15728
  inverseMap: Ember.computed(function () {
15660
- return Ember.create(null);
15729
+ return ember$data$lib$system$object$polyfills$$create(null);
15661
15730
  }),
15662
15731
 
15663
15732
  /**