ember-data-source 1.0.0.beta.11 → 1.0.0.beta.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  (function(global){
2
- var define, requireModule, require, requirejs;
2
+ var enifed, requireModule, eriuqer, requirejs;
3
3
 
4
4
  (function() {
5
5
 
@@ -15,7 +15,7 @@ var define, requireModule, require, requirejs;
15
15
  var registry = {}, seen = {}, state = {};
16
16
  var FAILED = false;
17
17
 
18
- define = function(name, deps, callback) {
18
+ enifed = function(name, deps, callback) {
19
19
 
20
20
  if (!_isArray(deps)) {
21
21
  callback = deps;
@@ -39,7 +39,7 @@ var define, requireModule, require, requirejs;
39
39
  if (dep === 'exports') {
40
40
  exports = reified[i] = seen;
41
41
  } else {
42
- reified[i] = require(resolve(dep, name));
42
+ reified[i] = eriuqer(resolve(dep, name));
43
43
  }
44
44
  }
45
45
 
@@ -49,7 +49,7 @@ var define, requireModule, require, requirejs;
49
49
  };
50
50
  }
51
51
 
52
- requirejs = require = requireModule = function(name) {
52
+ requirejs = eriuqer = requireModule = function(name) {
53
53
  if (state[name] !== FAILED &&
54
54
  seen.hasOwnProperty(name)) {
55
55
  return seen[name];
@@ -110,7 +110,7 @@ var define, requireModule, require, requirejs;
110
110
  };
111
111
  })();
112
112
 
113
- define("activemodel-adapter",
113
+ enifed("activemodel-adapter",
114
114
  ["activemodel-adapter/system","exports"],
115
115
  function(__dependency1__, __exports__) {
116
116
  "use strict";
@@ -120,7 +120,7 @@ define("activemodel-adapter",
120
120
  __exports__.ActiveModelAdapter = ActiveModelAdapter;
121
121
  __exports__.ActiveModelSerializer = ActiveModelSerializer;
122
122
  });
123
- define("activemodel-adapter/setup-container",
123
+ enifed("activemodel-adapter/setup-container",
124
124
  ["ember-data/system/container_proxy","activemodel-adapter/system/active_model_serializer","activemodel-adapter/system/active_model_adapter","exports"],
125
125
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
126
126
  "use strict";
@@ -139,7 +139,7 @@ define("activemodel-adapter/setup-container",
139
139
  container.register('adapter:-active-model', ActiveModelAdapter);
140
140
  };
141
141
  });
142
- define("activemodel-adapter/system",
142
+ enifed("activemodel-adapter/system",
143
143
  ["activemodel-adapter/system/active_model_adapter","activemodel-adapter/system/active_model_serializer","exports"],
144
144
  function(__dependency1__, __dependency2__, __exports__) {
145
145
  "use strict";
@@ -149,7 +149,7 @@ define("activemodel-adapter/system",
149
149
  __exports__.ActiveModelAdapter = ActiveModelAdapter;
150
150
  __exports__.ActiveModelSerializer = ActiveModelSerializer;
151
151
  });
152
- define("activemodel-adapter/system/active_model_adapter",
152
+ enifed("activemodel-adapter/system/active_model_adapter",
153
153
  ["ember-data/adapters","ember-data/system/adapter","ember-inflector","exports"],
154
154
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
155
155
  "use strict";
@@ -161,7 +161,6 @@ define("activemodel-adapter/system/active_model_adapter",
161
161
  @module ember-data
162
162
  */
163
163
 
164
- var forEach = Ember.EnumerableUtils.forEach;
165
164
  var decamelize = Ember.String.decamelize,
166
165
  underscore = Ember.String.underscore;
167
166
 
@@ -171,7 +170,7 @@ define("activemodel-adapter/system/active_model_adapter",
171
170
  It has been designed to work out of the box with the
172
171
  [active_model_serializers](http://github.com/rails-api/active_model_serializers)
173
172
  Ruby gem. This Adapter expects specific settings using ActiveModel::Serializers,
174
- `embed :ids, include: true` which sideloads the records.
173
+ `embed :ids, embed_in_root: true` which sideloads the records.
175
174
 
176
175
  This adapter extends the DS.RESTAdapter by making consistent use of the camelization,
177
176
  decamelization and pluralization methods to normalize the serialized JSON into a
@@ -297,18 +296,7 @@ define("activemodel-adapter/system/active_model_adapter",
297
296
  var error = this._super(jqXHR);
298
297
 
299
298
  if (jqXHR && jqXHR.status === 422) {
300
- var response = Ember.$.parseJSON(jqXHR.responseText),
301
- errors = {};
302
-
303
- if (response.errors !== undefined) {
304
- var jsonErrors = response.errors;
305
-
306
- forEach(Ember.keys(jsonErrors), function(key) {
307
- errors[Ember.String.camelize(key)] = jsonErrors[key];
308
- });
309
- }
310
-
311
- return new InvalidError(errors);
299
+ return new InvalidError(Ember.$.parseJSON(jqXHR.responseText));
312
300
  } else {
313
301
  return error;
314
302
  }
@@ -317,7 +305,7 @@ define("activemodel-adapter/system/active_model_adapter",
317
305
 
318
306
  __exports__["default"] = ActiveModelAdapter;
319
307
  });
320
- define("activemodel-adapter/system/active_model_serializer",
308
+ enifed("activemodel-adapter/system/active_model_serializer",
321
309
  ["ember-inflector","ember-data/serializers/rest_serializer","exports"],
322
310
  function(__dependency1__, __dependency2__, __exports__) {
323
311
  "use strict";
@@ -339,7 +327,7 @@ define("activemodel-adapter/system/active_model_serializer",
339
327
  It has been designed to work out of the box with the
340
328
  [active_model_serializers](http://github.com/rails-api/active_model_serializers)
341
329
  Ruby gem. This Serializer expects specific settings using ActiveModel::Serializers,
342
- `embed :ids, include: true` which sideloads the records.
330
+ `embed :ids, embed_in_root: true` which sideloads the records.
343
331
 
344
332
  This serializer extends the DS.RESTSerializer by making consistent
345
333
  use of the camelization, decamelization and pluralization methods to
@@ -613,9 +601,9 @@ define("activemodel-adapter/system/active_model_serializer",
613
601
 
614
602
  __exports__["default"] = ActiveModelSerializer;
615
603
  });
616
- define("ember-data",
617
- ["ember-data/core","ember-data/ext/date","ember-data/system/promise_proxies","ember-data/system/store","ember-data/system/model","ember-data/system/adapter","ember-data/system/debug","ember-data/system/record_arrays","ember-data/system/record_array_manager","ember-data/adapters","ember-data/serializers/json_serializer","ember-data/serializers/rest_serializer","ember-inflector","ember-data/serializers/embedded_records_mixin","activemodel-adapter","ember-data/transforms","ember-data/system/relationships","ember-data/ember-initializer","ember-data/setup-container","ember-data/system/container_proxy","ember-data/system/relationships/relationship","exports"],
618
- function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __dependency20__, __dependency21__, __exports__) {
604
+ enifed("ember-data",
605
+ ["ember-data/system/create","ember-data/core","ember-data/ext/date","ember-data/system/promise_proxies","ember-data/system/store","ember-data/system/model","ember-data/system/adapter","ember-data/system/debug","ember-data/system/record_arrays","ember-data/system/record_array_manager","ember-data/adapters","ember-data/serializers/json_serializer","ember-data/serializers/rest_serializer","ember-inflector","ember-data/serializers/embedded_records_mixin","activemodel-adapter","ember-data/transforms","ember-data/system/relationships","ember-data/ember-initializer","ember-data/setup-container","ember-data/system/container_proxy","ember-data/system/relationships/relationship","exports"],
606
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __dependency20__, __dependency21__, __dependency22__, __exports__) {
619
607
  "use strict";
620
608
  /**
621
609
  Ember Data
@@ -627,43 +615,43 @@ define("ember-data",
627
615
  // support RSVP 2.x via resolve, but prefer RSVP 3.x's Promise.cast
628
616
  Ember.RSVP.Promise.cast = Ember.RSVP.Promise.cast || Ember.RSVP.resolve;
629
617
 
630
- var DS = __dependency1__["default"];
631
-
632
- var PromiseArray = __dependency3__.PromiseArray;
633
- var PromiseObject = __dependency3__.PromiseObject;
634
- var Store = __dependency4__.Store;
635
- var Model = __dependency5__.Model;
636
- var Errors = __dependency5__.Errors;
637
- var RootState = __dependency5__.RootState;
638
- var attr = __dependency5__.attr;
639
- var InvalidError = __dependency6__.InvalidError;
640
- var Adapter = __dependency6__.Adapter;
641
- var DebugAdapter = __dependency7__["default"];
642
- var RecordArray = __dependency8__.RecordArray;
643
- var FilteredRecordArray = __dependency8__.FilteredRecordArray;
644
- var AdapterPopulatedRecordArray = __dependency8__.AdapterPopulatedRecordArray;
645
- var ManyArray = __dependency8__.ManyArray;
646
- var RecordArrayManager = __dependency9__["default"];
647
- var RESTAdapter = __dependency10__.RESTAdapter;
648
- var FixtureAdapter = __dependency10__.FixtureAdapter;
649
- var JSONSerializer = __dependency11__["default"];
650
- var RESTSerializer = __dependency12__["default"];
651
- var EmbeddedRecordsMixin = __dependency14__["default"];
652
- var ActiveModelAdapter = __dependency15__.ActiveModelAdapter;
653
- var ActiveModelSerializer = __dependency15__.ActiveModelSerializer;
654
-
655
- var Transform = __dependency16__.Transform;
656
- var DateTransform = __dependency16__.DateTransform;
657
- var NumberTransform = __dependency16__.NumberTransform;
658
- var StringTransform = __dependency16__.StringTransform;
659
- var BooleanTransform = __dependency16__.BooleanTransform;
660
-
661
- var hasMany = __dependency17__.hasMany;
662
- var belongsTo = __dependency17__.belongsTo;
663
- var setupContainer = __dependency19__["default"];
664
-
665
- var ContainerProxy = __dependency20__["default"];
666
- var Relationship = __dependency21__.Relationship;
618
+ var DS = __dependency2__["default"];
619
+
620
+ var PromiseArray = __dependency4__.PromiseArray;
621
+ var PromiseObject = __dependency4__.PromiseObject;
622
+ var Store = __dependency5__.Store;
623
+ var Model = __dependency6__.Model;
624
+ var Errors = __dependency6__.Errors;
625
+ var RootState = __dependency6__.RootState;
626
+ var attr = __dependency6__.attr;
627
+ var InvalidError = __dependency7__.InvalidError;
628
+ var Adapter = __dependency7__.Adapter;
629
+ var DebugAdapter = __dependency8__["default"];
630
+ var RecordArray = __dependency9__.RecordArray;
631
+ var FilteredRecordArray = __dependency9__.FilteredRecordArray;
632
+ var AdapterPopulatedRecordArray = __dependency9__.AdapterPopulatedRecordArray;
633
+ var ManyArray = __dependency9__.ManyArray;
634
+ var RecordArrayManager = __dependency10__["default"];
635
+ var RESTAdapter = __dependency11__.RESTAdapter;
636
+ var FixtureAdapter = __dependency11__.FixtureAdapter;
637
+ var JSONSerializer = __dependency12__["default"];
638
+ var RESTSerializer = __dependency13__["default"];
639
+ var EmbeddedRecordsMixin = __dependency15__["default"];
640
+ var ActiveModelAdapter = __dependency16__.ActiveModelAdapter;
641
+ var ActiveModelSerializer = __dependency16__.ActiveModelSerializer;
642
+
643
+ var Transform = __dependency17__.Transform;
644
+ var DateTransform = __dependency17__.DateTransform;
645
+ var NumberTransform = __dependency17__.NumberTransform;
646
+ var StringTransform = __dependency17__.StringTransform;
647
+ var BooleanTransform = __dependency17__.BooleanTransform;
648
+
649
+ var hasMany = __dependency18__.hasMany;
650
+ var belongsTo = __dependency18__.belongsTo;
651
+ var setupContainer = __dependency20__["default"];
652
+
653
+ var ContainerProxy = __dependency21__["default"];
654
+ var Relationship = __dependency22__.Relationship;
667
655
 
668
656
  DS.Store = Store;
669
657
  DS.PromiseArray = PromiseArray;
@@ -715,7 +703,7 @@ define("ember-data",
715
703
 
716
704
  __exports__["default"] = DS;
717
705
  });
718
- define("ember-data/adapters",
706
+ enifed("ember-data/adapters",
719
707
  ["ember-data/adapters/fixture_adapter","ember-data/adapters/rest_adapter","exports"],
720
708
  function(__dependency1__, __dependency2__, __exports__) {
721
709
  "use strict";
@@ -729,7 +717,7 @@ define("ember-data/adapters",
729
717
  __exports__.RESTAdapter = RESTAdapter;
730
718
  __exports__.FixtureAdapter = FixtureAdapter;
731
719
  });
732
- define("ember-data/adapters/fixture_adapter",
720
+ enifed("ember-data/adapters/fixture_adapter",
733
721
  ["ember-data/system/adapter","exports"],
734
722
  function(__dependency1__, __exports__) {
735
723
  "use strict";
@@ -1069,7 +1057,7 @@ define("ember-data/adapters/fixture_adapter",
1069
1057
  }
1070
1058
  });
1071
1059
  });
1072
- define("ember-data/adapters/rest_adapter",
1060
+ enifed("ember-data/adapters/rest_adapter",
1073
1061
  ["ember-data/system/adapter","ember-data/system/map","exports"],
1074
1062
  function(__dependency1__, __dependency2__, __exports__) {
1075
1063
  "use strict";
@@ -1656,7 +1644,7 @@ define("ember-data/adapters/rest_adapter",
1656
1644
  },
1657
1645
 
1658
1646
  _stripIDFromURL: function(store, record) {
1659
- var type = store.modelFor(record);
1647
+ var type = record.constructor;
1660
1648
  var url = this.buildURL(type.typeKey, record.get('id'), record);
1661
1649
 
1662
1650
  var expandedURL = url.split('/');
@@ -1673,6 +1661,11 @@ define("ember-data/adapters/rest_adapter",
1673
1661
  return expandedURL.join('/');
1674
1662
  },
1675
1663
 
1664
+ /**
1665
+ http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
1666
+ */
1667
+ maxUrlLength: 2048,
1668
+
1676
1669
  /**
1677
1670
  Organize records into groups, each of which is to be passed to separate
1678
1671
  calls to `findMany`.
@@ -1690,6 +1683,7 @@ define("ember-data/adapters/rest_adapter",
1690
1683
  and `/posts/2/comments/3`
1691
1684
 
1692
1685
  @method groupRecordsForFindMany
1686
+ @param {DS.Store} store
1693
1687
  @param {Array} records
1694
1688
  @return {Array} an array of arrays of records, each of which is to be
1695
1689
  loaded separately by `findMany`.
@@ -1697,19 +1691,20 @@ define("ember-data/adapters/rest_adapter",
1697
1691
  groupRecordsForFindMany: function (store, records) {
1698
1692
  var groups = MapWithDefault.create({defaultValue: function(){return [];}});
1699
1693
  var adapter = this;
1694
+ var maxUrlLength = this.maxUrlLength;
1700
1695
 
1701
1696
  forEach.call(records, function(record){
1702
1697
  var baseUrl = adapter._stripIDFromURL(store, record);
1703
1698
  groups.get(baseUrl).push(record);
1704
1699
  });
1705
1700
 
1706
- function splitGroupToFitInUrl(group, maxUrlLength) {
1701
+ function splitGroupToFitInUrl(group, maxUrlLength, paramNameLength) {
1707
1702
  var baseUrl = adapter._stripIDFromURL(store, group[0]);
1708
1703
  var idsSize = 0;
1709
1704
  var splitGroups = [[]];
1710
1705
 
1711
1706
  forEach.call(group, function(record) {
1712
- var additionalLength = '&ids[]='.length + record.get('id.length');
1707
+ var additionalLength = encodeURIComponent(record.get('id')).length + paramNameLength;
1713
1708
  if (baseUrl.length + idsSize + additionalLength >= maxUrlLength) {
1714
1709
  idsSize = 0;
1715
1710
  splitGroups.push([]);
@@ -1726,9 +1721,8 @@ define("ember-data/adapters/rest_adapter",
1726
1721
 
1727
1722
  var groupsArray = [];
1728
1723
  groups.forEach(function(group, key){
1729
- // http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
1730
- var maxUrlLength = 2048;
1731
- var splitGroups = splitGroupToFitInUrl(group, maxUrlLength);
1724
+ var paramNameLength = '&ids%5B%5D='.length;
1725
+ var splitGroups = splitGroupToFitInUrl(group, maxUrlLength, paramNameLength);
1732
1726
 
1733
1727
  forEach.call(splitGroups, function(splitGroup) {
1734
1728
  groupsArray.push(splitGroup);
@@ -1768,19 +1762,25 @@ define("ember-data/adapters/rest_adapter",
1768
1762
  },
1769
1763
 
1770
1764
  /**
1771
- Takes an ajax response, and returns a relevant error.
1765
+ Takes an ajax response, and returns an error payload.
1772
1766
 
1773
1767
  Returning a `DS.InvalidError` from this method will cause the
1774
1768
  record to transition into the `invalid` state and make the
1775
1769
  `errors` object available on the record.
1776
1770
 
1771
+ This function should return the entire payload as received from the
1772
+ server. Error object extraction and normalization of model errors
1773
+ should be performed by `extractErrors` on the serializer.
1774
+
1775
+ Example
1776
+
1777
1777
  ```javascript
1778
1778
  App.ApplicationAdapter = DS.RESTAdapter.extend({
1779
1779
  ajaxError: function(jqXHR) {
1780
1780
  var error = this._super(jqXHR);
1781
1781
 
1782
1782
  if (jqXHR && jqXHR.status === 422) {
1783
- var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)["errors"];
1783
+ var jsonErrors = Ember.$.parseJSON(jqXHR.responseText);
1784
1784
 
1785
1785
  return new DS.InvalidError(jsonErrors);
1786
1786
  } else {
@@ -1824,12 +1824,12 @@ define("ember-data/adapters/rest_adapter",
1824
1824
  2. Your API might return errors as successful responses with status code
1825
1825
  200 and an Errors text or object. You can return a DS.InvalidError from
1826
1826
  this hook and it will automatically reject the promise and put your record
1827
- into the invald state.
1827
+ into the invalid state.
1828
1828
 
1829
- @method ajaxError
1829
+ @method ajaxSuccess
1830
1830
  @param {Object} jqXHR
1831
1831
  @param {Object} jsonPayload
1832
- @return {Object} jqXHR
1832
+ @return {Object} jsonPayload
1833
1833
  */
1834
1834
 
1835
1835
  ajaxSuccess: function(jqXHR, jsonPayload) {
@@ -1925,7 +1925,7 @@ define("ember-data/adapters/rest_adapter",
1925
1925
  }
1926
1926
  }
1927
1927
  });
1928
- define("ember-data/core",
1928
+ enifed("ember-data/core",
1929
1929
  ["exports"],
1930
1930
  function(__exports__) {
1931
1931
  "use strict";
@@ -1944,11 +1944,11 @@ define("ember-data/core",
1944
1944
  /**
1945
1945
  @property VERSION
1946
1946
  @type String
1947
- @default '1.0.0-beta.11'
1947
+ @default '1.0.0-beta.12'
1948
1948
  @static
1949
1949
  */
1950
1950
  DS = Ember.Namespace.create({
1951
- VERSION: '1.0.0-beta.11'
1951
+ VERSION: '1.0.0-beta.12'
1952
1952
  });
1953
1953
 
1954
1954
  if (Ember.libraries) {
@@ -1958,7 +1958,7 @@ define("ember-data/core",
1958
1958
 
1959
1959
  __exports__["default"] = DS;
1960
1960
  });
1961
- define("ember-data/ember-initializer",
1961
+ enifed("ember-data/ember-initializer",
1962
1962
  ["ember-data/setup-container"],
1963
1963
  function(__dependency1__) {
1964
1964
  "use strict";
@@ -2042,7 +2042,7 @@ define("ember-data/ember-initializer",
2042
2042
  });
2043
2043
  });
2044
2044
  });
2045
- define("ember-data/ext/date",
2045
+ enifed("ember-data/ext/date",
2046
2046
  [],
2047
2047
  function() {
2048
2048
  "use strict";
@@ -2108,7 +2108,7 @@ define("ember-data/ext/date",
2108
2108
  Date.parse = Ember.Date.parse;
2109
2109
  }
2110
2110
  });
2111
- define("ember-data/initializers/data_adapter",
2111
+ enifed("ember-data/initializers/data_adapter",
2112
2112
  ["ember-data/system/debug/debug_adapter","exports"],
2113
2113
  function(__dependency1__, __exports__) {
2114
2114
  "use strict";
@@ -2125,7 +2125,7 @@ define("ember-data/initializers/data_adapter",
2125
2125
  container.register('data-adapter:main', DebugAdapter);
2126
2126
  };
2127
2127
  });
2128
- define("ember-data/initializers/store",
2128
+ enifed("ember-data/initializers/store",
2129
2129
  ["ember-data/serializers","ember-data/adapters","ember-data/system/container_proxy","ember-data/system/store","exports"],
2130
2130
  function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
2131
2131
  "use strict";
@@ -2166,7 +2166,7 @@ define("ember-data/initializers/store",
2166
2166
  container.lookup('store:main');
2167
2167
  };
2168
2168
  });
2169
- define("ember-data/initializers/store_injections",
2169
+ enifed("ember-data/initializers/store_injections",
2170
2170
  ["exports"],
2171
2171
  function(__exports__) {
2172
2172
  "use strict";
@@ -2184,7 +2184,7 @@ define("ember-data/initializers/store_injections",
2184
2184
  container.injection('data-adapter', 'store', 'store:main');
2185
2185
  };
2186
2186
  });
2187
- define("ember-data/initializers/transforms",
2187
+ enifed("ember-data/initializers/transforms",
2188
2188
  ["ember-data/transforms","exports"],
2189
2189
  function(__dependency1__, __exports__) {
2190
2190
  "use strict";
@@ -2207,7 +2207,7 @@ define("ember-data/initializers/transforms",
2207
2207
  container.register('transform:string', StringTransform);
2208
2208
  };
2209
2209
  });
2210
- define("ember-data/serializers",
2210
+ enifed("ember-data/serializers",
2211
2211
  ["ember-data/serializers/json_serializer","ember-data/serializers/rest_serializer","exports"],
2212
2212
  function(__dependency1__, __dependency2__, __exports__) {
2213
2213
  "use strict";
@@ -2217,7 +2217,7 @@ define("ember-data/serializers",
2217
2217
  __exports__.JSONSerializer = JSONSerializer;
2218
2218
  __exports__.RESTSerializer = RESTSerializer;
2219
2219
  });
2220
- define("ember-data/serializers/embedded_records_mixin",
2220
+ enifed("ember-data/serializers/embedded_records_mixin",
2221
2221
  ["exports"],
2222
2222
  function(__exports__) {
2223
2223
  "use strict";
@@ -2687,7 +2687,7 @@ define("ember-data/serializers/embedded_records_mixin",
2687
2687
 
2688
2688
  __exports__["default"] = EmbeddedRecordsMixin;
2689
2689
  });
2690
- define("ember-data/serializers/json_serializer",
2690
+ enifed("ember-data/serializers/json_serializer",
2691
2691
  ["exports"],
2692
2692
  function(__exports__) {
2693
2693
  "use strict";
@@ -2953,6 +2953,16 @@ define("ember-data/serializers/json_serializer",
2953
2953
  delete hash[primaryKey];
2954
2954
  },
2955
2955
 
2956
+ /**
2957
+ @method normalizeErrors
2958
+ @private
2959
+ */
2960
+ normalizeErrors: function(type, hash) {
2961
+ this.normalizeId(hash);
2962
+ this.normalizeAttributes(type, hash);
2963
+ this.normalizeRelationships(type, hash);
2964
+ },
2965
+
2956
2966
  /**
2957
2967
  Looks up the property key that was set by the custom `attr` mapping
2958
2968
  passed to the serializer.
@@ -3663,6 +3673,41 @@ define("ember-data/serializers/json_serializer",
3663
3673
  }
3664
3674
  },
3665
3675
 
3676
+ /**
3677
+ `extractErrors` is used to extract model errors when a call is made
3678
+ to `DS.Model#save` which fails with an InvalidError`. By default
3679
+ Ember Data expects error information to be located on the `errors`
3680
+ property of the payload object.
3681
+
3682
+ Example
3683
+
3684
+ ```javascript
3685
+ App.PostSerializer = DS.JSONSerializer.extend({
3686
+ extractErrors: function(store, type, payload, id) {
3687
+ if (payload && typeof payload === 'object' && payload._problems) {
3688
+ payload = payload._problems;
3689
+ this.normalizeErrors(type, payload);
3690
+ }
3691
+ return payload;
3692
+ }
3693
+ });
3694
+ ```
3695
+
3696
+ @method extractErrors
3697
+ @param {DS.Store} store
3698
+ @param {subclass of DS.Model} type
3699
+ @param {Object} payload
3700
+ @param {String or Number} id
3701
+ @return {Object} json The deserialized errors
3702
+ */
3703
+ extractErrors: function(store, type, payload, id) {
3704
+ if (payload && typeof payload === 'object' && payload.errors) {
3705
+ payload = payload.errors;
3706
+ this.normalizeErrors(type, payload);
3707
+ }
3708
+ return payload;
3709
+ },
3710
+
3666
3711
  /**
3667
3712
  `keyForAttribute` can be used to define rules for how to convert an
3668
3713
  attribute name in your model to a key in your JSON.
@@ -3725,7 +3770,7 @@ define("ember-data/serializers/json_serializer",
3725
3770
  }
3726
3771
  });
3727
3772
  });
3728
- define("ember-data/serializers/rest_serializer",
3773
+ enifed("ember-data/serializers/rest_serializer",
3729
3774
  ["ember-data/serializers/json_serializer","ember-inflector/system/string","exports"],
3730
3775
  function(__dependency1__, __dependency2__, __exports__) {
3731
3776
  "use strict";
@@ -3998,6 +4043,7 @@ define("ember-data/serializers/rest_serializer",
3998
4043
 
3999
4044
  for (var prop in payload) {
4000
4045
  var typeName = this.typeForRoot(prop);
4046
+
4001
4047
  if (!store.modelFactoryFor(typeName)){
4002
4048
  continue;
4003
4049
  }
@@ -4005,6 +4051,10 @@ define("ember-data/serializers/rest_serializer",
4005
4051
  var isPrimary = type.typeKey === primaryTypeName;
4006
4052
  var value = payload[prop];
4007
4053
 
4054
+ if (value === null) {
4055
+ continue;
4056
+ }
4057
+
4008
4058
  // legacy support for singular resources
4009
4059
  if (isPrimary && Ember.typeOf(value) !== "array" ) {
4010
4060
  primaryRecord = this.normalize(primaryType, value, prop);
@@ -4474,7 +4524,7 @@ define("ember-data/serializers/rest_serializer",
4474
4524
 
4475
4525
  __exports__["default"] = RESTSerializer;
4476
4526
  });
4477
- define("ember-data/setup-container",
4527
+ enifed("ember-data/setup-container",
4478
4528
  ["ember-data/initializers/store","ember-data/initializers/transforms","ember-data/initializers/store_injections","ember-data/initializers/data_adapter","activemodel-adapter/setup-container","exports"],
4479
4529
  function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
4480
4530
  "use strict";
@@ -4496,7 +4546,7 @@ define("ember-data/setup-container",
4496
4546
  setupActiveModelContainer(container, application);
4497
4547
  };
4498
4548
  });
4499
- define("ember-data/system/adapter",
4549
+ enifed("ember-data/system/adapter",
4500
4550
  ["exports"],
4501
4551
  function(__exports__) {
4502
4552
  "use strict";
@@ -4525,6 +4575,10 @@ define("ember-data/system/adapter",
4525
4575
  transition to the `invalid` state and the errors will be set to the
4526
4576
  `errors` property on the record.
4527
4577
 
4578
+ This function should return the entire payload as received from the
4579
+ server. Error object extraction and normalization of model errors
4580
+ should be performed by `extractErrors` on the serializer.
4581
+
4528
4582
  Example
4529
4583
 
4530
4584
  ```javascript
@@ -4533,7 +4587,7 @@ define("ember-data/system/adapter",
4533
4587
  var error = this._super(jqXHR);
4534
4588
 
4535
4589
  if (jqXHR && jqXHR.status === 422) {
4536
- var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)["errors"];
4590
+ var jsonErrors = Ember.$.parseJSON(jqXHR.responseText);
4537
4591
  return new DS.InvalidError(jsonErrors);
4538
4592
  } else {
4539
4593
  return error;
@@ -4549,7 +4603,7 @@ define("ember-data/system/adapter",
4549
4603
  ```javascript
4550
4604
  return new DS.InvalidError({
4551
4605
  length: 'Must be less than 15',
4552
- name: 'Must not be blank
4606
+ name: 'Must not be blank'
4553
4607
  });
4554
4608
  ```
4555
4609
 
@@ -4948,6 +5002,7 @@ define("ember-data/system/adapter",
4948
5002
  The default implementation returns the records as a single group.
4949
5003
 
4950
5004
  @method groupRecordsForFindMany
5005
+ @param {DS.Store} store
4951
5006
  @param {Array} records
4952
5007
  @return {Array} an array of arrays of records, each of which is to be
4953
5008
  loaded separately by `findMany`.
@@ -4961,7 +5016,7 @@ define("ember-data/system/adapter",
4961
5016
  __exports__.Adapter = Adapter;
4962
5017
  __exports__["default"] = Adapter;
4963
5018
  });
4964
- define("ember-data/system/container_proxy",
5019
+ enifed("ember-data/system/container_proxy",
4965
5020
  ["exports"],
4966
5021
  function(__exports__) {
4967
5022
  "use strict";
@@ -5014,7 +5069,21 @@ define("ember-data/system/container_proxy",
5014
5069
 
5015
5070
  __exports__["default"] = ContainerProxy;
5016
5071
  });
5017
- define("ember-data/system/debug",
5072
+ enifed("ember-data/system/create",
5073
+ [],
5074
+ function() {
5075
+ "use strict";
5076
+ /*
5077
+ Detect if the user has a correct Object.create shim.
5078
+ Ember has provided this for a long time but has had an incorrect shim before 1.8
5079
+ TODO: Remove for Ember Data 1.0.
5080
+ */
5081
+ var object = Ember.create(null);
5082
+ if (object.toString !== undefined && Ember.keys(Ember.create({}))[0] === '__proto__'){
5083
+ throw new Error("Ember Data requires a correct Object.create shim. You should upgrade to Ember >= 1.8 which provides one for you. If you are using ES5-shim, you should try removing that after upgrading Ember.");
5084
+ }
5085
+ });
5086
+ enifed("ember-data/system/debug",
5018
5087
  ["ember-data/system/debug/debug_info","ember-data/system/debug/debug_adapter","exports"],
5019
5088
  function(__dependency1__, __dependency2__, __exports__) {
5020
5089
  "use strict";
@@ -5026,7 +5095,7 @@ define("ember-data/system/debug",
5026
5095
 
5027
5096
  __exports__["default"] = DebugAdapter;
5028
5097
  });
5029
- define("ember-data/system/debug/debug_adapter",
5098
+ enifed("ember-data/system/debug/debug_adapter",
5030
5099
  ["ember-data/system/model","exports"],
5031
5100
  function(__dependency1__, __exports__) {
5032
5101
  "use strict";
@@ -5149,7 +5218,7 @@ define("ember-data/system/debug/debug_adapter",
5149
5218
 
5150
5219
  });
5151
5220
  });
5152
- define("ember-data/system/debug/debug_info",
5221
+ enifed("ember-data/system/debug/debug_info",
5153
5222
  ["ember-data/system/model","exports"],
5154
5223
  function(__dependency1__, __exports__) {
5155
5224
  "use strict";
@@ -5223,7 +5292,7 @@ define("ember-data/system/debug/debug_info",
5223
5292
 
5224
5293
  __exports__["default"] = Model;
5225
5294
  });
5226
- define("ember-data/system/map",
5295
+ enifed("ember-data/system/map",
5227
5296
  ["exports"],
5228
5297
  function(__exports__) {
5229
5298
  "use strict";
@@ -5254,9 +5323,9 @@ define("ember-data/system/map",
5254
5323
  usesOldBehavior = value === 'key' && key === 'value';
5255
5324
  });
5256
5325
 
5257
- Map.prototype = Object.create(Ember.Map.prototype);
5258
- MapWithDefault.prototype = Object.create(Ember.MapWithDefault.prototype);
5259
- OrderedSet.prototype = Object.create(Ember.OrderedSet.prototype);
5326
+ Map.prototype = Ember.create(Ember.Map.prototype);
5327
+ MapWithDefault.prototype = Ember.create(Ember.MapWithDefault.prototype);
5328
+ OrderedSet.prototype = Ember.create(Ember.OrderedSet.prototype);
5260
5329
 
5261
5330
  OrderedSet.create = function(){
5262
5331
  return new OrderedSet();
@@ -5318,7 +5387,7 @@ define("ember-data/system/map",
5318
5387
  __exports__.MapWithDefault = MapWithDefault;
5319
5388
  __exports__.OrderedSet = OrderedSet;
5320
5389
  });
5321
- define("ember-data/system/model",
5390
+ enifed("ember-data/system/model",
5322
5391
  ["ember-data/system/model/model","ember-data/system/model/attributes","ember-data/system/model/states","ember-data/system/model/errors","exports"],
5323
5392
  function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
5324
5393
  "use strict";
@@ -5336,7 +5405,7 @@ define("ember-data/system/model",
5336
5405
  __exports__.attr = attr;
5337
5406
  __exports__.Errors = Errors;
5338
5407
  });
5339
- define("ember-data/system/model/attributes",
5408
+ enifed("ember-data/system/model/attributes",
5340
5409
  ["ember-data/system/model/model","ember-data/system/map","exports"],
5341
5410
  function(__dependency1__, __dependency2__, __exports__) {
5342
5411
  "use strict";
@@ -5615,7 +5684,7 @@ define("ember-data/system/model/attributes",
5615
5684
  options: options
5616
5685
  };
5617
5686
 
5618
- return Ember.computed('data', function(key, value) {
5687
+ return Ember.computed(function(key, value) {
5619
5688
  if (arguments.length > 1) {
5620
5689
  var oldValue = getValue(this, key);
5621
5690
 
@@ -5645,7 +5714,7 @@ define("ember-data/system/model/attributes",
5645
5714
  }).meta(meta);
5646
5715
  };
5647
5716
  });
5648
- define("ember-data/system/model/errors",
5717
+ enifed("ember-data/system/model/errors",
5649
5718
  ["ember-data/system/map","exports"],
5650
5719
  function(__dependency1__, __exports__) {
5651
5720
  "use strict";
@@ -5666,7 +5735,7 @@ define("ember-data/system/model/errors",
5666
5735
  `DS.Errors`. This can be used to display validation error
5667
5736
  messages returned from the server when a `record.save()` rejects.
5668
5737
  This works automatically with `DS.ActiveModelAdapter`, but you
5669
- can implement [ajaxError](api/data/classes/DS.RESTAdapter.html#method_ajaxError)
5738
+ can implement [ajaxError](/api/data/classes/DS.RESTAdapter.html#method_ajaxError)
5670
5739
  in other adapters as well.
5671
5740
 
5672
5741
  For Example, if you had an `User` model that looked like this:
@@ -5992,7 +6061,7 @@ define("ember-data/system/model/errors",
5992
6061
  }
5993
6062
  });
5994
6063
  });
5995
- define("ember-data/system/model/model",
6064
+ enifed("ember-data/system/model/model",
5996
6065
  ["ember-data/system/model/states","ember-data/system/model/errors","ember-data/system/promise_proxies","ember-data/system/relationships/relationship","exports"],
5997
6066
  function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
5998
6067
  "use strict";
@@ -6017,8 +6086,8 @@ define("ember-data/system/model/model",
6017
6086
  return get(get(this, 'currentState'), key);
6018
6087
  }).readOnly();
6019
6088
 
6020
- var _extractPivotNameCache = Object.create(null);
6021
- var _splitOnDotCache = Object.create(null);
6089
+ var _extractPivotNameCache = Ember.create(null);
6090
+ var _splitOnDotCache = Ember.create(null);
6022
6091
 
6023
6092
  function splitOnDot(name) {
6024
6093
  return _splitOnDotCache[name] || (
@@ -6463,7 +6532,7 @@ define("ember-data/system/model/model",
6463
6532
  would have a implicit post relationship in order to be do things like remove ourselves from the post
6464
6533
  when we are deleted
6465
6534
  */
6466
- this._implicitRelationships = Object.create(null);
6535
+ this._implicitRelationships = Ember.create(null);
6467
6536
  var model = this;
6468
6537
  //TODO Move into a getter for better perf
6469
6538
  this.constructor.eachRelationship(function(key, descriptor) {
@@ -6756,6 +6825,20 @@ define("ember-data/system/model/model",
6756
6825
  return value;
6757
6826
  },
6758
6827
 
6828
+ /**
6829
+ @method _notifyProperties
6830
+ @private
6831
+ */
6832
+ _notifyProperties: function(keys) {
6833
+ Ember.beginPropertyChanges();
6834
+ var key;
6835
+ for (var i = 0, length = keys.length; i < length; i++){
6836
+ key = keys[i];
6837
+ this.notifyPropertyChange(key);
6838
+ }
6839
+ Ember.endPropertyChanges();
6840
+ },
6841
+
6759
6842
  /**
6760
6843
  Returns an object, whose keys are changed properties, and value is
6761
6844
  an [oldProp, newProp] array.
@@ -6821,7 +6904,7 @@ define("ember-data/system/model/model",
6821
6904
 
6822
6905
  if (!data) { return; }
6823
6906
 
6824
- this.notifyPropertyChange('data');
6907
+ this._notifyProperties(Ember.keys(data));
6825
6908
  },
6826
6909
 
6827
6910
  /**
@@ -6854,15 +6937,16 @@ define("ember-data/system/model/model",
6854
6937
  the existing data, not replace it.
6855
6938
  */
6856
6939
  setupData: function(data, partial) {
6940
+
6857
6941
  if (partial) {
6858
6942
  Ember.merge(this._data, data);
6859
6943
  } else {
6860
6944
  this._data = data;
6861
6945
  }
6862
6946
 
6863
- if (data) { this.pushedData(); }
6947
+ this.pushedData();
6864
6948
 
6865
- this.notifyPropertyChange('data');
6949
+ this._notifyProperties(Ember.keys(data));
6866
6950
  },
6867
6951
 
6868
6952
  materializeId: function(id) {
@@ -6908,13 +6992,18 @@ define("ember-data/system/model/model",
6908
6992
  this.reconnectRelationships();
6909
6993
  }
6910
6994
 
6995
+ if (get(this, 'isNew')) {
6996
+ this.clearRelationships();
6997
+ }
6998
+
6911
6999
  if (!get(this, 'isValid')) {
6912
7000
  this._inFlightAttributes = {};
6913
7001
  }
6914
7002
 
6915
7003
  this.send('rolledBack');
6916
7004
 
6917
- this.notifyPropertyChange('data');
7005
+ this._notifyProperties(Ember.keys(this._data));
7006
+
6918
7007
  },
6919
7008
 
6920
7009
  toStringExtension: function() {
@@ -6965,7 +7054,9 @@ define("ember-data/system/model/model",
6965
7054
  App.ModelViewRoute = Ember.Route.extend({
6966
7055
  actions: {
6967
7056
  reload: function() {
6968
- this.controller.get('model').reload();
7057
+ this.controller.get('model').reload().then(function(model) {
7058
+ // do something with the reloaded model
7059
+ });
6969
7060
  }
6970
7061
  }
6971
7062
  });
@@ -7126,7 +7217,7 @@ define("ember-data/system/model/model",
7126
7217
 
7127
7218
  __exports__["default"] = Model;
7128
7219
  });
7129
- define("ember-data/system/model/states",
7220
+ enifed("ember-data/system/model/states",
7130
7221
  ["exports"],
7131
7222
  function(__exports__) {
7132
7223
  "use strict";
@@ -7847,7 +7938,7 @@ define("ember-data/system/model/states",
7847
7938
 
7848
7939
  __exports__["default"] = RootState;
7849
7940
  });
7850
- define("ember-data/system/promise_proxies",
7941
+ enifed("ember-data/system/promise_proxies",
7851
7942
  ["exports"],
7852
7943
  function(__exports__) {
7853
7944
  "use strict";
@@ -7933,13 +8024,38 @@ define("ember-data/system/promise_proxies",
7933
8024
  to the underlying manyArray.
7934
8025
  Right now we proxy:
7935
8026
  `reload()`
8027
+ `createRecord()`
8028
+ `on()`
8029
+ `one()`
8030
+ `trigger()`
8031
+ `off()`
8032
+ `has()`
7936
8033
  */
7937
8034
 
8035
+ function proxyToContent(method) {
8036
+ return function() {
8037
+ var content = get(this, 'content');
8038
+ return content[method].apply(content, arguments);
8039
+ };
8040
+ }
8041
+
7938
8042
  var PromiseManyArray = PromiseArray.extend({
7939
8043
  reload: function() {
7940
8044
  //I don't think this should ever happen right now, but worth guarding if we refactor the async relationships
7941
8045
  return get(this, 'content').reload();
7942
- }
8046
+ },
8047
+
8048
+ createRecord: proxyToContent('createRecord'),
8049
+
8050
+ on: proxyToContent('on'),
8051
+
8052
+ one: proxyToContent('one'),
8053
+
8054
+ trigger: proxyToContent('trigger'),
8055
+
8056
+ off: proxyToContent('off'),
8057
+
8058
+ has: proxyToContent('has')
7943
8059
  });
7944
8060
 
7945
8061
  var promiseManyArray = function(promise, label) {
@@ -7956,7 +8072,7 @@ define("ember-data/system/promise_proxies",
7956
8072
  __exports__.promiseObject = promiseObject;
7957
8073
  __exports__.promiseManyArray = promiseManyArray;
7958
8074
  });
7959
- define("ember-data/system/record_array_manager",
8075
+ enifed("ember-data/system/record_array_manager",
7960
8076
  ["ember-data/system/record_arrays","ember-data/system/map","exports"],
7961
8077
  function(__dependency1__, __dependency2__, __exports__) {
7962
8078
  "use strict";
@@ -7972,6 +8088,7 @@ define("ember-data/system/record_array_manager",
7972
8088
  var OrderedSet = __dependency2__.OrderedSet;
7973
8089
  var get = Ember.get;
7974
8090
  var forEach = Ember.EnumerableUtils.forEach;
8091
+ var indexOf = Ember.EnumerableUtils.indexOf;
7975
8092
 
7976
8093
  /**
7977
8094
  @class RecordArrayManager
@@ -8224,6 +8341,19 @@ define("ember-data/system/record_array_manager",
8224
8341
  this.updateFilter(array, type, filter);
8225
8342
  },
8226
8343
 
8344
+ /**
8345
+ Unregister a FilteredRecordArray.
8346
+ So manager will not update this array.
8347
+
8348
+ @method unregisterFilteredRecordArray
8349
+ @param {DS.RecordArray} array
8350
+ */
8351
+ unregisterFilteredRecordArray: function(array) {
8352
+ var recordArrays = this.filteredRecordArrays.get(array.type);
8353
+ var index = indexOf(recordArrays, array);
8354
+ recordArrays.splice(index, 1);
8355
+ },
8356
+
8227
8357
  // Internally, we maintain a map of all unloaded IDs requested by
8228
8358
  // a ManyArray. As the adapter loads data into the store, the
8229
8359
  // store notifies any interested ManyArrays. When the ManyArray's
@@ -8269,7 +8399,7 @@ define("ember-data/system/record_array_manager",
8269
8399
  return result;
8270
8400
  }
8271
8401
  });
8272
- define("ember-data/system/record_arrays",
8402
+ enifed("ember-data/system/record_arrays",
8273
8403
  ["ember-data/system/record_arrays/record_array","ember-data/system/record_arrays/filtered_record_array","ember-data/system/record_arrays/adapter_populated_record_array","ember-data/system/record_arrays/many_array","exports"],
8274
8404
  function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
8275
8405
  "use strict";
@@ -8287,7 +8417,7 @@ define("ember-data/system/record_arrays",
8287
8417
  __exports__.AdapterPopulatedRecordArray = AdapterPopulatedRecordArray;
8288
8418
  __exports__.ManyArray = ManyArray;
8289
8419
  });
8290
- define("ember-data/system/record_arrays/adapter_populated_record_array",
8420
+ enifed("ember-data/system/record_arrays/adapter_populated_record_array",
8291
8421
  ["ember-data/system/record_arrays/record_array","exports"],
8292
8422
  function(__dependency1__, __exports__) {
8293
8423
  "use strict";
@@ -8299,7 +8429,7 @@ define("ember-data/system/record_arrays/adapter_populated_record_array",
8299
8429
  var get = Ember.get;
8300
8430
 
8301
8431
  function cloneNull(source) {
8302
- var clone = Object.create(null);
8432
+ var clone = Ember.create(null);
8303
8433
  for (var key in source) {
8304
8434
  clone[key] = source[key];
8305
8435
  }
@@ -8350,7 +8480,7 @@ define("ember-data/system/record_arrays/adapter_populated_record_array",
8350
8480
  }
8351
8481
  });
8352
8482
  });
8353
- define("ember-data/system/record_arrays/filtered_record_array",
8483
+ enifed("ember-data/system/record_arrays/filtered_record_array",
8354
8484
  ["ember-data/system/record_arrays/record_array","exports"],
8355
8485
  function(__dependency1__, __exports__) {
8356
8486
  "use strict";
@@ -8418,10 +8548,23 @@ define("ember-data/system/record_arrays/filtered_record_array",
8418
8548
 
8419
8549
  updateFilter: Ember.observer(function() {
8420
8550
  Ember.run.once(this, this._updateFilter);
8421
- }, 'filterFunction')
8551
+ }, 'filterFunction'),
8552
+
8553
+ /**
8554
+ @method _unregisterFromManager
8555
+ @private
8556
+ */
8557
+ _unregisterFromManager: function(){
8558
+ this.manager.unregisterFilteredRecordArray(this);
8559
+ },
8560
+
8561
+ willDestroy: function(){
8562
+ this._unregisterFromManager();
8563
+ this._super();
8564
+ }
8422
8565
  });
8423
8566
  });
8424
- define("ember-data/system/record_arrays/many_array",
8567
+ enifed("ember-data/system/record_arrays/many_array",
8425
8568
  ["ember-data/system/record_arrays/record_array","exports"],
8426
8569
  function(__dependency1__, __exports__) {
8427
8570
  "use strict";
@@ -8482,17 +8625,19 @@ define("ember-data/system/record_arrays/many_array",
8482
8625
  */
8483
8626
  isPolymorphic: false,
8484
8627
 
8485
- // LOADING STATE
8628
+ /**
8629
+ The loading state of this array
8486
8630
 
8631
+ @property {Boolean} isLoaded
8632
+ */
8487
8633
  isLoaded: false,
8488
8634
 
8489
8635
  /**
8490
8636
  The relationship which manages this array.
8491
8637
 
8492
- @property {DS.Model} owner
8638
+ @property {ManyRelationship} relationship
8493
8639
  @private
8494
8640
  */
8495
-
8496
8641
  relationship: null,
8497
8642
 
8498
8643
 
@@ -8558,14 +8703,14 @@ define("ember-data/system/record_arrays/many_array",
8558
8703
  var record;
8559
8704
 
8560
8705
 
8561
- record = store.createRecord.call(store, type, hash);
8706
+ record = store.createRecord(type, hash);
8562
8707
  this.pushObject(record);
8563
8708
 
8564
8709
  return record;
8565
8710
  }
8566
8711
  });
8567
8712
  });
8568
- define("ember-data/system/record_arrays/record_array",
8713
+ enifed("ember-data/system/record_arrays/record_array",
8569
8714
  ["ember-data/system/promise_proxies","exports"],
8570
8715
  function(__dependency1__, __exports__) {
8571
8716
  "use strict";
@@ -8773,7 +8918,7 @@ define("ember-data/system/record_arrays/record_array",
8773
8918
  }
8774
8919
  });
8775
8920
  });
8776
- define("ember-data/system/relationship-meta",
8921
+ enifed("ember-data/system/relationship-meta",
8777
8922
  ["ember-inflector/system","exports"],
8778
8923
  function(__dependency1__, __exports__) {
8779
8924
  "use strict";
@@ -8808,7 +8953,7 @@ define("ember-data/system/relationship-meta",
8808
8953
 
8809
8954
  __exports__.relationshipFromMeta = relationshipFromMeta;
8810
8955
  });
8811
- define("ember-data/system/relationships",
8956
+ enifed("ember-data/system/relationships",
8812
8957
  ["./relationships/belongs_to","./relationships/has_many","ember-data/system/relationships/ext","exports"],
8813
8958
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
8814
8959
  "use strict";
@@ -8823,7 +8968,7 @@ define("ember-data/system/relationships",
8823
8968
  __exports__.belongsTo = belongsTo;
8824
8969
  __exports__.hasMany = hasMany;
8825
8970
  });
8826
- define("ember-data/system/relationships/belongs_to",
8971
+ enifed("ember-data/system/relationships/belongs_to",
8827
8972
  ["ember-data/system/model","exports"],
8828
8973
  function(__dependency1__, __exports__) {
8829
8974
  "use strict";
@@ -8929,7 +9074,7 @@ define("ember-data/system/relationships/belongs_to",
8929
9074
 
8930
9075
  __exports__["default"] = belongsTo;
8931
9076
  });
8932
- define("ember-data/system/relationships/ext",
9077
+ enifed("ember-data/system/relationships/ext",
8933
9078
  ["ember-data/system/relationship-meta","ember-data/system/model","ember-data/system/map"],
8934
9079
  function(__dependency1__, __dependency2__, __dependency3__) {
8935
9080
  "use strict";
@@ -9040,10 +9185,10 @@ define("ember-data/system/relationships/ext",
9040
9185
  },
9041
9186
 
9042
9187
  inverseMap: Ember.computed(function() {
9043
- return Object.create(null);
9188
+ return Ember.create(null);
9044
9189
  }),
9045
9190
 
9046
- /*
9191
+ /**
9047
9192
  Find the relationship which is the inverse of the one asked for.
9048
9193
 
9049
9194
  For example, if you define models like this:
@@ -9371,7 +9516,7 @@ define("ember-data/system/relationships/ext",
9371
9516
  });
9372
9517
 
9373
9518
  var fields = Ember.get(App.Blog, 'fields');
9374
- fields.forEach(function(field, kind) {
9519
+ fields.forEach(function(kind, field) {
9375
9520
  console.log(field, kind);
9376
9521
  });
9377
9522
 
@@ -9480,7 +9625,7 @@ define("ember-data/system/relationships/ext",
9480
9625
 
9481
9626
  });
9482
9627
  });
9483
- define("ember-data/system/relationships/has_many",
9628
+ enifed("ember-data/system/relationships/has_many",
9484
9629
  ["ember-data/system/model","exports"],
9485
9630
  function(__dependency1__, __exports__) {
9486
9631
  "use strict";
@@ -9615,7 +9760,7 @@ define("ember-data/system/relationships/has_many",
9615
9760
 
9616
9761
  __exports__["default"] = hasMany;
9617
9762
  });
9618
- define("ember-data/system/relationships/relationship",
9763
+ enifed("ember-data/system/relationships/relationship",
9619
9764
  ["ember-data/system/promise_proxies","ember-data/system/map","exports"],
9620
9765
  function(__dependency1__, __dependency2__, __exports__) {
9621
9766
  "use strict";
@@ -9629,7 +9774,6 @@ define("ember-data/system/relationships/relationship",
9629
9774
  this.key = relationshipMeta.key;
9630
9775
  this.inverseKey = inverseKey;
9631
9776
  this.record = record;
9632
- this.key = relationshipMeta.key;
9633
9777
  this.isAsync = relationshipMeta.options.async;
9634
9778
  this.relationshipMeta = relationshipMeta;
9635
9779
  //This probably breaks for polymorphic relationship in complex scenarios, due to
@@ -9663,20 +9807,24 @@ define("ember-data/system/relationships/relationship",
9663
9807
  },
9664
9808
 
9665
9809
  removeRecords: function(records){
9666
- var that = this;
9667
- records.forEach(function(record){
9668
- that.removeRecord(record);
9669
- });
9810
+ var length = Ember.get(records, 'length');
9811
+ var record;
9812
+ for (var i = 0; i < length; i++){
9813
+ record = records[i];
9814
+ this.removeRecord(record);
9815
+ }
9670
9816
  },
9671
9817
 
9672
9818
  addRecords: function(records, idx){
9673
- var that = this;
9674
- records.forEach(function(record){
9675
- that.addRecord(record, idx);
9819
+ var length = Ember.get(records, 'length');
9820
+ var record;
9821
+ for (var i = 0; i < length; i++){
9822
+ record = records[i];
9823
+ this.addRecord(record, idx);
9676
9824
  if (idx !== undefined) {
9677
9825
  idx++;
9678
9826
  }
9679
- });
9827
+ }
9680
9828
  },
9681
9829
 
9682
9830
  addRecord: function(record, idx) {
@@ -9729,7 +9877,7 @@ define("ember-data/system/relationships/relationship",
9729
9877
  },
9730
9878
 
9731
9879
  updateLink: function(link) {
9732
- if (link !== this.link) {
9880
+ if (link !== this.link) {
9733
9881
  this.link = link;
9734
9882
  this.linkPromise = null;
9735
9883
  this.record.notifyPropertyChange(this.key);
@@ -9766,7 +9914,7 @@ define("ember-data/system/relationships/relationship",
9766
9914
  this.manyArray.isPolymorphic = this.isPolymorphic;
9767
9915
  };
9768
9916
 
9769
- ManyRelationship.prototype = Object.create(Relationship.prototype);
9917
+ ManyRelationship.prototype = Ember.create(Relationship.prototype);
9770
9918
  ManyRelationship.prototype.constructor = ManyRelationship;
9771
9919
  ManyRelationship.prototype._super$constructor = Relationship;
9772
9920
 
@@ -9864,7 +10012,9 @@ define("ember-data/system/relationships/relationship",
9864
10012
  });
9865
10013
  } else {
9866
10014
 
9867
- this.manyArray.set('isLoaded', true);
10015
+ if (!this.manyArray.get('isDestroyed')) {
10016
+ this.manyArray.set('isLoaded', true);
10017
+ }
9868
10018
  return this.manyArray;
9869
10019
  }
9870
10020
  };
@@ -9876,7 +10026,7 @@ define("ember-data/system/relationships/relationship",
9876
10026
  this.inverseRecord = null;
9877
10027
  };
9878
10028
 
9879
- BelongsToRelationship.prototype = Object.create(Relationship.prototype);
10029
+ BelongsToRelationship.prototype = Ember.create(Relationship.prototype);
9880
10030
  BelongsToRelationship.prototype.constructor = BelongsToRelationship;
9881
10031
  BelongsToRelationship.prototype._super$constructor = Relationship;
9882
10032
 
@@ -9916,9 +10066,9 @@ define("ember-data/system/relationships/relationship",
9916
10066
 
9917
10067
  BelongsToRelationship.prototype._super$removeRecordFromOwn = Relationship.prototype.removeRecordFromOwn;
9918
10068
  BelongsToRelationship.prototype.removeRecordFromOwn = function(record) {
9919
- if (!this.members.has(record)){ return;}
9920
- this._super$removeRecordFromOwn(record);
10069
+ if (!this.members.has(record)) { return; }
9921
10070
  this.inverseRecord = null;
10071
+ this._super$removeRecordFromOwn(record);
9922
10072
  };
9923
10073
 
9924
10074
  BelongsToRelationship.prototype.findRecord = function() {
@@ -9932,7 +10082,9 @@ define("ember-data/system/relationships/relationship",
9932
10082
  BelongsToRelationship.prototype.fetchLink = function() {
9933
10083
  var self = this;
9934
10084
  return this.store.findBelongsTo(this.record, this.link, this.relationshipMeta).then(function(record){
9935
- self.addRecord(record);
10085
+ if (record) {
10086
+ self.addRecord(record);
10087
+ }
9936
10088
  return record;
9937
10089
  });
9938
10090
  };
@@ -9992,7 +10144,7 @@ define("ember-data/system/relationships/relationship",
9992
10144
  __exports__.BelongsToRelationship = BelongsToRelationship;
9993
10145
  __exports__.createRelationshipFor = createRelationshipFor;
9994
10146
  });
9995
- define("ember-data/system/store",
10147
+ enifed("ember-data/system/store",
9996
10148
  ["ember-data/system/adapter","ember-inflector/system/string","ember-data/system/map","ember-data/system/promise_proxies","exports"],
9997
10149
  function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
9998
10150
  "use strict";
@@ -10073,14 +10225,6 @@ define("ember-data/system/store",
10073
10225
  });
10074
10226
  ```
10075
10227
 
10076
- If your application has multiple `DS.Store` instances (an unusual case), you can
10077
- specify which store should be used:
10078
-
10079
- ```javascript
10080
- store.find('person', 123).then(function (person) {
10081
- });
10082
- ```
10083
-
10084
10228
  By default, the store will talk to your backend using a standard
10085
10229
  REST mechanism. You can customize how the store talks to your
10086
10230
  backend by specifying a custom adapter:
@@ -10420,6 +10564,25 @@ define("ember-data/system/store",
10420
10564
  return this.findById(type, coerceId(id), preload);
10421
10565
  },
10422
10566
 
10567
+ /**
10568
+ This method returns a fresh record for a given type and id combination.
10569
+
10570
+ If a record is available for the given type/id combination, then it will fetch this record from the store then reload it. If there's no record corresponding in the store it will simply call store.find.
10571
+
10572
+ @method fetch
10573
+ @param {String or subclass of DS.Model} type
10574
+ @param {Object|String|Integer|null} id
10575
+ @param {Object} preload - optional set of attributes and relationships passed in either as IDs or as actual models
10576
+ @return {Promise} promise
10577
+ */
10578
+ fetch: function(type, id, preload) {
10579
+ if (this.hasRecordForId(type, id)) {
10580
+ return this.getById(type, id).reload();
10581
+ } else {
10582
+ return this.find(type, id, preload);
10583
+ }
10584
+ },
10585
+
10423
10586
  /**
10424
10587
  This method returns a record for a given type and id combination.
10425
10588
 
@@ -10494,7 +10657,7 @@ define("ember-data/system/store",
10494
10657
  },
10495
10658
 
10496
10659
  scheduleFetchMany: function(records) {
10497
- return Ember.RSVP.all(map(records, this.scheduleFetch, this));
10660
+ return Promise.all(map(records, this.scheduleFetch, this));
10498
10661
  },
10499
10662
 
10500
10663
  scheduleFetch: function(record) {
@@ -10693,7 +10856,7 @@ define("ember-data/system/store",
10693
10856
  */
10694
10857
  findMany: function(records) {
10695
10858
  var store = this;
10696
- return Promise.all( map(records, function(record) {
10859
+ return Promise.all(map(records, function(record) {
10697
10860
  return store._findByRecord(record);
10698
10861
  }));
10699
10862
  },
@@ -10810,14 +10973,17 @@ define("ember-data/system/store",
10810
10973
  },
10811
10974
 
10812
10975
  /**
10813
- This method returns a filtered array that contains all of the known records
10814
- for a given type.
10976
+ This method returns a filtered array that contains all of the
10977
+ known records for a given type in the store.
10815
10978
 
10816
- Note that because it's just a filter, it will have any locally
10817
- created records of the type.
10979
+ Note that because it's just a filter, the result will contain any
10980
+ locally created records of the type, however, it will not make a
10981
+ request to the backend to retrieve additional records. If you
10982
+ would like to request all the records from the backend please use
10983
+ [store.find](#method_find).
10818
10984
 
10819
10985
  Also note that multiple calls to `all` for a given type will always
10820
- return the same RecordArray.
10986
+ return the same `RecordArray`.
10821
10987
 
10822
10988
  Example
10823
10989
 
@@ -10873,10 +11039,18 @@ define("ember-data/system/store",
10873
11039
  remains up to date as new records are loaded into the store or created
10874
11040
  locally.
10875
11041
 
10876
- The callback function takes a materialized record, and returns true
11042
+ The filter function takes a materialized record, and returns true
10877
11043
  if the record should be included in the filter and false if it should
10878
11044
  not.
10879
11045
 
11046
+ Example
11047
+
11048
+ ```javascript
11049
+ store.filter('post', function(post) {
11050
+ return post.get('unread');
11051
+ });
11052
+ ```
11053
+
10880
11054
  The filter function is called once on all records for the type when
10881
11055
  it is created, and then once on each newly loaded or created record.
10882
11056
 
@@ -10884,14 +11058,19 @@ define("ember-data/system/store",
10884
11058
  filter function will be invoked again to determine whether it should
10885
11059
  still be in the array.
10886
11060
 
10887
- Optionally you can pass a query which will be triggered at first. The
10888
- results returned by the server could then appear in the filter if they
10889
- match the filter function.
11061
+ Optionally you can pass a query, which is the equivalent of calling
11062
+ [find](#method_find) with that same query, to fetch additional records
11063
+ from the server. The results returned by the server could then appear
11064
+ in the filter if they match the filter function.
11065
+
11066
+ The query itself is not used to filter records, it's only sent to your
11067
+ server for you to be able to do server-side filtering. The filter
11068
+ function will be applied on the returned results regardless.
10890
11069
 
10891
11070
  Example
10892
11071
 
10893
11072
  ```javascript
10894
- store.filter('post', {unread: true}, function(post) {
11073
+ store.filter('post', { unread: true }, function(post) {
10895
11074
  return post.get('unread');
10896
11075
  }).then(function(unreadPosts) {
10897
11076
  unreadPosts.get('length'); // 5
@@ -11134,9 +11313,9 @@ define("ember-data/system/store",
11134
11313
  if (typeMap) { return typeMap; }
11135
11314
 
11136
11315
  typeMap = {
11137
- idToRecord: Object.create(null),
11316
+ idToRecord: Ember.create(null),
11138
11317
  records: [],
11139
- metadata: Object.create(null),
11318
+ metadata: Ember.create(null),
11140
11319
  type: type
11141
11320
  };
11142
11321
 
@@ -11270,6 +11449,7 @@ define("ember-data/system/store",
11270
11449
  // merged into the existing data, not replace it.
11271
11450
 
11272
11451
  var type = this.modelFor(typeName);
11452
+ var filter = Ember.EnumerableUtils.filter;
11273
11453
 
11274
11454
  // If the payload contains relationships that are specified as
11275
11455
  // IDs, normalizeRelationships will convert them into DS.Model instances
@@ -11278,6 +11458,7 @@ define("ember-data/system/store",
11278
11458
 
11279
11459
  data = normalizeRelationships(this, type, data);
11280
11460
 
11461
+
11281
11462
  // Actually load the record into the store.
11282
11463
 
11283
11464
  this._load(type, data, _partial);
@@ -11407,7 +11588,6 @@ define("ember-data/system/store",
11407
11588
  @return {DS.Model} the record that was updated.
11408
11589
  */
11409
11590
  update: function(type, data) {
11410
-
11411
11591
  return this.push(type, data, true);
11412
11592
  },
11413
11593
 
@@ -11612,7 +11792,7 @@ define("ember-data/system/store",
11612
11792
  if (isNone(id) || id instanceof Model) {
11613
11793
  return;
11614
11794
  }
11615
-
11795
+
11616
11796
  var type;
11617
11797
 
11618
11798
  if (typeof id === 'number' || typeof id === 'string') {
@@ -11633,10 +11813,11 @@ define("ember-data/system/store",
11633
11813
  }
11634
11814
 
11635
11815
  function deserializeRecordIds(store, data, key, relationship, ids) {
11636
- if (!Ember.isArray(ids)) {
11816
+ if (isNone(ids)) {
11637
11817
  return;
11638
11818
  }
11639
- for (var i=0, l=ids.length; i<l; i++) {
11819
+
11820
+ for (var i=0, l=ids.length; i<l; i++) {
11640
11821
  deserializeRecordId(store, ids, i, relationship, ids[i]);
11641
11822
  }
11642
11823
  }
@@ -11767,6 +11948,11 @@ define("ember-data/system/store",
11767
11948
 
11768
11949
  return promise.then(function(adapterPayload) {
11769
11950
  var payload = serializer.extract(store, relationship.type, adapterPayload, null, 'findBelongsTo');
11951
+
11952
+ if (!payload) {
11953
+ return null;
11954
+ }
11955
+
11770
11956
  var record = store.push(relationship.type, payload);
11771
11957
  return record;
11772
11958
  }, null, "DS: Extract payload of " + record + " : " + relationship.type);
@@ -11831,7 +12017,9 @@ define("ember-data/system/store",
11831
12017
  return record;
11832
12018
  }, function(reason) {
11833
12019
  if (reason instanceof InvalidError) {
11834
- store.recordWasInvalid(record, reason.errors);
12020
+ var errors = serializer.extractErrors(store, type, reason.errors, get(record, 'id'));
12021
+ store.recordWasInvalid(record, errors);
12022
+ reason = new InvalidError(errors);
11835
12023
  } else {
11836
12024
  store.recordWasError(record, reason);
11837
12025
  }
@@ -11866,7 +12054,7 @@ define("ember-data/system/store",
11866
12054
  __exports__.Store = Store;
11867
12055
  __exports__["default"] = Store;
11868
12056
  });
11869
- define("ember-data/transforms",
12057
+ enifed("ember-data/transforms",
11870
12058
  ["ember-data/transforms/base","ember-data/transforms/number","ember-data/transforms/date","ember-data/transforms/string","ember-data/transforms/boolean","exports"],
11871
12059
  function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
11872
12060
  "use strict";
@@ -11882,7 +12070,7 @@ define("ember-data/transforms",
11882
12070
  __exports__.StringTransform = StringTransform;
11883
12071
  __exports__.BooleanTransform = BooleanTransform;
11884
12072
  });
11885
- define("ember-data/transforms/base",
12073
+ enifed("ember-data/transforms/base",
11886
12074
  ["exports"],
11887
12075
  function(__exports__) {
11888
12076
  "use strict";
@@ -11958,7 +12146,7 @@ define("ember-data/transforms/base",
11958
12146
  deserialize: Ember.required()
11959
12147
  });
11960
12148
  });
11961
- define("ember-data/transforms/boolean",
12149
+ enifed("ember-data/transforms/boolean",
11962
12150
  ["ember-data/transforms/base","exports"],
11963
12151
  function(__dependency1__, __exports__) {
11964
12152
  "use strict";
@@ -12005,7 +12193,7 @@ define("ember-data/transforms/boolean",
12005
12193
  }
12006
12194
  });
12007
12195
  });
12008
- define("ember-data/transforms/date",
12196
+ enifed("ember-data/transforms/date",
12009
12197
  ["ember-data/transforms/base","exports"],
12010
12198
  function(__dependency1__, __exports__) {
12011
12199
  "use strict";
@@ -12057,7 +12245,6 @@ define("ember-data/transforms/date",
12057
12245
  }
12058
12246
 
12059
12247
  __exports__["default"] = Transform.extend({
12060
-
12061
12248
  deserialize: function(serialized) {
12062
12249
  var type = typeof serialized;
12063
12250
 
@@ -12083,7 +12270,7 @@ define("ember-data/transforms/date",
12083
12270
  }
12084
12271
  });
12085
12272
  });
12086
- define("ember-data/transforms/number",
12273
+ enifed("ember-data/transforms/number",
12087
12274
  ["ember-data/transforms/base","exports"],
12088
12275
  function(__dependency1__, __exports__) {
12089
12276
  "use strict";
@@ -12122,7 +12309,7 @@ define("ember-data/transforms/number",
12122
12309
  }
12123
12310
  });
12124
12311
  });
12125
- define("ember-data/transforms/string",
12312
+ enifed("ember-data/transforms/string",
12126
12313
  ["ember-data/transforms/base","exports"],
12127
12314
  function(__dependency1__, __exports__) {
12128
12315
  "use strict";
@@ -12159,7 +12346,7 @@ define("ember-data/transforms/string",
12159
12346
  }
12160
12347
  });
12161
12348
  });
12162
- define("ember-inflector",
12349
+ enifed("ember-inflector",
12163
12350
  ["./system","./helpers","./ext/string","exports"],
12164
12351
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
12165
12352
  "use strict";
@@ -12180,7 +12367,7 @@ define("ember-inflector",
12180
12367
  __exports__.pluralize = pluralize;
12181
12368
  __exports__.singularize = singularize;
12182
12369
  });
12183
- define("ember-inflector/ext/string",
12370
+ enifed("ember-inflector/ext/string",
12184
12371
  ["../system/string"],
12185
12372
  function(__dependency1__) {
12186
12373
  "use strict";
@@ -12209,7 +12396,7 @@ define("ember-inflector/ext/string",
12209
12396
  };
12210
12397
  }
12211
12398
  });
12212
- define("ember-inflector/helpers",
12399
+ enifed("ember-inflector/helpers",
12213
12400
  ["./system/string"],
12214
12401
  function(__dependency1__) {
12215
12402
  "use strict";
@@ -12248,7 +12435,7 @@ define("ember-inflector/helpers",
12248
12435
  */
12249
12436
  Ember.Handlebars.helper('pluralize', pluralize);
12250
12437
  });
12251
- define("ember-inflector/system",
12438
+ enifed("ember-inflector/system",
12252
12439
  ["./system/inflector","./system/string","./system/inflections","exports"],
12253
12440
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
12254
12441
  "use strict";
@@ -12267,7 +12454,7 @@ define("ember-inflector/system",
12267
12454
  __exports__.pluralize = pluralize;
12268
12455
  __exports__.defaultRules = defaultRules;
12269
12456
  });
12270
- define("ember-inflector/system/inflections",
12457
+ enifed("ember-inflector/system/inflections",
12271
12458
  ["exports"],
12272
12459
  function(__exports__) {
12273
12460
  "use strict";
@@ -12350,7 +12537,7 @@ define("ember-inflector/system/inflections",
12350
12537
  ]
12351
12538
  };
12352
12539
  });
12353
- define("ember-inflector/system/inflector",
12540
+ enifed("ember-inflector/system/inflector",
12354
12541
  ["exports"],
12355
12542
  function(__exports__) {
12356
12543
  "use strict";
@@ -12651,7 +12838,7 @@ define("ember-inflector/system/inflector",
12651
12838
 
12652
12839
  __exports__["default"] = Inflector;
12653
12840
  });
12654
- define("ember-inflector/system/string",
12841
+ enifed("ember-inflector/system/string",
12655
12842
  ["./inflector","exports"],
12656
12843
  function(__dependency1__, __exports__) {
12657
12844
  "use strict";