ember-data-source 1.0.0.beta.5 → 1.0.0.beta.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,8 @@
3
3
  * @copyright Copyright 2011-2014 Tilde Inc. and contributors.
4
4
  * Portions Copyright 2011 LivingSocial Inc.
5
5
  * @license Licensed under MIT license (see license.js)
6
- * @version 1.0.0-beta.5
6
+ * @version 1.0.0-beta.6
7
7
  */
8
- !function(){var e,t;!function(){var r={},n={};e=function(e,t,n){r[e]={deps:t,callback:n}},t=function(e){if(n[e])return n[e];n[e]={};var i,a,o,s,c;if(i=r[e],!i)throw new Error("Module '"+e+"' not found.");a=i.deps,o=i.callback,s=[];for(var d=0,u=a.length;u>d;d++)"exports"===a[d]?s.push(c={}):s.push(t(a[d]));var l=o.apply(this,s);return n[e]=c||l}}(),function(){var e;"undefined"==typeof e&&(e=Ember.Namespace.create({VERSION:"1.0.0-beta.5"}),"undefined"!=typeof window&&(window.DS=e),Ember.libraries&&Ember.libraries.registerCoreLibrary("Ember Data",e.VERSION))}(),function(){function e(e){return function(){return this[e].apply(this,arguments)}}var t=Ember.get,r=(Ember.set,Ember.isNone);DS.JSONSerializer=Ember.Object.extend({primaryKey:"id",applyTransforms:function(e,t){return e.eachTransformedAttribute(function(e,r){var n=this.transformFor(r);t[e]=n.deserialize(t[e])},this),t},normalize:function(e,t){return t?(this.applyTransforms(e,t),t):t},serialize:function(e,r){var n={};if(r&&r.includeId){var i=t(e,"id");i&&(n[t(this,"primaryKey")]=i)}return e.eachAttribute(function(t,r){this.serializeAttribute(e,n,t,r)},this),e.eachRelationship(function(t,r){"belongsTo"===r.kind?this.serializeBelongsTo(e,n,r):"hasMany"===r.kind&&this.serializeHasMany(e,n,r)},this),n},serializeAttribute:function(e,r,n,i){var a=t(this,"attrs"),o=t(e,n),s=i.type;if(s){var c=this.transformFor(s);o=c.serialize(o)}n=a&&a[n]||(this.keyForAttribute?this.keyForAttribute(n):n),r[n]=o},serializeBelongsTo:function(e,n,i){var a=i.key,o=t(e,a);a=this.keyForRelationship?this.keyForRelationship(a,"belongsTo"):a,n[a]=r(o)?o:t(o,"id"),i.options.polymorphic&&this.serializePolymorphicType(e,n,i)},serializeHasMany:function(e,r,n){var i=n.key,a=DS.RelationshipChange.determineRelationshipType(e.constructor,n);("manyToNone"===a||"manyToMany"===a)&&(r[i]=t(e,i).mapBy("id"))},serializePolymorphicType:Ember.K,extract:function(e,t,r,n,i){this.extractMeta(e,t,r);var a="extract"+i.charAt(0).toUpperCase()+i.substr(1);return this[a](e,t,r,n,i)},extractFindAll:e("extractArray"),extractFindQuery:e("extractArray"),extractFindMany:e("extractArray"),extractFindHasMany:e("extractArray"),extractCreateRecord:e("extractSave"),extractUpdateRecord:e("extractSave"),extractDeleteRecord:e("extractSave"),extractFind:e("extractSingle"),extractFindBelongsTo:e("extractSingle"),extractSave:e("extractSingle"),extractSingle:function(e,t,r){return this.normalize(t,r)},extractArray:function(e,t,r){return this.normalize(t,r)},extractMeta:function(e,t,r){r&&r.meta&&(e.metaForType(t,r.meta),delete r.meta)},transformFor:function(e){var t=this.container.lookup("transform:"+e);return t}})}(),function(){var e=Ember.get,t=Ember.String.capitalize,r=Ember.String.underscore,n=window.DS;n.DebugAdapter=Ember.DataAdapter.extend({getFilters:function(){return[{name:"isNew",desc:"New"},{name:"isModified",desc:"Modified"},{name:"isClean",desc:"Clean"}]},detect:function(e){return e!==n.Model&&n.Model.detect(e)},columnsForType:function(n){var i=[{name:"id",desc:"Id"}],a=0,o=this;return e(n,"attributes").forEach(function(e){if(a++>o.attributeLimit)return!1;var n=t(r(e).replace("_"," "));i.push({name:e,desc:n})}),i},getRecords:function(e){return this.get("store").all(e)},getRecordColumnValues:function(t){var r=this,n=0,i={id:e(t,"id")};return t.eachAttribute(function(a){if(n++>r.attributeLimit)return!1;var o=e(t,a);i[a]=o}),i},getRecordKeywords:function(t){var r=[],n=Ember.A(["id"]);return t.eachAttribute(function(e){n.push(e)}),n.forEach(function(n){r.push(e(t,n))}),r},getRecordFilterValues:function(e){return{isNew:e.get("isNew"),isModified:e.get("isDirty")&&!e.get("isNew"),isClean:!e.get("isDirty")}},getRecordColor:function(e){var t="black";return e.get("isNew")?t="green":e.get("isDirty")&&(t="blue"),t},observeRecord:function(e,t){var r=Ember.A(),n=this,i=Ember.A(["id","isNew","isDirty"]);e.eachAttribute(function(e){i.push(e)}),i.forEach(function(i){var a=function(){t(n.wrapRecord(e))};Ember.addObserver(e,i,a),r.push(function(){Ember.removeObserver(e,i,a)})});var a=function(){r.forEach(function(e){e()})};return a}})}(),function(){DS.Transform=Ember.Object.extend({serialize:Ember.required(),deserialize:Ember.required()})}(),function(){DS.BooleanTransform=DS.Transform.extend({deserialize:function(e){var t=typeof e;return"boolean"===t?e:"string"===t?null!==e.match(/^true$|^t$|^1$/i):"number"===t?1===e:!1},serialize:function(e){return Boolean(e)}})}(),function(){DS.DateTransform=DS.Transform.extend({deserialize:function(e){var t=typeof e;return"string"===t?new Date(Ember.Date.parse(e)):"number"===t?new Date(e):null===e||void 0===e?e:null},serialize:function(e){if(e instanceof Date){var t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=function(e){return 10>e?"0"+e:""+e},i=e.getUTCFullYear(),a=e.getUTCMonth(),o=e.getUTCDate(),s=e.getUTCDay(),c=e.getUTCHours(),d=e.getUTCMinutes(),u=e.getUTCSeconds(),l=t[s],h=n(o),f=r[a];return l+", "+h+" "+f+" "+i+" "+n(c)+":"+n(d)+":"+n(u)+" GMT"}return null}})}(),function(){var e=Ember.isEmpty;DS.NumberTransform=DS.Transform.extend({deserialize:function(t){return e(t)?null:Number(t)},serialize:function(t){return e(t)?null:Number(t)}})}(),function(){var e=Ember.isNone;DS.StringTransform=DS.Transform.extend({deserialize:function(t){return e(t)?null:String(t)},serialize:function(t){return e(t)?null:String(t)}})}(),function(){Ember.set;Ember.onLoad("Ember.Application",function(e){e.initializer({name:"store",initialize:function(e,t){t.register("store:main",t.Store||DS.Store),t.register("serializer:_default",DS.JSONSerializer),t.register("serializer:_rest",DS.RESTSerializer),t.register("adapter:_rest",DS.RESTAdapter),e.lookup("store:main")}}),e.initializer({name:"transforms",before:"store",initialize:function(e,t){t.register("transform:boolean",DS.BooleanTransform),t.register("transform:date",DS.DateTransform),t.register("transform:number",DS.NumberTransform),t.register("transform:string",DS.StringTransform)}}),e.initializer({name:"dataAdapter",before:"store",initialize:function(e,t){t.register("dataAdapter:main",DS.DebugAdapter)}}),e.initializer({name:"injectStore",before:"store",initialize:function(e,t){t.inject("controller","store","store:main"),t.inject("route","store","store:main"),t.inject("serializer","store","store:main"),t.inject("dataAdapter","store","store:main")}})})}(),function(){Ember.Date=Ember.Date||{};var e=Date.parse,t=[1,4,5,6,7,10,11];Ember.Date.parse=function(r){var n,i,a=0;if(i=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(r)){for(var o,s=0;o=t[s];++s)i[o]=+i[o]||0;i[2]=(+i[2]||1)-1,i[3]=+i[3]||1,"Z"!==i[8]&&void 0!==i[9]&&(a=60*i[10]+i[11],"+"===i[9]&&(a=0-a)),n=Date.UTC(i[1],i[2],i[3],i[4],i[5]+a,i[6],i[7])}else n=e?e(r):0/0;return n},(Ember.EXTEND_PROTOTYPES===!0||Ember.EXTEND_PROTOTYPES.Date)&&(Date.parse=Ember.Date.parse)}(),function(){{var e=Ember.get;Ember.set}DS.RecordArray=Ember.ArrayProxy.extend(Ember.Evented,{type:null,content:null,isLoaded:!1,isUpdating:!1,store:null,objectAtContent:function(t){var r=e(this,"content");return r.objectAt(t)},update:function(){if(!e(this,"isUpdating")){var t=e(this,"store"),r=e(this,"type");t.fetchAll(r,this)}},addRecord:function(t){e(this,"content").addObject(t)},removeRecord:function(t){e(this,"content").removeObject(t)},save:function(){var t="DS: RecordArray#save "+e(this,"type"),r=Ember.RSVP.all(this.invoke("save"),t).then(function(e){return Ember.A(e)},null,"DS: RecordArray#save apply Ember.NativeArray");return DS.PromiseArray.create({promise:r})}})}(),function(){var e=Ember.get;DS.FilteredRecordArray=DS.RecordArray.extend({filterFunction:null,isLoaded:!0,replace:function(){var t=e(this,"type").toString();throw new Error("The result of a client-side filter (on "+t+") is immutable.")},updateFilter:Ember.observer(function(){var t=e(this,"manager");t.updateFilter(this,e(this,"type"),e(this,"filterFunction"))},"filterFunction")})}(),function(){{var e=Ember.get;Ember.set}DS.AdapterPopulatedRecordArray=DS.RecordArray.extend({query:null,replace:function(){var t=e(this,"type").toString();throw new Error("The result of a server query (on "+t+") is immutable.")},load:function(t){var r=e(this,"store"),n=e(this,"type"),i=r.pushMany(n,t),a=r.metadataFor(n);this.setProperties({content:Ember.A(i),isLoaded:!0,meta:a}),Ember.run.once(this,"trigger","didLoad")}})}(),function(){var e=Ember.get,t=Ember.set,r=Ember.EnumerableUtils.map;DS.ManyArray=DS.RecordArray.extend({init:function(){this._super.apply(this,arguments),this._changesToSync=Ember.OrderedSet.create()},name:null,owner:null,isPolymorphic:!1,isLoaded:!1,promise:null,loadingRecordsCount:function(e){this.loadingRecordsCount=e},loadedRecord:function(){this.loadingRecordsCount--,0===this.loadingRecordsCount&&(t(this,"isLoaded",!0),this.trigger("didLoad"))},fetch:function(){var t=e(this,"content"),r=e(this,"store"),n=e(this,"owner"),i=Ember.RSVP.defer("DS: ManyArray#fetch "+e(this,"type")),a=t.filterProperty("isEmpty",!0);r.fetchMany(a,n,i)},replaceContent:function(e,t,n){n=r(n,function(e){return e},this),this._super(e,t,n)},arrangedContentDidChange:function(){Ember.run.once(this,"fetch")},arrayContentWillChange:function(t,r){var n=e(this,"owner"),i=e(this,"name");if(!n._suspendedRelationships)for(var a=t;t+r>a;a++){var o=e(this,"content").objectAt(a),s=DS.RelationshipChange.createChange(n,o,e(this,"store"),{parentType:n.constructor,changeType:"remove",kind:"hasMany",key:i});this._changesToSync.add(s)}return this._super.apply(this,arguments)},arrayContentDidChange:function(t,r,n){this._super.apply(this,arguments);var i=e(this,"owner"),a=e(this,"name"),o=e(this,"store");if(!i._suspendedRelationships){for(var s=t;t+n>s;s++){var c=e(this,"content").objectAt(s),d=DS.RelationshipChange.createChange(i,c,o,{parentType:i.constructor,changeType:"add",kind:"hasMany",key:a});d.hasManyName=a,this._changesToSync.add(d)}this._changesToSync.forEach(function(e){e.sync()}),this._changesToSync.clear()}},createRecord:function(t){var r,n=e(this,"owner"),i=e(n,"store"),a=e(this,"type");return r=i.createRecord.call(i,a,t),this.pushObject(r),r}})}(),function(){function e(e,r,a,o){return r.eachRelationship(function(r,s){if(a.links&&a.links[r])return o&&s.options.async&&(o._relationships[r]=null),void 0;var c=s.kind,d=a[r];null!=d&&("belongsTo"===c?t(e,a,r,s,d):"hasMany"===c&&(n(e,a,r,s,d),i(o,r,d)))}),a}function t(e,t,n,i,a){if(!(R(a)||a instanceof DS.Model)){var o;"number"==typeof a||"string"==typeof a?(o=r(i,n,t),t[n]=e.recordForId(o,a)):"object"==typeof a&&(t[n]=e.recordForId(a.type,a.id))}}function r(e,t,r){return e.options.polymorphic?r[t+"Type"]:e.type}function n(e,r,n,i,a){for(var o=0,s=a.length;s>o;o++)t(e,a,o,i,a[o])}function i(e,t,r){e&&r.pushObjects(e.get(t).filterBy("isNew"))}function a(e){return DS.PromiseObject.create({promise:e})}function o(e){return DS.PromiseArray.create({promise:e})}function s(e,t,r){return e.lookup("serializer:"+t)||e.lookup("serializer:application")||e.lookup("serializer:"+r)||e.lookup("serializer:_default")}function c(e){return e.lookup("serializer:application")||e.lookup("serializer:_default")}function d(e,t){var r=e.serializer,n=e.defaultSerializer,i=e.container;return i&&void 0===r&&(r=s(i,t.typeKey,n)),(null===r||void 0===r)&&(r={extract:function(e,t,r){return r}}),r}function u(e,t,r,n){var i=e.find(t,r,n),a=d(e,r);return T(i,"DS: Handle Adapter#find of "+r+" with id: "+n).then(function(e){return e=a.extract(t,r,e,n,"find"),t.push(r,e)},function(e){var i=t.getById(r,n);throw i.notFound(),e},"DS: Extract payload of '"+r+"'")}function l(e,t,r,n,i){var a=e.findMany(t,r,n,i),o=d(e,r);return T(a,"DS: Handle Adapter#findMany of "+r).then(function(e){e=o.extract(t,r,e,null,"findMany"),t.pushMany(r,e)},null,"DS: Extract payload of "+r)}function h(e,t,r,n,i){var a=e.findHasMany(t,r,n,i),o=d(e,i.type);return T(a,"DS: Handle Adapter#findHasMany of "+r+" : "+i.type).then(function(e){e=o.extract(t,i.type,e,null,"findHasMany");var n=t.pushMany(i.type,e);r.updateHasMany(i.key,n)},null,"DS: Extract payload of "+r+" : hasMany "+i.type)}function f(e,t,r,n,i){var a=e.findBelongsTo(t,r,n,i),o=d(e,i.type);return T(a,"DS: Handle Adapter#findBelongsTo of "+r+" : "+i.type).then(function(e){e=o.extract(t,i.type,e,null,"findBelongsTo");var r=t.push(i.type,e);return r.updateBelongsTo(i.key,r),r},null,"DS: Extract payload of "+r+" : "+i.type)}function p(e,t,r,n){var i=e.findAll(t,r,n),a=d(e,r);return T(i,"DS: Handle Adapter#findAll of "+r).then(function(e){return e=a.extract(t,r,e,null,"findAll"),t.pushMany(r,e),t.didUpdateAll(r),t.all(r)},null,"DS: Extract payload of findAll "+r)}function m(e,t,r,n,i){var a=e.findQuery(t,r,n,i),o=d(e,r);return T(a,"DS: Handle Adapter#findQuery of "+r).then(function(e){return e=o.extract(t,r,e,null,"findQuery"),i.load(e),i},null,"DS: Extract payload of findQuery "+r)}function y(e,t,r,n){var i=n.constructor,a=e[r](t,i,n),o=d(e,i);return a.then(function(e){return e&&(e=o.extract(t,i,e,g(n,"id"),r)),t.didSaveRecord(n,e),n},function(e){throw e instanceof DS.InvalidError?t.recordWasInvalid(n,e.errors):t.recordWasError(n,e),e},"DS: Extract and notify about "+r+" completion of "+n)}var g=Ember.get,b=Ember.set,v=Ember.run.once,R=Ember.isNone,E=Ember.EnumerableUtils.forEach,S=Ember.EnumerableUtils.indexOf,D=Ember.EnumerableUtils.map,T=Ember.RSVP.resolve,A=Ember.copy,F=function(e){return null==e?null:e+""};DS.Store=Ember.Object.extend({init:function(){this.typeMaps={},this.recordArrayManager=DS.RecordArrayManager.create({store:this}),this._relationshipChanges={},this._pendingSave=[]},adapter:"_rest",serialize:function(e,t){return this.serializerFor(e.constructor.typeKey).serialize(e,t)},defaultAdapter:Ember.computed("adapter",function(){var e=g(this,"adapter");return"string"==typeof e&&(e=this.container.lookup("adapter:"+e)||this.container.lookup("adapter:application")||this.container.lookup("adapter:_rest")),DS.Adapter.detect(e)&&(e=e.create({container:this.container})),e}),createRecord:function(e,t){e=this.modelFor(e),t=A(t)||{},R(t.id)&&(t.id=this._generateId(e)),t.id=F(t.id);var r=this.buildRecord(e,t.id);return r.loadedData(),r.setProperties(t),r},_generateId:function(e){var t=this.adapterFor(e);return t&&t.generateIdForRecord?t.generateIdForRecord(this):null},deleteRecord:function(e){e.deleteRecord()},unloadRecord:function(e){e.unloadRecord()},find:function(e,t){return void 0===t?this.findAll(e):"object"===Ember.typeOf(t)?this.findQuery(e,t):this.findById(e,F(t))},findById:function(e,t){e=this.modelFor(e);var r=this.recordForId(e,t),n=this.fetchRecord(r)||T(r,"DS: Store#findById "+e+" with id: "+t);return a(n)},findByIds:function(e,t){var r=this;return o(Ember.RSVP.all(D(t,function(t){return r.findById(e,t)})).then(Ember.A,null,"DS: Store#findByIds of "+e+" complete"))},fetchRecord:function(e){if(R(e))return null;if(e._loadingPromise)return e._loadingPromise;if(!g(e,"isEmpty"))return null;var t=e.constructor,r=g(e,"id"),n=this.adapterFor(t),i=u(n,this,t,r);return e.loadingData(i),i},getById:function(e,t){return this.hasRecordForId(e,t)?this.recordForId(e,t):null},reloadRecord:function(e){var t=e.constructor,r=this.adapterFor(t),n=g(e,"id");return u(r,this,t,n)},fetchMany:function(e,t,r){if(e.length){var n=Ember.MapWithDefault.create({defaultValue:function(){return Ember.A()}});E(e,function(e){n.get(e.constructor).push(e)}),E(n,function(e,n){var i=n.mapProperty("id"),a=this.adapterFor(e);r.resolve(l(a,this,e,i,t))},this)}},hasRecordForId:function(e,t){return t=F(t),e=this.modelFor(e),!!this.typeMapFor(e).idToRecord[t]},recordForId:function(e,t){e=this.modelFor(e),t=F(t);var r=this.typeMapFor(e).idToRecord[t];return r||(r=this.buildRecord(e,t)),r},findMany:function(e,t,r,n){r=this.modelFor(r),t=Ember.A(t);var i=t.filterProperty("isEmpty",!0),a=this.recordArrayManager.createManyArray(r,t);return E(i,function(e){e.loadingData()}),a.loadingRecordsCount=i.length,i.length?(E(i,function(e){this.recordArrayManager.registerWaitingRecordArray(e,a)},this),this.fetchMany(i,e,n)):(n&&n.resolve(),a.set("isLoaded",!0),Ember.run.once(a,"trigger","didLoad")),a},findHasMany:function(e,t,r,n){var i=this.adapterFor(e.constructor),a=this.recordArrayManager.createManyArray(r.type,Ember.A([]));return n.resolve(h(i,this,e,t,r)),a},findBelongsTo:function(e,t,r,n){var i=this.adapterFor(e.constructor);n.resolve(f(i,this,e,t,r))},findQuery:function(e,t){e=this.modelFor(e);var r=this.recordArrayManager.createAdapterPopulatedRecordArray(e,t),n=this.adapterFor(e),i="DS: Store#findQuery "+e,a=Ember.RSVP.defer(i);return a.resolve(m(n,this,e,t,r)),o(a.promise)},findAll:function(e){return e=this.modelFor(e),this.fetchAll(e,this.all(e))},fetchAll:function(e,t){var r=this.adapterFor(e),n=this.typeMapFor(e).metadata.since;return b(t,"isUpdating",!0),o(p(r,this,e,n))},didUpdateAll:function(e){var t=this.typeMapFor(e).findAllCache;b(t,"isUpdating",!1)},all:function(e){e=this.modelFor(e);var t=this.typeMapFor(e),r=t.findAllCache;if(r)return r;var n=this.recordArrayManager.createRecordArray(e);return t.findAllCache=n,n},unloadAll:function(e){e=this.modelFor(e);for(var t,r=this.typeMapFor(e),n=r.records;t=n.pop();)t.unloadRecord();r.findAllCache=null},filter:function(e,t,r){var n;3===arguments.length?n=this.findQuery(e,t):2===arguments.length&&(r=t),e=this.modelFor(e);var i=this.recordArrayManager.createFilteredRecordArray(e,r);return n=n||T(i),o(n.then(function(){return i},null,"DS: Store#filter of "+e))},recordIsLoaded:function(e,t){return this.hasRecordForId(e,t)?!g(this.recordForId(e,t),"isEmpty"):!1},metadataFor:function(e){return e=this.modelFor(e),this.typeMapFor(e).metadata},dataWasUpdated:function(e,t){this.recordArrayManager.recordDidChange(t)},scheduleSave:function(e,t){e.adapterWillCommit(),this._pendingSave.push([e,t]),v(this,"flushPendingSave")},flushPendingSave:function(){var e=this._pendingSave.slice();this._pendingSave=[],E(e,function(e){var t,r=e[0],n=e[1],i=this.adapterFor(r.constructor);t=g(r,"isNew")?"createRecord":g(r,"isDeleted")?"deleteRecord":"updateRecord",n.resolve(y(i,this,t,r))},this)},didSaveRecord:function(t,r){r&&(r=e(this,t.constructor,r,t),this.updateId(t,r)),t.adapterDidCommit(r)},recordWasInvalid:function(e,t){e.adapterDidInvalidate(t)},recordWasError:function(e){e.adapterDidError()},updateId:function(e,t){var r=(g(e,"id"),F(t.id));this.typeMapFor(e.constructor).idToRecord[r]=e,b(e,"id",r)},typeMapFor:function(e){var t,r=g(this,"typeMaps"),n=Ember.guidFor(e);return(t=r[n])?t:(t={idToRecord:{},records:[],metadata:{}},r[n]=t,t)},_load:function(e,t,r){var n=F(t.id),i=this.recordForId(e,n);return i.setupData(t,r),this.recordArrayManager.recordDidChange(i),i},modelFor:function(e){var t;if("string"==typeof e){var r=this.container.normalize("model:"+e);if(t=this.container.lookupFactory(r),!t)throw new Ember.Error("No model was found for '"+e+"'");t.typeKey=r.split(":",2)[1]}else t=e;return t.store=this,t},push:function(t,r,n){return t=this.modelFor(t),r=e(this,t,r),this._load(t,r,n),this.recordForId(t,r.id)},pushPayload:function(e,t){var r;t?r=this.serializerFor(e):(t=e,r=c(this.container)),r.pushPayload(this,t)},update:function(e,t){return this.push(e,t,!0)},pushMany:function(e,t){return D(t,function(t){return this.push(e,t)},this)},metaForType:function(e,t){e=this.modelFor(e),Ember.merge(this.typeMapFor(e).metadata,t)},buildRecord:function(e,t,r){var n=this.typeMapFor(e),i=n.idToRecord,a=e._create({id:t,store:this,container:this.container});return r&&a.setupData(r),t&&(i[t]=a),n.records.push(a),a},dematerializeRecord:function(e){var t=e.constructor,r=this.typeMapFor(t),n=g(e,"id");e.updateRecordArrays(),n&&delete r.idToRecord[n];var i=S(r.records,e);r.records.splice(i,1)},addRelationshipChangeFor:function(e,t,r,n,i){var a=e.clientId,o=r?r:r,s=t+n,c=this._relationshipChanges;a in c||(c[a]={}),o in c[a]||(c[a][o]={}),s in c[a][o]||(c[a][o][s]={}),c[a][o][s][i.changeType]=i},removeRelationshipChangeFor:function(e,t,r,n,i){var a=e.clientId,o=r?r.clientId:r,s=this._relationshipChanges,c=t+n;a in s&&o in s[a]&&c in s[a][o]&&delete s[a][o][c][i]},relationshipChangePairsFor:function(e){var t=[];if(!e)return t;var r=this._relationshipChanges[e.clientId];for(var n in r)if(r.hasOwnProperty(n))for(var i in r[n])r[n].hasOwnProperty(i)&&t.push(r[n][i]);return t},adapterFor:function(e){var t,r=this.container;return r&&(t=r.lookup("adapter:"+e.typeKey)||r.lookup("adapter:application")),t||g(this,"defaultAdapter")},serializerFor:function(e){e=this.modelFor(e);var t=this.adapterFor(e);return s(this.container,e.typeKey,t&&t.defaultSerializer)}}),DS.PromiseArray=Ember.ArrayProxy.extend(Ember.PromiseProxyMixin),DS.PromiseObject=Ember.ObjectProxy.extend(Ember.PromiseProxyMixin)}(),function(){function e(t){var r,n={};for(var i in t)r=t[i],n[i]=r&&"object"==typeof r?e(r):r;return n}function t(e,t){for(var r in t)e[r]=t[r];return e}function r(r){var n=e(s);return t(n,r)}function n(e,r,i){e=t(r?Ember.create(r):{},e),e.parentState=r,e.stateName=i;for(var a in e)e.hasOwnProperty(a)&&"parentState"!==a&&"stateName"!==a&&"object"==typeof e[a]&&(e[a]=n(e[a],e,i+"."+a));return e}var i=Ember.get,a=Ember.set,o=function(e,t){t.value===t.originalValue?(delete e._attributes[t.name],e.send("propertyWasReset",t.name)):t.value!==t.oldValue&&e.send("becomeDirty"),e.updateRecordArraysLater()},s={initialState:"uncommitted",isDirty:!0,uncommitted:{didSetProperty:o,propertyWasReset:function(e){var t=!1;for(var r in e._attributes){t=!0;break}t||e.send("rolledBack")},pushedData:Ember.K,becomeDirty:Ember.K,willCommit:function(e){e.transitionTo("inFlight")},reloadRecord:function(e,t){t(i(e,"store").reloadRecord(e))},rolledBack:function(e){e.transitionTo("loaded.saved")},becameInvalid:function(e){e.transitionTo("invalid")},rollback:function(e){e.rollback()}},inFlight:{isSaving:!0,didSetProperty:o,becomeDirty:Ember.K,pushedData:Ember.K,willCommit:Ember.K,didCommit:function(e){var t=i(this,"dirtyType");e.transitionTo("saved"),e.send("invokeLifecycleCallbacks",t)},becameInvalid:function(e){e.transitionTo("invalid"),e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("uncommitted"),e.triggerLater("becameError",e)}},invalid:{isValid:!1,deleteRecord:function(e){e.transitionTo("deleted.uncommitted"),e.clearRelationships()},didSetProperty:function(e,t){i(e,"errors").remove(t.name),o(e,t)},becomeDirty:Ember.K,rolledBack:function(e){i(e,"errors").clear()},becameValid:function(e){e.transitionTo("uncommitted")},invokeLifecycleCallbacks:function(e){e.triggerLater("becameInvalid",e)}}},c=r({dirtyType:"created",isNew:!0});c.uncommitted.rolledBack=function(e){e.transitionTo("deleted.saved")};var d=r({dirtyType:"updated"});c.uncommitted.deleteRecord=function(e){e.clearRelationships(),e.transitionTo("deleted.saved")},c.uncommitted.rollback=function(e){s.uncommitted.rollback.apply(this,arguments),e.transitionTo("deleted.saved")},d.uncommitted.deleteRecord=function(e){e.transitionTo("deleted.uncommitted"),e.clearRelationships()};var u={isEmpty:!1,isLoading:!1,isLoaded:!1,isDirty:!1,isSaving:!1,isDeleted:!1,isNew:!1,isValid:!0,rolledBack:Ember.K,propertyWasReset:Ember.K,empty:{isEmpty:!0,loadingData:function(e,t){e._loadingPromise=t,e.transitionTo("loading")},loadedData:function(e){e.transitionTo("loaded.created.uncommitted"),e.suspendRelationshipObservers(function(){e.notifyPropertyChange("data")})},pushedData:function(e){e.transitionTo("loaded.saved"),e.triggerLater("didLoad")}},loading:{isLoading:!0,exit:function(e){e._loadingPromise=null},pushedData:function(e){e.transitionTo("loaded.saved"),e.triggerLater("didLoad"),a(e,"isError",!1)},becameError:function(e){e.triggerLater("becameError",e)},notFound:function(e){e.transitionTo("empty")}},loaded:{initialState:"saved",isLoaded:!0,saved:{setup:function(e){var t=e._attributes,r=!1;for(var n in t)if(t.hasOwnProperty(n)){r=!0;break}r&&e.adapterDidDirty()},didSetProperty:o,pushedData:Ember.K,becomeDirty:function(e){e.transitionTo("updated.uncommitted")},willCommit:function(e){e.transitionTo("updated.inFlight")},reloadRecord:function(e,t){t(i(e,"store").reloadRecord(e))},deleteRecord:function(e){e.transitionTo("deleted.uncommitted"),e.clearRelationships()},unloadRecord:function(e){e.clearRelationships(),e.transitionTo("deleted.saved")},didCommit:function(e){e.send("invokeLifecycleCallbacks",i(e,"lastDirtyType"))},notFound:Ember.K},created:c,updated:d},deleted:{initialState:"uncommitted",dirtyType:"deleted",isDeleted:!0,isLoaded:!0,isDirty:!0,setup:function(e){e.updateRecordArrays()},uncommitted:{willCommit:function(e){e.transitionTo("inFlight")},rollback:function(e){e.rollback()},becomeDirty:Ember.K,deleteRecord:Ember.K,rolledBack:function(e){e.transitionTo("loaded.saved")}},inFlight:{isSaving:!0,willCommit:Ember.K,didCommit:function(e){e.transitionTo("saved"),e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("uncommitted"),e.triggerLater("becameError",e)}},saved:{isDirty:!1,setup:function(e){var t=i(e,"store");t.dematerializeRecord(e)},invokeLifecycleCallbacks:function(e){e.triggerLater("didDelete",e),e.triggerLater("didCommit",e)}}},invokeLifecycleCallbacks:function(e,t){"created"===t?e.triggerLater("didCreate",e):e.triggerLater("didUpdate",e),e.triggerLater("didCommit",e)}};u=n(u,null,"root"),DS.RootState=u}(),function(){var e=Ember.get,t=Ember.isEmpty;DS.Errors=Ember.Object.extend(Ember.Enumerable,Ember.Evented,{registerHandlers:function(e,t,r){this.on("becameInvalid",e,t),this.on("becameValid",e,r)},errorsByAttributeName:Ember.reduceComputed("content",{initialValue:function(){return Ember.MapWithDefault.create({defaultValue:function(){return Ember.A()}})},addedItem:function(e,t){return e.get(t.attribute).pushObject(t),e},removedItem:function(e,t){return e.get(t.attribute).removeObject(t),e}}),errorsFor:function(t){return e(this,"errorsByAttributeName").get(t)},messages:Ember.computed.mapBy("content","message"),content:Ember.computed(function(){return Ember.A()}),unknownProperty:function(e){var r=this.errorsFor(e);return t(r)?null:r},nextObject:function(t){return e(this,"content").objectAt(t)},length:Ember.computed.oneWay("content.length").readOnly(),isEmpty:Ember.computed.not("length").readOnly(),add:function(t,r){var n=e(this,"isEmpty");r=this._findOrCreateMessages(t,r),e(this,"content").addObjects(r),this.notifyPropertyChange(t),this.enumerableContentDidChange(),n&&!e(this,"isEmpty")&&this.trigger("becameInvalid")},_findOrCreateMessages:function(e,t){var r=this.errorsFor(e);return Ember.makeArray(t).map(function(t){return r.findBy("message",t)||{attribute:e,message:t}})},remove:function(t){if(!e(this,"isEmpty")){var r=e(this,"content").rejectBy("attribute",t);e(this,"content").setObjects(r),this.notifyPropertyChange(t),this.enumerableContentDidChange(),e(this,"isEmpty")&&this.trigger("becameValid")}},clear:function(){e(this,"isEmpty")||(e(this,"content").clear(),this.enumerableContentDidChange(),this.trigger("becameValid"))},has:function(e){return!t(this.errorsFor(e))}})}(),function(){var e=Ember.get,t=Ember.set,r=Ember.merge,n=Ember.run.once,i=Ember.computed("currentState",function(t){return e(e(this,"currentState"),t)}).readOnly();DS.Model=Ember.Object.extend(Ember.Evented,{isEmpty:i,isLoading:i,isLoaded:i,isDirty:i,isSaving:i,isDeleted:i,isNew:i,isValid:i,dirtyType:i,isError:!1,isReloading:!1,clientId:null,id:null,transaction:null,currentState:null,errors:null,serialize:function(t){var r=e(this,"store");return r.serialize(this,t)},toJSON:function(e){var t=DS.JSONSerializer.create({container:this.container});return t.serialize(this,e)},didLoad:Ember.K,didUpdate:Ember.K,didCreate:Ember.K,didDelete:Ember.K,becameInvalid:Ember.K,becameError:Ember.K,data:Ember.computed(function(){return this._data=this._data||{},this._data}).property(),_data:null,init:function(){t(this,"currentState",DS.RootState.empty);var e=DS.Errors.create();e.registerHandlers(this,function(){this.send("becameInvalid")},function(){this.send("becameValid")}),t(this,"errors",e),this._super(),this._setup()},_setup:function(){this._changesToSync={},this._deferredTriggers=[],this._data={},this._attributes={},this._inFlightAttributes={},this._relationships={}},send:function(t,r){var n=e(this,"currentState");return n[t]||this._unhandledEvent(n,t,r),n[t](this,r)},transitionTo:function(r){var n=r.split(".",1),i=e(this,"currentState"),a=i;do a.exit&&a.exit(this),a=a.parentState;while(!a.hasOwnProperty(n));var o,s,c=r.split("."),d=[],u=[];for(o=0,s=c.length;s>o;o++)a=a[c[o]],a.enter&&u.push(a),a.setup&&d.push(a);for(o=0,s=u.length;s>o;o++)u[o].enter(this);for(t(this,"currentState",a),o=0,s=d.length;s>o;o++)d[o].setup(this);this.updateRecordArraysLater()},_unhandledEvent:function(e,t,r){var n="Attempted to handle event `"+t+"` ";throw n+="on "+String(this)+" while in state ",n+=e.stateName+". ",void 0!==r&&(n+="Called with "+Ember.inspect(r)+"."),new Ember.Error(n)},withTransaction:function(t){var r=e(this,"transaction");r&&t(r)},loadingData:function(e){this.send("loadingData",e)},loadedData:function(){this.send("loadedData")},notFound:function(){this.send("notFound")},pushedData:function(){this.send("pushedData")},deleteRecord:function(){this.send("deleteRecord")},destroyRecord:function(){return this.deleteRecord(),this.save()},unloadRecord:function(){this.send("unloadRecord")},clearRelationships:function(){this.eachRelationship(function(e,r){if("belongsTo"===r.kind)t(this,e,null);else if("hasMany"===r.kind){var n=this._relationships[r.name];n&&n.clear()}},this)},updateRecordArrays:function(){e(this,"store").dataWasUpdated(this.constructor,this)},changedAttributes:function(){var t,r=e(this,"_data"),n=e(this,"_attributes"),i={};for(t in n)i[t]=[r[t],n[t]];return i},adapterWillCommit:function(){this.send("willCommit")},adapterDidCommit:function(e){t(this,"isError",!1),e?this._data=e:Ember.mixin(this._data,this._inFlightAttributes),this._inFlightAttributes={},this.send("didCommit"),this.updateRecordArraysLater(),e&&this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},adapterDidDirty:function(){this.send("becomeDirty"),this.updateRecordArraysLater()},dataDidChange:Ember.observer(function(){this.reloadHasManys()},"data"),reloadHasManys:function(){var t=e(this.constructor,"relationshipsByName");this.updateRecordArraysLater(),t.forEach(function(e,t){this._data.links&&this._data.links[e]||"hasMany"===t.kind&&this.hasManyDidChange(t.key)},this)},hasManyDidChange:function(e){var r=this._relationships[e];if(r){var n=this._data[e]||[];t(r,"content",Ember.A(n)),t(r,"isLoaded",!0),r.trigger("didLoad")}},updateRecordArraysLater:function(){Ember.run.once(this,this.updateRecordArrays)},setupData:function(e,t){t?Ember.merge(this._data,e):this._data=e;var r=this._relationships;this.eachRelationship(function(t,n){e.links&&e.links[t]||n.options.async&&(r[t]=null)}),e&&this.pushedData(),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},materializeId:function(e){t(this,"id",e)},materializeAttributes:function(e){r(this._data,e)},materializeAttribute:function(e,t){this._data[e]=t},updateHasMany:function(e,t){this._data[e]=t,this.hasManyDidChange(e)},updateBelongsTo:function(e,t){this._data[e]=t},rollback:function(){this._attributes={},e(this,"isError")&&(this._inFlightAttributes={},t(this,"isError",!1)),e(this,"isValid")||(this._inFlightAttributes={}),this.send("rolledBack"),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},toStringExtension:function(){return e(this,"id")},suspendRelationshipObservers:function(t,r){var n=e(this.constructor,"relationshipNames").belongsTo,i=this;try{this._suspendedRelationships=!0,Ember._suspendObservers(i,n,null,"belongsToDidChange",function(){Ember._suspendBeforeObservers(i,n,null,"belongsToWillChange",function(){t.call(r||i)})})}finally{this._suspendedRelationships=!1}},save:function(){var e="DS: Model#save "+this,t=Ember.RSVP.defer(e);return this.get("store").scheduleSave(this,t),this._inFlightAttributes=this._attributes,this._attributes={},DS.PromiseObject.create({promise:t.promise})},reload:function(){t(this,"isReloading",!0);var e=this,r="DS: Model#reload of "+this,n=new Ember.RSVP.Promise(function(t){e.send("reloadRecord",t)},r).then(function(){return e.set("isReloading",!1),e.set("isError",!1),e},function(t){throw e.set("isError",!0),t},"DS: Model#reload complete, update flags");return DS.PromiseObject.create({promise:n})},adapterDidUpdateAttribute:function(e,t){void 0!==t?(this._data[e]=t,this.notifyPropertyChange(e)):this._data[e]=this._inFlightAttributes[e],this.updateRecordArraysLater()},adapterDidInvalidate:function(t){function r(e){t[e]&&n.add(e,t[e])}var n=e(this,"errors");this.eachAttribute(r),this.eachRelationship(r)},adapterDidError:function(){this.send("becameError"),t(this,"isError",!0)
9
- },trigger:function(e){Ember.tryInvoke(this,e,[].slice.call(arguments,1)),this._super.apply(this,arguments)},triggerLater:function(){this._deferredTriggers.push(arguments),n(this,"_triggerDeferredTriggers")},_triggerDeferredTriggers:function(){for(var e=0,t=this._deferredTriggers.length;t>e;e++)this.trigger.apply(this,this._deferredTriggers[e]);this._deferredTriggers=[]}}),DS.Model.reopenClass({_create:DS.Model.create,create:function(){throw new Ember.Error("You should not call `create` on a model. Instead, call `store.createRecord` with the attributes you would like to set.")}})}(),function(){function e(e,t){return"function"==typeof t.defaultValue?t.defaultValue():t.defaultValue}function t(e,t){return e._attributes.hasOwnProperty(t)||e._inFlightAttributes.hasOwnProperty(t)||e._data.hasOwnProperty(t)}function r(e,t){return e._attributes.hasOwnProperty(t)?e._attributes[t]:e._inFlightAttributes.hasOwnProperty(t)?e._inFlightAttributes[t]:e._data[t]}var n=Ember.get;DS.Model.reopenClass({attributes:Ember.computed(function(){var e=Ember.Map.create();return this.eachComputedProperty(function(t,r){r.isAttribute&&(r.name=t,e.set(t,r))}),e}),transformedAttributes:Ember.computed(function(){var e=Ember.Map.create();return this.eachAttribute(function(t,r){r.type&&e.set(t,r.type)}),e}),eachAttribute:function(e,t){n(this,"attributes").forEach(function(r,n){e.call(t,r,n)},t)},eachTransformedAttribute:function(e,t){n(this,"transformedAttributes").forEach(function(r,n){e.call(t,r,n)})}}),DS.Model.reopen({eachAttribute:function(e,t){this.constructor.eachAttribute(e,t)}}),DS.attr=function(n,i){i=i||{};var a={type:n,isAttribute:!0,options:i};return Ember.computed(function(n,a){if(arguments.length>1){var o=this._attributes[n]||this._inFlightAttributes[n]||this._data[n];return this.send("didSetProperty",{name:n,oldValue:o,originalValue:this._data[n],value:a}),this._attributes[n]=a,a}return t(this,n)?r(this,n):e(this,i,n)}).property("data").meta(a)}}(),function(){var e=DS.AttributeChange=function(e){this.record=e.record,this.store=e.store,this.name=e.name,this.value=e.value,this.oldValue=e.oldValue};e.createChange=function(t){return new e(t)},e.prototype={sync:function(){this.value!==this.oldValue&&(this.record.send("becomeDirty"),this.record.updateRecordArraysLater()),this.destroy()},destroy:function(){delete this.record._changesToSync[this.name]}}}(),function(){function e(e){return"object"==typeof e&&(!e.then||"function"!=typeof e.then)}var t=Ember.get,r=Ember.set,n=Ember.EnumerableUtils.forEach;DS.RelationshipChange=function(e){this.parentRecord=e.parentRecord,this.childRecord=e.childRecord,this.firstRecord=e.firstRecord,this.firstRecordKind=e.firstRecordKind,this.firstRecordName=e.firstRecordName,this.secondRecord=e.secondRecord,this.secondRecordKind=e.secondRecordKind,this.secondRecordName=e.secondRecordName,this.changeType=e.changeType,this.store=e.store,this.committed={}},DS.RelationshipChangeAdd=function(e){DS.RelationshipChange.call(this,e)},DS.RelationshipChangeRemove=function(e){DS.RelationshipChange.call(this,e)},DS.RelationshipChange.create=function(e){return new DS.RelationshipChange(e)},DS.RelationshipChangeAdd.create=function(e){return new DS.RelationshipChangeAdd(e)},DS.RelationshipChangeRemove.create=function(e){return new DS.RelationshipChangeRemove(e)},DS.OneToManyChange={},DS.OneToNoneChange={},DS.ManyToNoneChange={},DS.OneToOneChange={},DS.ManyToManyChange={},DS.RelationshipChange._createChange=function(e){return"add"===e.changeType?DS.RelationshipChangeAdd.create(e):"remove"===e.changeType?DS.RelationshipChangeRemove.create(e):void 0},DS.RelationshipChange.determineRelationshipType=function(e,t){var r,n,i=t.key,a=t.kind,o=e.inverseFor(i);return o&&(r=o.name,n=o.kind),o?"belongsTo"===n?"belongsTo"===a?"oneToOne":"manyToOne":"belongsTo"===a?"oneToMany":"manyToMany":"belongsTo"===a?"oneToNone":"manyToNone"},DS.RelationshipChange.createChange=function(e,t,r,n){var i,a=e.constructor;return i=DS.RelationshipChange.determineRelationshipType(a,n),"oneToMany"===i?DS.OneToManyChange.createChange(e,t,r,n):"manyToOne"===i?DS.OneToManyChange.createChange(t,e,r,n):"oneToNone"===i?DS.OneToNoneChange.createChange(e,t,r,n):"manyToNone"===i?DS.ManyToNoneChange.createChange(e,t,r,n):"oneToOne"===i?DS.OneToOneChange.createChange(e,t,r,n):"manyToMany"===i?DS.ManyToManyChange.createChange(e,t,r,n):void 0},DS.OneToNoneChange.createChange=function(e,t,r,n){var i=n.key,a=DS.RelationshipChange._createChange({parentRecord:t,childRecord:e,firstRecord:e,store:r,changeType:n.changeType,firstRecordName:i,firstRecordKind:"belongsTo"});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.ManyToNoneChange.createChange=function(e,t,r,n){var i=n.key,a=DS.RelationshipChange._createChange({parentRecord:e,childRecord:t,secondRecord:e,store:r,changeType:n.changeType,secondRecordName:n.key,secondRecordKind:"hasMany"});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.ManyToManyChange.createChange=function(e,t,r,n){var i=n.key,a=DS.RelationshipChange._createChange({parentRecord:t,childRecord:e,firstRecord:e,secondRecord:t,firstRecordKind:"hasMany",secondRecordKind:"hasMany",store:r,changeType:n.changeType,firstRecordName:i});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.OneToOneChange.createChange=function(e,t,r,n){var i;n.parentType?i=n.parentType.inverseFor(n.key).name:n.key&&(i=n.key);var a=DS.RelationshipChange._createChange({parentRecord:t,childRecord:e,firstRecord:e,secondRecord:t,firstRecordKind:"belongsTo",secondRecordKind:"belongsTo",store:r,changeType:n.changeType,firstRecordName:i});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.OneToOneChange.maintainInvariant=function(e,r,n,i){if("add"===e.changeType&&r.recordIsMaterialized(n)){var a=t(n,i);if(a){var o=DS.OneToOneChange.createChange(n,a,r,{parentType:e.parentType,hasManyName:e.hasManyName,changeType:"remove",key:e.key});r.addRelationshipChangeFor(n,i,e.parentRecord,null,o),o.sync()}}},DS.OneToManyChange.createChange=function(e,t,r,n){var i;n.parentType?(i=n.parentType.inverseFor(n.key).name,DS.OneToManyChange.maintainInvariant(n,r,e,i)):n.key&&(i=n.key);var a=DS.RelationshipChange._createChange({parentRecord:t,childRecord:e,firstRecord:e,secondRecord:t,firstRecordKind:"belongsTo",secondRecordKind:"hasMany",store:r,changeType:n.changeType,firstRecordName:i});return r.addRelationshipChangeFor(e,i,t,a.getSecondRecordName(),a),a},DS.OneToManyChange.maintainInvariant=function(e,r,n,i){if("add"===e.changeType&&n){var a=t(n,i);if(a){var o=DS.OneToManyChange.createChange(n,a,r,{parentType:e.parentType,hasManyName:e.hasManyName,changeType:"remove",key:e.key});r.addRelationshipChangeFor(n,i,e.parentRecord,o.getSecondRecordName(),o),o.sync()}}},DS.RelationshipChange.prototype={getSecondRecordName:function(){var e,t=this.secondRecordName;if(!t){if(e=this.secondRecord,!e)return;var r=this.firstRecord.constructor,n=r.inverseFor(this.firstRecordName);this.secondRecordName=n.name}return this.secondRecordName},getFirstRecordName:function(){var e=this.firstRecordName;return e},destroy:function(){var e=this.childRecord,t=this.getFirstRecordName(),r=this.getSecondRecordName(),n=this.store;n.removeRelationshipChangeFor(e,t,this.parentRecord,r,this.changeType)},getSecondRecord:function(){return this.secondRecord},getFirstRecord:function(){return this.firstRecord},coalesce:function(){var e=this.store.relationshipChangePairsFor(this.firstRecord);n(e,function(e){var t=e.add,r=e.remove;t&&r&&(t.destroy(),r.destroy())})}},DS.RelationshipChangeAdd.prototype=Ember.create(DS.RelationshipChange.create({})),DS.RelationshipChangeRemove.prototype=Ember.create(DS.RelationshipChange.create({})),DS.RelationshipChangeAdd.prototype.changeType="add",DS.RelationshipChangeAdd.prototype.sync=function(){var n=this.getSecondRecordName(),i=this.getFirstRecordName(),a=this.getFirstRecord(),o=this.getSecondRecord();o instanceof DS.Model&&a instanceof DS.Model&&("belongsTo"===this.secondRecordKind?o.suspendRelationshipObservers(function(){r(o,n,a)}):"hasMany"===this.secondRecordKind&&o.suspendRelationshipObservers(function(){var r=t(o,n);e(r)&&r.addObject(a)})),a instanceof DS.Model&&o instanceof DS.Model&&t(a,i)!==o&&("belongsTo"===this.firstRecordKind?a.suspendRelationshipObservers(function(){r(a,i,o)}):"hasMany"===this.firstRecordKind&&a.suspendRelationshipObservers(function(){var r=t(a,i);e(r)&&r.addObject(o)})),this.coalesce()},DS.RelationshipChangeRemove.prototype.changeType="remove",DS.RelationshipChangeRemove.prototype.sync=function(){var n=this.getSecondRecordName(),i=this.getFirstRecordName(),a=this.getFirstRecord(),o=this.getSecondRecord();o instanceof DS.Model&&a instanceof DS.Model&&("belongsTo"===this.secondRecordKind?o.suspendRelationshipObservers(function(){r(o,n,null)}):"hasMany"===this.secondRecordKind&&o.suspendRelationshipObservers(function(){var r=t(o,n);e(r)&&r.removeObject(a)})),a instanceof DS.Model&&t(a,i)&&("belongsTo"===this.firstRecordKind?a.suspendRelationshipObservers(function(){r(a,i,null)}):"hasMany"===this.firstRecordKind&&a.suspendRelationshipObservers(function(){var r=t(a,i);e(r)&&r.removeObject(o)})),this.coalesce()}}(),function(){function e(e,n,i){return Ember.computed(function(e,n){var a=t(this,"data"),o=t(this,"store"),s="DS: Async belongsTo "+this+" : "+e;if(2===arguments.length)return void 0===n?null:DS.PromiseObject.create({promise:Ember.RSVP.resolve(n,s)});var c=a.links&&a.links[e],d=a[e];if(r(d)){if(c){var u=Ember.RSVP.defer("DS: Async belongsTo (link) "+this+" : "+e);return o.findBelongsTo(this,c,i,u),DS.PromiseObject.create({promise:u.promise})}return null}var l=o.fetchRecord(d)||Ember.RSVP.resolve(d,s);return DS.PromiseObject.create({promise:l})}).property("data").meta(i)}var t=Ember.get,r=(Ember.set,Ember.isNone);DS.belongsTo=function(n,i){"object"==typeof n&&(i=n,n=void 0),i=i||{};var a={type:n,isRelationship:!0,options:i,kind:"belongsTo"};return i.async?e(n,i,a):Ember.computed(function(e,i){var a,o,s=t(this,"data"),c=t(this,"store");return o="string"==typeof n?c.modelFor(n):n,2===arguments.length?void 0===i?null:i:(a=s[e],r(a)?null:(c.fetchRecord(a),a))}).property("data").meta(a)},DS.Model.reopen({belongsToWillChange:Ember.beforeObserver(function(e,r){if(t(e,"isLoaded")){var n=t(e,r);if(n){var i=t(e,"store"),a=DS.RelationshipChange.createChange(e,n,i,{key:r,kind:"belongsTo",changeType:"remove"});a.sync(),this._changesToSync[r]=a}}}),belongsToDidChange:Ember.immediateObserver(function(e,r){if(t(e,"isLoaded")){var n=t(e,r);if(n){var i=t(e,"store"),a=DS.RelationshipChange.createChange(e,n,i,{key:r,kind:"belongsTo",changeType:"add"});a.sync()}}delete this._changesToSync[r]})})}(),function(){function e(e,r,n){return Ember.computed(function(e){var a=this._relationships[e],o="DS: Async hasMany "+this+" : "+e;if(!a){var s=Ember.RSVP.defer(o);a=t(this,e,r,function(t,r){var a,o=r.links&&r.links[e];return a=o?t.findHasMany(this,o,n,s):t.findMany(this,r[e],n.type,s),i(a,"promise",s.promise),a})}var c=a.get("promise").then(function(){return a},null,"DS: Async hasMany records received");return DS.PromiseArray.create({promise:c})}).property("data").meta(n)}function t(e,t,r,i){var o=e._relationships;if(o[t])return o[t];var s=n(e,"data"),c=n(e,"store"),d=o[t]=i.call(e,c,s);return a(d,{owner:e,name:t,isPolymorphic:r.polymorphic})}function r(r,n){n=n||{};var i={type:r,isRelationship:!0,options:n,kind:"hasMany"};return n.async?e(r,n,i):Ember.computed(function(e){return t(this,e,n,function(t,r){r[e];return t.findMany(this,r[e],i.type)})}).property("data").meta(i)}var n=Ember.get,i=Ember.set,a=Ember.setProperties;DS.hasMany=function(e,t){return"object"==typeof e&&(t=e,e=void 0),r(e,t)}}(),function(){{var e=Ember.get;Ember.set}DS.Model.reopen({didDefineProperty:function(e,t,r){if(r instanceof Ember.Descriptor){var n=r.meta();n.isRelationship&&"belongsTo"===n.kind&&(Ember.addObserver(e,t,null,"belongsToDidChange"),Ember.addBeforeObserver(e,t,null,"belongsToWillChange")),n.parentType=e.constructor}}}),DS.Model.reopenClass({typeForRelationship:function(t){var r=e(this,"relationshipsByName").get(t);return r&&r.type},inverseFor:function(t){function r(t,n,i){i=i||[];var a=e(n,"relationships");if(a){var o=a.get(t);return o&&i.push.apply(i,a.get(t)),t.superclass&&r(t.superclass,n,i),i}}var n=this.typeForRelationship(t);if(!n)return null;var i=this.metaForProperty(t).options;if(null===i.inverse)return null;var a,o;if(i.inverse)a=i.inverse,o=Ember.get(n,"relationshipsByName").get(a).kind;else{var s=r(this,n);if(0===s.length)return null;a=s[0].name,o=s[0].kind}return{type:n,name:a,kind:o}},relationships:Ember.computed(function(){var e=new Ember.MapWithDefault({defaultValue:function(){return[]}});return this.eachComputedProperty(function(t,r){if(r.isRelationship){"string"==typeof r.type&&(r.type=this.store.modelFor(r.type));var n=e.get(r.type);n.push({name:t,kind:r.kind})}}),e}),relationshipNames:Ember.computed(function(){var e={hasMany:[],belongsTo:[]};return this.eachComputedProperty(function(t,r){r.isRelationship&&e[r.kind].push(t)}),e}),relatedTypes:Ember.computed(function(){var t,r=Ember.A();return this.eachComputedProperty(function(n,i){i.isRelationship&&(t=i.type,"string"==typeof t&&(t=e(this,t,!1)||this.store.modelFor(t)),r.contains(t)||r.push(t))}),r}),relationshipsByName:Ember.computed(function(){var e,t=Ember.Map.create();return this.eachComputedProperty(function(r,n){n.isRelationship&&(n.key=r,e=n.type,e||"hasMany"!==n.kind?e||(e=r):e=Ember.String.singularize(r),"string"==typeof e&&(n.type=this.store.modelFor(e)),t.set(r,n))}),t}),fields:Ember.computed(function(){var e=Ember.Map.create();return this.eachComputedProperty(function(t,r){r.isRelationship?e.set(t,r.kind):r.isAttribute&&e.set(t,"attribute")}),e}),eachRelationship:function(t,r){e(this,"relationshipsByName").forEach(function(e,n){t.call(r,e,n)})},eachRelatedType:function(t,r){e(this,"relatedTypes").forEach(function(e){t.call(r,e)})}}),DS.Model.reopen({eachRelationship:function(e,t){this.constructor.eachRelationship(e,t)}})}(),function(){var e=Ember.get,t=(Ember.set,Ember.run.once),r=Ember.EnumerableUtils.forEach;DS.RecordArrayManager=Ember.Object.extend({init:function(){this.filteredRecordArrays=Ember.MapWithDefault.create({defaultValue:function(){return[]}}),this.changedRecords=[]},recordDidChange:function(e){this.changedRecords.push(e),t(this,this.updateRecordArrays)},recordArraysForRecord:function(e){return e._recordArrays=e._recordArrays||Ember.OrderedSet.create(),e._recordArrays},updateRecordArrays:function(){r(this.changedRecords,function(t){e(t,"isDeleted")?this._recordWasDeleted(t):this._recordWasChanged(t)},this),this.changedRecords=[]},_recordWasDeleted:function(e){var t=e._recordArrays;t&&r(t,function(t){t.removeRecord(e)})},_recordWasChanged:function(t){var n,i=t.constructor,a=this.filteredRecordArrays.get(i);r(a,function(r){n=e(r,"filterFunction"),this.updateRecordArray(r,n,i,t)},this);var o=t._loadingRecordArrays;if(o){for(var s=0,c=o.length;c>s;s++)o[s].loadedRecord();t._loadingRecordArrays=[]}},updateRecordArray:function(e,t,r,n){var i;i=t?t(n):!0;var a=this.recordArraysForRecord(n);i?(a.add(e),e.addRecord(n)):i||(a.remove(e),e.removeRecord(n))},updateFilter:function(t,r,n){for(var i,a=this.store.typeMapFor(r),o=a.records,s=0,c=o.length;c>s;s++)i=o[s],e(i,"isDeleted")||e(i,"isEmpty")||this.updateRecordArray(t,n,r,i)},createManyArray:function(e,t){var n=DS.ManyArray.create({type:e,content:t,store:this.store});return r(t,function(e){var t=this.recordArraysForRecord(e);t.add(n)},this),n},createRecordArray:function(e){var t=DS.RecordArray.create({type:e,content:Ember.A(),store:this.store,isLoaded:!0});return this.registerFilteredRecordArray(t,e),t},createFilteredRecordArray:function(e,t){var r=DS.FilteredRecordArray.create({type:e,content:Ember.A(),store:this.store,manager:this,filterFunction:t});return this.registerFilteredRecordArray(r,e,t),r},createAdapterPopulatedRecordArray:function(e,t){return DS.AdapterPopulatedRecordArray.create({type:e,query:t,content:Ember.A(),store:this.store})},registerFilteredRecordArray:function(e,t,r){var n=this.filteredRecordArrays.get(t);n.push(e),this.updateFilter(e,t,r)},registerWaitingRecordArray:function(e,t){var r=e._loadingRecordArrays||[];r.push(t),e._loadingRecordArrays=r}})}(),function(){var e=Ember.get,t=(Ember.set,Ember.ArrayPolyfills.map),r=["description","fileName","lineNumber","message","name","number","stack"];DS.InvalidError=function(e){var t=Error.prototype.constructor.call(this,"The backend rejected the commit because it was invalid: "+Ember.inspect(e));this.errors=e;for(var n=0,i=r.length;i>n;n++)this[r[n]]=t[r[n]]},DS.InvalidError.prototype=Ember.create(Error.prototype),DS.Adapter=Ember.Object.extend({find:Ember.required(Function),findAll:null,findQuery:null,generateIdForRecord:null,serialize:function(t,r){return e(t,"store").serializerFor(t.constructor.typeKey).serialize(t,r)},createRecord:Ember.required(Function),updateRecord:Ember.required(Function),deleteRecord:Ember.required(Function),findMany:function(e,r,n){var i=t.call(n,function(t){return this.find(e,r,t)},this);return Ember.RSVP.all(i)}})}(),function(){var e=Ember.get,t=Ember.String.fmt,r=Ember.EnumerableUtils.indexOf,n=0;DS.FixtureAdapter=DS.Adapter.extend({serializer:null,simulateRemoteResponse:!0,latency:50,fixturesForType:function(e){if(e.FIXTURES){var r=Ember.A(e.FIXTURES);return r.map(function(e){var r=typeof e.id;if("number"!==r&&"string"!==r)throw new Error(t("the id property must be defined as a number or string for fixture %@",[e]));return e.id=e.id+"",e})}return null},queryFixtures:function(){},updateFixtures:function(e,t){e.FIXTURES||(e.FIXTURES=[]);var r=e.FIXTURES;this.deleteLoadedFixture(e,t),r.push(t)},mockJSON:function(e,t,r){return e.serializerFor(t).serialize(r,{includeId:!0})},generateIdForRecord:function(){return"fixture-"+n++},find:function(e,t,r){var n,i=this.fixturesForType(t);return i&&(n=Ember.A(i).findProperty("id",r)),n?this.simulateRemoteCall(function(){return n},this):void 0},findMany:function(e,t,n){var i=this.fixturesForType(t);return i&&(i=i.filter(function(e){return-1!==r(n,e.id)})),i?this.simulateRemoteCall(function(){return i},this):void 0},findAll:function(e,t){var r=this.fixturesForType(t);return this.simulateRemoteCall(function(){return r},this)},findQuery:function(e,t,r){var n=this.fixturesForType(t);return n=this.queryFixtures(n,r,t),n?this.simulateRemoteCall(function(){return n},this):void 0},createRecord:function(e,t,r){var n=this.mockJSON(e,t,r);return this.updateFixtures(t,n),this.simulateRemoteCall(function(){return n},this)},updateRecord:function(e,t,r){var n=this.mockJSON(e,t,r);return this.updateFixtures(t,n),this.simulateRemoteCall(function(){return n},this)},deleteRecord:function(e,t,r){var n=this.mockJSON(e,t,r);return this.deleteLoadedFixture(t,n),this.simulateRemoteCall(function(){return null})},deleteLoadedFixture:function(e,t){var n=this.findExistingFixture(e,t);if(n){var i=r(e.FIXTURES,n);return e.FIXTURES.splice(i,1),!0}},findExistingFixture:function(t,r){var n=this.fixturesForType(t),i=e(r,"id");return this.findFixtureById(n,i)},findFixtureById:function(t,r){return Ember.A(t).find(function(t){return""+e(t,"id")==""+r?!0:!1})},simulateRemoteCall:function(t,r){var n=this;return new Ember.RSVP.Promise(function(i){e(n,"simulateRemoteResponse")?Ember.run.later(function(){i(t.call(r))},e(n,"latency")):Ember.run.schedule("actions",null,function(){i(t.call(r))})},"DS: FixtureAdapter#simulateRemoteCall")}})}(),function(){function e(e){return null==e?null:e+""}var t=Ember.get,r=(Ember.set,Ember.ArrayPolyfills.forEach),n=Ember.ArrayPolyfills.map;DS.RESTSerializer=DS.JSONSerializer.extend({normalize:function(e,t,r){return this.normalizeId(t),this.normalizeAttributes(e,t),this.normalizeRelationships(e,t),this.normalizeUsingDeclaredMapping(e,t),this.normalizeHash&&this.normalizeHash[r]&&this.normalizeHash[r](t),this._super(e,t,r)},normalizePayload:function(e,t){return t},normalizeId:function(e){var r=t(this,"primaryKey");"id"!==r&&(e.id=e[r],delete e[r])},normalizeUsingDeclaredMapping:function(e,r){var n,i,a=t(this,"attrs");if(a)for(i in a)n=a[i],n&&n.key&&(n=n.key),"string"==typeof n&&(r[i]=r[n],delete r[n])},normalizeAttributes:function(e,t){var r;this.keyForAttribute&&e.eachAttribute(function(e){r=this.keyForAttribute(e),e!==r&&(t[e]=t[r],delete t[r])},this)},normalizeRelationships:function(e,t){var r;this.keyForRelationship&&e.eachRelationship(function(e,n){r=this.keyForRelationship(e,n.kind),e!==r&&(t[e]=t[r],delete t[r])},this)},extractSingle:function(t,n,i,a){i=this.normalizePayload(n,i);var o,s=n.typeKey;for(var c in i){var d=this.typeForRoot(c),u=d===s;if(u&&"array"!==Ember.typeOf(i[c]))o=this.normalize(n,i[c],c);else{{t.modelFor(d)}r.call(i[c],function(r){var n=this.typeForRoot(c),i=t.modelFor(n),s=t.serializerFor(i);r=s.normalize(i,r,c);var d=u&&!a&&!o,l=u&&e(r.id)===a;d||l?o=r:t.push(n,r)},this)}}return o},extractArray:function(e,t,r){r=this.normalizePayload(t,r);var i,a=t.typeKey;for(var o in r){var s=o,c=!1;"_"===o.charAt(0)&&(c=!0,s=o.substr(1));var d=this.typeForRoot(s),u=e.modelFor(d),l=e.serializerFor(u),h=!c&&d===a,f=n.call(r[o],function(e){return l.normalize(u,e,o)},this);h?i=f:e.pushMany(d,f)}return i},pushPayload:function(e,t){t=this.normalizePayload(null,t);for(var r in t){var i=this.typeForRoot(r),a=e.modelFor(i),o=n.call(Ember.makeArray(t[r]),function(e){return this.normalize(a,e,r)},this);e.pushMany(i,o)}},typeForRoot:function(e){return Ember.String.singularize(e)},serialize:function(){return this._super.apply(this,arguments)},serializeIntoHash:function(e,t,r,n){e[t.typeKey]=this.serialize(r,n)},serializePolymorphicType:function(e,r,n){var i=n.key,a=t(e,i);i=this.keyForAttribute?this.keyForAttribute(i):i,r[i+"Type"]=a.constructor.typeKey}})}(),function(){var e=Ember.get,t=(Ember.set,Ember.ArrayPolyfills.forEach);DS.RESTAdapter=DS.Adapter.extend({defaultSerializer:"_rest",find:function(e,t,r){return this.ajax(this.buildURL(t.typeKey,r),"GET")},findAll:function(e,t,r){var n;return r&&(n={since:r}),this.ajax(this.buildURL(t.typeKey),"GET",{data:n})},findQuery:function(e,t,r){return this.ajax(this.buildURL(t.typeKey),"GET",{data:r})},findMany:function(e,t,r){return this.ajax(this.buildURL(t.typeKey),"GET",{data:{ids:r}})},findHasMany:function(t,r,n){var i=e(this,"host"),a=e(r,"id"),o=r.constructor.typeKey;return i&&"/"===n.charAt(0)&&"/"!==n.charAt(1)&&(n=i+n),this.ajax(this.urlPrefix(n,this.buildURL(o,a)),"GET")},findBelongsTo:function(t,r,n){var i=e(r,"id"),a=r.constructor.typeKey;return this.ajax(this.urlPrefix(n,this.buildURL(a,i)),"GET")},createRecord:function(e,t,r){var n={},i=e.serializerFor(t.typeKey);return i.serializeIntoHash(n,t,r,{includeId:!0}),this.ajax(this.buildURL(t.typeKey),"POST",{data:n})},updateRecord:function(t,r,n){var i={},a=t.serializerFor(r.typeKey);a.serializeIntoHash(i,r,n);var o=e(n,"id");return this.ajax(this.buildURL(r.typeKey,o),"PUT",{data:i})},deleteRecord:function(t,r,n){var i=e(n,"id");return this.ajax(this.buildURL(r.typeKey,i),"DELETE")},buildURL:function(t,r){var n=[],i=e(this,"host"),a=this.urlPrefix();return t&&n.push(this.pathForType(t)),r&&n.push(r),a&&n.unshift(a),n=n.join("/"),!i&&n&&(n="/"+n),n},urlPrefix:function(t,r){var n=e(this,"host"),i=e(this,"namespace"),a=[];return t?"/"===t.charAt(0)?n&&(t=t.slice(1),a.push(n)):/^http(s)?:\/\//.test(t)||a.push(r):(n&&a.push(n),i&&a.push(i)),t&&a.push(t),a.join("/")},pathForType:function(e){return Ember.String.pluralize(e)},ajaxError:function(e){return e&&(e.then=null),e},ajax:function(e,t,r){var n=this;return new Ember.RSVP.Promise(function(i,a){r=n.ajaxOptions(e,t,r),r.success=function(e){Ember.run(null,i,e)},r.error=function(e){Ember.run(null,a,n.ajaxError(e))},Ember.$.ajax(r)},"DS: RestAdapter#ajax "+t+" to "+e)},ajaxOptions:function(e,r,n){if(n=n||{},n.url=e,n.type=r,n.dataType="json",n.context=this,n.data&&"GET"!==r&&(n.contentType="application/json; charset=utf-8",n.data=JSON.stringify(n.data)),void 0!==this.headers){var i=this.headers;n.beforeSend=function(e){t.call(Ember.keys(i),function(t){e.setRequestHeader(t,i[t])})}}return n}})}(),function(){DS.Model.reopen({_debugInfo:function(){var e=["id"],t={belongsTo:[],hasMany:[]},r=[];this.eachAttribute(function(t){e.push(t)},this),this.eachRelationship(function(e,n){t[n.kind].push(e),r.push(e)});var n=[{name:"Attributes",properties:e,expand:!0},{name:"Belongs To",properties:t.belongsTo,expand:!0},{name:"Has Many",properties:t.hasMany,expand:!0},{name:"Flags",properties:["isLoaded","isDirty","isSaving","isDeleted","isError","isNew","isValid"]}];return{propertyInfo:{includeOtherProperties:!0,groups:n,expensiveProperties:r}}}})}(),function(){Ember.String.pluralize=function(e){return Ember.Inflector.inflector.pluralize(e)},Ember.String.singularize=function(e){return Ember.Inflector.inflector.singularize(e)}}(),function(){function e(e,t){for(var r=0,n=t.length;n>r;r++)e.uncountable[t[r].toLowerCase()]=!0}function t(e,t){for(var r,n=0,i=t.length;i>n;n++)r=t[n],e.irregular[r[0].toLowerCase()]=r[1],e.irregularInverse[r[1].toLowerCase()]=r[0]}function r(r){r=r||{},r.uncountable=r.uncountable||{},r.irregularPairs=r.irregularPairs||{};var n=this.rules={plurals:r.plurals||[],singular:r.singular||[],irregular:{},irregularInverse:{},uncountable:{}};e(n,r.uncountable),t(n,r.irregularPairs)}var n=/^\s*$/;r.prototype={plural:function(e,t){this.rules.plurals.push([e,t.toLowerCase()])},singular:function(e,t){this.rules.singular.push([e,t.toLowerCase()])},uncountable:function(t){e(this.rules,[t.toLowerCase()])},irregular:function(e,r){t(this.rules,[[e,r]])},pluralize:function(e){return this.inflect(e,this.rules.plurals,this.rules.irregular)},singularize:function(e){return this.inflect(e,this.rules.singular,this.rules.irregularInverse)},inflect:function(e,t,r){var i,a,o,s,c,d,u,l;if(c=n.test(e))return e;if(s=e.toLowerCase(),d=this.rules.uncountable[s])return e;if(u=r&&r[s])return u;for(var h=t.length,f=0;h>f&&(i=t[h-1],l=i[0],!l.test(e));h--);return i=i||[],l=i[0],a=i[1],o=e.replace(l,a)}},Ember.Inflector=r}(),function(){Ember.Inflector.defaultRules={plurals:[[/$/,"s"],[/s$/i,"s"],[/^(ax|test)is$/i,"$1es"],[/(octop|vir)us$/i,"$1i"],[/(octop|vir)i$/i,"$1i"],[/(alias|status)$/i,"$1es"],[/(bu)s$/i,"$1ses"],[/(buffal|tomat)o$/i,"$1oes"],[/([ti])um$/i,"$1a"],[/([ti])a$/i,"$1a"],[/sis$/i,"ses"],[/(?:([^f])fe|([lr])f)$/i,"$1$2ves"],[/(hive)$/i,"$1s"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/(x|ch|ss|sh)$/i,"$1es"],[/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"],[/^(m|l)ouse$/i,"$1ice"],[/^(m|l)ice$/i,"$1ice"],[/^(ox)$/i,"$1en"],[/^(oxen)$/i,"$1"],[/(quiz)$/i,"$1zes"]],singular:[[/s$/i,""],[/(ss)$/i,"$1"],[/(n)ews$/i,"$1ews"],[/([ti])a$/i,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i,"$1sis"],[/(^analy)(sis|ses)$/i,"$1sis"],[/([^f])ves$/i,"$1fe"],[/(hive)s$/i,"$1"],[/(tive)s$/i,"$1"],[/([lr])ves$/i,"$1f"],[/([^aeiouy]|qu)ies$/i,"$1y"],[/(s)eries$/i,"$1eries"],[/(m)ovies$/i,"$1ovie"],[/(x|ch|ss|sh)es$/i,"$1"],[/^(m|l)ice$/i,"$1ouse"],[/(bus)(es)?$/i,"$1"],[/(o)es$/i,"$1"],[/(shoe)s$/i,"$1"],[/(cris|test)(is|es)$/i,"$1is"],[/^(a)x[ie]s$/i,"$1xis"],[/(octop|vir)(us|i)$/i,"$1us"],[/(alias|status)(es)?$/i,"$1"],[/^(ox)en/i,"$1"],[/(vert|ind)ices$/i,"$1ex"],[/(matr)ices$/i,"$1ix"],[/(quiz)zes$/i,"$1"],[/(database)s$/i,"$1"]],irregularPairs:[["person","people"],["man","men"],["child","children"],["sex","sexes"],["move","moves"],["cow","kine"],["zombie","zombies"]],uncountable:["equipment","information","rice","money","species","series","fish","sheep","jeans","police"]}}(),function(){(Ember.EXTEND_PROTOTYPES===!0||Ember.EXTEND_PROTOTYPES.String)&&(String.prototype.pluralize=function(){return Ember.String.pluralize(this)},String.prototype.singularize=function(){return Ember.String.singularize(this)})}(),function(){Ember.Inflector.inflector=new Ember.Inflector(Ember.Inflector.defaultRules)}(),function(){var e=Ember.get,t=Ember.EnumerableUtils.forEach;DS.ActiveModelSerializer=DS.RESTSerializer.extend({keyForAttribute:function(e){return Ember.String.decamelize(e)},keyForRelationship:function(e,t){return e=Ember.String.decamelize(e),"belongsTo"===t?e+"_id":"hasMany"===t?Ember.String.singularize(e)+"_ids":e},serializeHasMany:Ember.K,serializeIntoHash:function(e,t,r,n){var i=Ember.String.decamelize(t.typeKey);e[i]=this.serialize(r,n)},serializePolymorphicType:function(t,r,n){var i=n.key,a=e(t,i);i=this.keyForAttribute(i),r[i+"_type"]=Ember.String.capitalize(a.constructor.typeKey)},typeForRoot:function(e){var t=Ember.String.camelize(e);return Ember.String.singularize(t)},normalize:function(e,t,r){return this.normalizeLinks(t),this._super(e,t,r)},normalizeLinks:function(e){if(e.links){var t=e.links;for(var r in t){var n=Ember.String.camelize(r);n!==r&&(t[n]=t[r],delete t[r])}}},normalizeRelationships:function(e,r){var n,i;this.keyForRelationship&&e.eachRelationship(function(e,a){if(a.options.polymorphic){if(n=this.keyForAttribute(e),i=r[n],i&&i.type)i.type=this.typeForRoot(i.type);else if(i&&"hasMany"===a.kind){var o=this;t(i,function(e){e.type=o.typeForRoot(e.type)})}}else n=this.keyForRelationship(e,a.kind),i=r[n];r[e]=i,e!==n&&delete r[n]},this)}})}(),function(){function e(n,i,a,o,s){var c=t(i,"attrs");c&&a.eachRelationship(function(i,a){var d,u,l,h,f=c[i],p=n.serializerFor(a.type.typeKey),m=t(p,"primaryKey");if("hasMany"===a.kind&&f&&("always"===f.embedded||"load"===f.embedded)){if(u="_"+Ember.String.pluralize(a.type.typeKey),d=this.keyForRelationship(i,a.kind),l=this.keyForAttribute(i),h=[],!o[l])return;s[u]=s[u]||[],r(o[l],function(t){var r=n.modelFor(a.type.typeKey);e(n,p,r,t,s),h.push(t[m]),s[u].push(t)}),o[d]=h,delete o[l]}},i)}var t=Ember.get,r=Ember.EnumerableUtils.forEach;DS.EmbeddedRecordsMixin=Ember.Mixin.create({serializeHasMany:function(e,r,n){var i=n.key,a=t(this,"attrs"),o=a&&a[i]&&"always"===a[i].embedded;o&&(r[this.keyForAttribute(i)]=t(e,i).map(function(e){var r=e.serialize(),n=t(this,"primaryKey");return r[n]=t(e,n),r},this))},extractSingle:function(t,r,n,i,a){var o=this.keyForAttribute(r.typeKey),s=n[o];return e(t,this,r,s,n),this._super(t,r,n,i,a)},extractArray:function(t,n,i){var a=this.keyForAttribute(n.typeKey),o=i[Ember.String.pluralize(a)];return r(o,function(r){e(t,this,n,r,i)},this),this._super(t,n,i)}})}(),function(){var e=Ember.EnumerableUtils.forEach;DS.ActiveModelAdapter=DS.RESTAdapter.extend({defaultSerializer:"_ams",pathForType:function(e){var t=Ember.String.decamelize(e);return Ember.String.pluralize(t)},ajaxError:function(t){var r=this._super(t);if(t&&422===t.status){var n=Ember.$.parseJSON(t.responseText).errors,i={};return e(Ember.keys(n),function(e){i[Ember.String.camelize(e)]=n[e]}),new DS.InvalidError(i)}return r}})}(),function(){Ember.onLoad("Ember.Application",function(e){e.initializer({name:"activeModelAdapter",initialize:function(e,t){t.register("serializer:_ams",DS.ActiveModelSerializer),t.register("adapter:_ams",DS.ActiveModelAdapter)}})})}()}(),"undefined"==typeof location||"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname||Ember.Logger.warn("You are running a production build of Ember on localhost and won't receive detailed error messages. If you want full error messages please use the non-minified build provided on the Ember website.");
8
+ !function(){var e,t;!function(){var r={},n={};e=function(e,t,n){r[e]={deps:t,callback:n}},t=function(e){if(n[e])return n[e];n[e]={};var i,a,o,s,d;if(i=r[e],!i)throw new Error("Module '"+e+"' not found.");a=i.deps,o=i.callback,s=[];for(var u=0,c=a.length;c>u;u++)"exports"===a[u]?s.push(d={}):s.push(t(a[u]));var l=o.apply(this,s);return n[e]=d||l}}(),function(){var e;"undefined"==typeof e&&(e=Ember.Namespace.create({VERSION:"1.0.0-beta.6"}),"undefined"!=typeof window&&(window.DS=e),Ember.libraries&&Ember.libraries.registerCoreLibrary("Ember Data",e.VERSION))}(),function(){var e=function(e){this.container=e};e.prototype.aliasedFactory=function(e,t){var r=this;return{create:function(){return t&&t(),r.container.lookup(e)}}},e.prototype.registerAlias=function(e,t,r){var n=this.aliasedFactory(t,r);return this.container.register(e,n)},e.prototype.registerDeprecation=function(e,t){var r=function(){Ember.deprecate("You tried to look up '"+e+"', but this has been deprecated in favor of '"+t+"'.",!1)};return this.registerAlias(e,t,r)},e.prototype.registerDeprecations=function(e){for(var t=e.length;t>0;t--){var r=e[t-1],n=r.deprecated,i=r.valid;this.registerDeprecation(n,i)}},DS.ContainerProxy=e}(),function(){function e(e){return function(){return this[e].apply(this,arguments)}}var t=Ember.get,r=(Ember.set,Ember.isNone);DS.JSONSerializer=Ember.Object.extend({primaryKey:"id",applyTransforms:function(e,t){return e.eachTransformedAttribute(function(e,r){var n=this.transformFor(r);t[e]=n.deserialize(t[e])},this),t},normalize:function(e,t){return t?(this.applyTransforms(e,t),t):t},serialize:function(e,r){var n={};if(r&&r.includeId){var i=t(e,"id");i&&(n[t(this,"primaryKey")]=i)}return e.eachAttribute(function(t,r){this.serializeAttribute(e,n,t,r)},this),e.eachRelationship(function(t,r){"belongsTo"===r.kind?this.serializeBelongsTo(e,n,r):"hasMany"===r.kind&&this.serializeHasMany(e,n,r)},this),n},serializeAttribute:function(e,r,n,i){var a=t(this,"attrs"),o=t(e,n),s=i.type;if(s){var d=this.transformFor(s);o=d.serialize(o)}n=a&&a[n]||(this.keyForAttribute?this.keyForAttribute(n):n),r[n]=o},serializeBelongsTo:function(e,n,i){var a=i.key,o=t(e,a);a=this.keyForRelationship?this.keyForRelationship(a,"belongsTo"):a,n[a]=r(o)?o:t(o,"id"),i.options.polymorphic&&this.serializePolymorphicType(e,n,i)},serializeHasMany:function(e,r,n){var i=n.key,a=DS.RelationshipChange.determineRelationshipType(e.constructor,n);("manyToNone"===a||"manyToMany"===a)&&(r[i]=t(e,i).mapBy("id"))},serializePolymorphicType:Ember.K,extract:function(e,t,r,n,i){this.extractMeta(e,t,r);var a="extract"+i.charAt(0).toUpperCase()+i.substr(1);return this[a](e,t,r,n,i)},extractFindAll:e("extractArray"),extractFindQuery:e("extractArray"),extractFindMany:e("extractArray"),extractFindHasMany:e("extractArray"),extractCreateRecord:e("extractSave"),extractUpdateRecord:e("extractSave"),extractDeleteRecord:e("extractSave"),extractFind:e("extractSingle"),extractFindBelongsTo:e("extractSingle"),extractSave:e("extractSingle"),extractSingle:function(e,t,r){return this.normalize(t,r)},extractArray:function(e,t,r){return this.normalize(t,r)},extractMeta:function(e,t,r){r&&r.meta&&(e.metaForType(t,r.meta),delete r.meta)},transformFor:function(e,t){var r=this.container.lookup("transform:"+e);return Ember.assert("Unable to find transform for '"+e+"'",t||!!r),r}})}(),function(){var e=Ember.get,t=Ember.String.capitalize,r=Ember.String.underscore,n=window.DS;n.DebugAdapter=Ember.DataAdapter.extend({getFilters:function(){return[{name:"isNew",desc:"New"},{name:"isModified",desc:"Modified"},{name:"isClean",desc:"Clean"}]},detect:function(e){return e!==n.Model&&n.Model.detect(e)},columnsForType:function(n){var i=[{name:"id",desc:"Id"}],a=0,o=this;return e(n,"attributes").forEach(function(e){if(a++>o.attributeLimit)return!1;var n=t(r(e).replace("_"," "));i.push({name:e,desc:n})}),i},getRecords:function(e){return this.get("store").all(e)},getRecordColumnValues:function(t){var r=this,n=0,i={id:e(t,"id")};return t.eachAttribute(function(a){if(n++>r.attributeLimit)return!1;var o=e(t,a);i[a]=o}),i},getRecordKeywords:function(t){var r=[],n=Ember.A(["id"]);return t.eachAttribute(function(e){n.push(e)}),n.forEach(function(n){r.push(e(t,n))}),r},getRecordFilterValues:function(e){return{isNew:e.get("isNew"),isModified:e.get("isDirty")&&!e.get("isNew"),isClean:!e.get("isDirty")}},getRecordColor:function(e){var t="black";return e.get("isNew")?t="green":e.get("isDirty")&&(t="blue"),t},observeRecord:function(e,t){var r=Ember.A(),n=this,i=Ember.A(["id","isNew","isDirty"]);e.eachAttribute(function(e){i.push(e)}),i.forEach(function(i){var a=function(){t(n.wrapRecord(e))};Ember.addObserver(e,i,a),r.push(function(){Ember.removeObserver(e,i,a)})});var a=function(){r.forEach(function(e){e()})};return a}})}(),function(){DS.Transform=Ember.Object.extend({serialize:Ember.required(),deserialize:Ember.required()})}(),function(){DS.BooleanTransform=DS.Transform.extend({deserialize:function(e){var t=typeof e;return"boolean"===t?e:"string"===t?null!==e.match(/^true$|^t$|^1$/i):"number"===t?1===e:!1},serialize:function(e){return Boolean(e)}})}(),function(){DS.DateTransform=DS.Transform.extend({deserialize:function(e){var t=typeof e;return"string"===t?new Date(Ember.Date.parse(e)):"number"===t?new Date(e):null===e||void 0===e?e:null},serialize:function(e){return e instanceof Date?Number(e):null}})}(),function(){var e=Ember.isEmpty;DS.NumberTransform=DS.Transform.extend({deserialize:function(t){return e(t)?null:Number(t)},serialize:function(t){return e(t)?null:Number(t)}})}(),function(){var e=Ember.isNone;DS.StringTransform=DS.Transform.extend({deserialize:function(t){return e(t)?null:String(t)},serialize:function(t){return e(t)?null:String(t)}})}(),function(){Ember.set;Ember.onLoad("Ember.Application",function(e){e.initializer({name:"store",initialize:function(e,t){t.register("store:main",t.Store||DS.Store);var r=new DS.ContainerProxy(e);r.registerDeprecations([{deprecated:"serializer:_default",valid:"serializer:-default"},{deprecated:"serializer:_rest",valid:"serializer:-rest"},{deprecated:"adapter:_rest",valid:"adapter:-rest"}]),t.register("serializer:-default",DS.JSONSerializer),t.register("serializer:-rest",DS.RESTSerializer),t.register("adapter:-rest",DS.RESTAdapter),e.lookup("store:main")}}),e.initializer({name:"transforms",before:"store",initialize:function(e,t){t.register("transform:boolean",DS.BooleanTransform),t.register("transform:date",DS.DateTransform),t.register("transform:number",DS.NumberTransform),t.register("transform:string",DS.StringTransform)}}),e.initializer({name:"data-adapter",before:"store",initialize:function(e,t){t.register("data-adapter:main",DS.DebugAdapter)}}),e.initializer({name:"injectStore",before:"store",initialize:function(e,t){t.inject("controller","store","store:main"),t.inject("route","store","store:main"),t.inject("serializer","store","store:main"),t.inject("data-adapter","store","store:main")}})})}(),function(){Ember.Date=Ember.Date||{};var e=Date.parse,t=[1,4,5,6,7,10,11];Ember.Date.parse=function(r){var n,i,a=0;if(i=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(r)){for(var o,s=0;o=t[s];++s)i[o]=+i[o]||0;i[2]=(+i[2]||1)-1,i[3]=+i[3]||1,"Z"!==i[8]&&void 0!==i[9]&&(a=60*i[10]+i[11],"+"===i[9]&&(a=0-a)),n=Date.UTC(i[1],i[2],i[3],i[4],i[5]+a,i[6],i[7])}else n=e?e(r):0/0;return n},(Ember.EXTEND_PROTOTYPES===!0||Ember.EXTEND_PROTOTYPES.Date)&&(Date.parse=Ember.Date.parse)}(),function(){{var e=Ember.get;Ember.set}DS.RecordArray=Ember.ArrayProxy.extend(Ember.Evented,{type:null,content:null,isLoaded:!1,isUpdating:!1,store:null,objectAtContent:function(t){var r=e(this,"content");return r.objectAt(t)},update:function(){if(!e(this,"isUpdating")){var t=e(this,"store"),r=e(this,"type");return t.fetchAll(r,this)}},addRecord:function(t){e(this,"content").addObject(t)},removeRecord:function(t){e(this,"content").removeObject(t)},save:function(){var t="DS: RecordArray#save "+e(this,"type"),r=Ember.RSVP.all(this.invoke("save"),t).then(function(e){return Ember.A(e)},null,"DS: RecordArray#save apply Ember.NativeArray");return DS.PromiseArray.create({promise:r})}})}(),function(){var e=Ember.get;DS.FilteredRecordArray=DS.RecordArray.extend({filterFunction:null,isLoaded:!0,replace:function(){var t=e(this,"type").toString();throw new Error("The result of a client-side filter (on "+t+") is immutable.")},updateFilter:Ember.observer(function(){var t=e(this,"manager");t.updateFilter(this,e(this,"type"),e(this,"filterFunction"))},"filterFunction")})}(),function(){{var e=Ember.get;Ember.set}DS.AdapterPopulatedRecordArray=DS.RecordArray.extend({query:null,replace:function(){var t=e(this,"type").toString();throw new Error("The result of a server query (on "+t+") is immutable.")},load:function(t){var r=e(this,"store"),n=e(this,"type"),i=r.pushMany(n,t),a=r.metadataFor(n);this.setProperties({content:Ember.A(i),isLoaded:!0,meta:a}),Ember.run.once(this,"trigger","didLoad")}})}(),function(){var e=Ember.get,t=Ember.set,r=Ember.EnumerableUtils.map;DS.ManyArray=DS.RecordArray.extend({init:function(){this._super.apply(this,arguments),this._changesToSync=Ember.OrderedSet.create()},name:null,owner:null,isPolymorphic:!1,isLoaded:!1,promise:null,loadingRecordsCount:function(e){this.loadingRecordsCount=e},loadedRecord:function(){this.loadingRecordsCount--,0===this.loadingRecordsCount&&(t(this,"isLoaded",!0),this.trigger("didLoad"))},fetch:function(){var t=e(this,"content"),r=e(this,"store"),n=e(this,"owner"),i=Ember.RSVP.defer("DS: ManyArray#fetch "+e(this,"type")),a=t.filterProperty("isEmpty",!0);r.fetchMany(a,n,i)},replaceContent:function(e,t,n){n=r(n,function(e){return Ember.assert("You cannot add '"+e.constructor.typeKey+"' records to this relationship (only '"+this.type.typeKey+"' allowed)",!this.type||e instanceof this.type),e},this),this._super(e,t,n)},arrangedContentDidChange:function(){Ember.run.once(this,"fetch")},arrayContentWillChange:function(t,r){var n=e(this,"owner"),i=e(this,"name");if(!n._suspendedRelationships)for(var a=t;t+r>a;a++){var o=e(this,"content").objectAt(a),s=DS.RelationshipChange.createChange(n,o,e(this,"store"),{parentType:n.constructor,changeType:"remove",kind:"hasMany",key:i});this._changesToSync.add(s)}return this._super.apply(this,arguments)},arrayContentDidChange:function(t,r,n){this._super.apply(this,arguments);var i=e(this,"owner"),a=e(this,"name"),o=e(this,"store");if(!i._suspendedRelationships){for(var s=t;t+n>s;s++){var d=e(this,"content").objectAt(s),u=DS.RelationshipChange.createChange(i,d,o,{parentType:i.constructor,changeType:"add",kind:"hasMany",key:a});u.hasManyName=a,this._changesToSync.add(u)}this._changesToSync.forEach(function(e){e.sync()}),this._changesToSync.clear()}},createRecord:function(t){var r,n=e(this,"owner"),i=e(n,"store"),a=e(this,"type");return Ember.assert("You cannot add '"+a.typeKey+"' records to this polymorphic relationship.",!e(this,"isPolymorphic")),r=i.createRecord.call(i,a,t),this.pushObject(r),r}})}(),function(){function e(e,r,a,o){return r.eachRelationship(function(r,s){if(a.links&&a.links[r])return o&&s.options.async&&(o._relationships[r]=null),void 0;var d=s.kind,u=a[r];null!=u&&("belongsTo"===d?t(e,a,r,s,u):"hasMany"===d&&(n(e,a,r,s,u),i(o,r,u)))}),a}function t(e,t,n,i,a){if(!(R(a)||a instanceof DS.Model)){var o;"number"==typeof a||"string"==typeof a?(o=r(i,n,t),t[n]=e.recordForId(o,a)):"object"==typeof a&&(t[n]=e.recordForId(a.type,a.id))}}function r(e,t,r){return e.options.polymorphic?r[t+"Type"]:e.type}function n(e,r,n,i,a){for(var o=0,s=a.length;s>o;o++)t(e,a,o,i,a[o])}function i(e,t,r){e&&r.pushObjects(e.get(t).filterBy("isNew"))}function a(e){return DS.PromiseObject.create({promise:e})}function o(e){return DS.PromiseArray.create({promise:e})}function s(e){return e&&"function"==typeof e.then}function d(e,t,r){return e.lookup("serializer:"+t)||e.lookup("serializer:application")||e.lookup("serializer:"+r)||e.lookup("serializer:-default")}function u(e){return e.lookup("serializer:application")||e.lookup("serializer:-default")}function c(e,t){var r=e.serializer,n=e.defaultSerializer,i=e.container;return i&&void 0===r&&(r=d(i,t.typeKey,n)),(null===r||void 0===r)&&(r={extract:function(e,t,r){return r}}),r}function l(e,t,r,n){var i=e.find(t,r,n),a=c(e,r);return A(i,"DS: Handle Adapter#find of "+r+" with id: "+n).then(function(e){return Ember.assert("You made a request for a "+r.typeKey+" with id "+n+", but the adapter's response did not have any data",e),e=a.extract(t,r,e,n,"find"),t.push(r,e)},function(e){var i=t.getById(r,n);throw i.notFound(),e},"DS: Extract payload of '"+r+"'")}function h(e,t,r,n,i){var a=e.findMany(t,r,n,i),o=c(e,r);return A(a,"DS: Handle Adapter#findMany of "+r).then(function(e){e=o.extract(t,r,e,null,"findMany"),Ember.assert("The response from a findMany must be an Array, not "+Ember.inspect(e),"array"===Ember.typeOf(e)),t.pushMany(r,e)},null,"DS: Extract payload of "+r)}function p(e,t,r,n,i){var a=e.findHasMany(t,r,n,i),o=c(e,i.type);return A(a,"DS: Handle Adapter#findHasMany of "+r+" : "+i.type).then(function(e){e=o.extract(t,i.type,e,null,"findHasMany"),Ember.assert("The response from a findHasMany must be an Array, not "+Ember.inspect(e),"array"===Ember.typeOf(e));var n=t.pushMany(i.type,e);r.updateHasMany(i.key,n)},null,"DS: Extract payload of "+r+" : hasMany "+i.type)}function f(e,t,r,n,i){var a=e.findBelongsTo(t,r,n,i),o=c(e,i.type);return A(a,"DS: Handle Adapter#findBelongsTo of "+r+" : "+i.type).then(function(e){e=o.extract(t,i.type,e,null,"findBelongsTo");var r=t.push(i.type,e);return r.updateBelongsTo(i.key,r),r},null,"DS: Extract payload of "+r+" : "+i.type)}function m(e,t,r,n){var i=e.findAll(t,r,n),a=c(e,r);return A(i,"DS: Handle Adapter#findAll of "+r).then(function(e){return e=a.extract(t,r,e,null,"findAll"),Ember.assert("The response from a findAll must be an Array, not "+Ember.inspect(e),"array"===Ember.typeOf(e)),t.pushMany(r,e),t.didUpdateAll(r),t.all(r)},null,"DS: Extract payload of findAll "+r)}function y(e,t,r,n,i){var a=e.findQuery(t,r,n,i),o=c(e,r);return A(a,"DS: Handle Adapter#findQuery of "+r).then(function(e){return e=o.extract(t,r,e,null,"findQuery"),Ember.assert("The response from a findQuery must be an Array, not "+Ember.inspect(e),"array"===Ember.typeOf(e)),i.load(e),i},null,"DS: Extract payload of findQuery "+r)}function b(e,t,r,n){var i=n.constructor,a=e[r](t,i,n),o=c(e,i);return Ember.assert("Your adapter's '"+r+"' method must return a promise, but it returned "+a,s(a)),a.then(function(e){return e&&(e=o.extract(t,i,e,g(n,"id"),r)),t.didSaveRecord(n,e),n},function(e){throw e instanceof DS.InvalidError?t.recordWasInvalid(n,e.errors):t.recordWasError(n,e),e},"DS: Extract and notify about "+r+" completion of "+n)}var g=Ember.get,v=Ember.set,E=Ember.run.once,R=Ember.isNone,S=Ember.EnumerableUtils.forEach,D=Ember.EnumerableUtils.indexOf,T=Ember.EnumerableUtils.map,A=Ember.RSVP.resolve,F=Ember.copy,C=function(e){return null==e?null:e+""};DS.Store=Ember.Object.extend({init:function(){this.typeMaps={},this.recordArrayManager=DS.RecordArrayManager.create({store:this}),this._relationshipChanges={},this._pendingSave=[]},adapter:"-rest",serialize:function(e,t){return this.serializerFor(e.constructor.typeKey).serialize(e,t)},defaultAdapter:Ember.computed("adapter",function(){var e=g(this,"adapter");return Ember.assert("You tried to set `adapter` property to an instance of `DS.Adapter`, where it should be a name or a factory",!(e instanceof DS.Adapter)),"string"==typeof e&&(e=this.container.lookup("adapter:"+e)||this.container.lookup("adapter:application")||this.container.lookup("adapter:-rest")),DS.Adapter.detect(e)&&(e=e.create({container:this.container})),e}),createRecord:function(e,t){e=this.modelFor(e),t=F(t)||{},R(t.id)&&(t.id=this._generateId(e)),t.id=C(t.id);var r=this.buildRecord(e,t.id);return r.loadedData(),r.setProperties(t),r},_generateId:function(e){var t=this.adapterFor(e);return t&&t.generateIdForRecord?t.generateIdForRecord(this):null},deleteRecord:function(e){e.deleteRecord()},unloadRecord:function(e){e.unloadRecord()},find:function(e,t){return void 0===t?this.findAll(e):"object"===Ember.typeOf(t)?this.findQuery(e,t):this.findById(e,C(t))},findById:function(e,t){e=this.modelFor(e);var r=this.recordForId(e,t),n=this.fetchRecord(r)||A(r,"DS: Store#findById "+e+" with id: "+t);return a(n)},findByIds:function(e,t){var r=this;return o(Ember.RSVP.all(T(t,function(t){return r.findById(e,t)})).then(Ember.A,null,"DS: Store#findByIds of "+e+" complete"))},fetchRecord:function(e){if(R(e))return null;if(e._loadingPromise)return e._loadingPromise;if(!g(e,"isEmpty"))return null;var t=e.constructor,r=g(e,"id"),n=this.adapterFor(t);Ember.assert("You tried to find a record but you have no adapter (for "+t+")",n),Ember.assert("You tried to find a record but your adapter (for "+t+") does not implement 'find'",n.find);var i=l(n,this,t,r);return e.loadingData(i),i},getById:function(e,t){return this.hasRecordForId(e,t)?this.recordForId(e,t):null},reloadRecord:function(e){var t=e.constructor,r=this.adapterFor(t),n=g(e,"id");return Ember.assert("You cannot reload a record without an ID",n),Ember.assert("You tried to reload a record but you have no adapter (for "+t+")",r),Ember.assert("You tried to reload a record but your adapter does not implement `find`",r.find),l(r,this,t,n)},fetchMany:function(e,t,r){if(e.length){var n=Ember.MapWithDefault.create({defaultValue:function(){return Ember.A()}});S(e,function(e){n.get(e.constructor).push(e)}),S(n,function(e,n){var i=n.mapProperty("id"),a=this.adapterFor(e);Ember.assert("You tried to load many records but you have no adapter (for "+e+")",a),Ember.assert("You tried to load many records but your adapter does not implement `findMany`",a.findMany),r.resolve(h(a,this,e,i,t))},this)}},hasRecordForId:function(e,t){return t=C(t),e=this.modelFor(e),!!this.typeMapFor(e).idToRecord[t]},recordForId:function(e,t){e=this.modelFor(e),t=C(t);var r=this.typeMapFor(e).idToRecord[t];return r||(r=this.buildRecord(e,t)),r},findMany:function(e,t,r,n){r=this.modelFor(r),t=Ember.A(t);var i=t.filterProperty("isEmpty",!0),a=this.recordArrayManager.createManyArray(r,t);return S(i,function(e){e.loadingData()}),a.loadingRecordsCount=i.length,i.length?(S(i,function(e){this.recordArrayManager.registerWaitingRecordArray(e,a)},this),this.fetchMany(i,e,n)):(n&&n.resolve(),a.set("isLoaded",!0),Ember.run.once(a,"trigger","didLoad")),a},findHasMany:function(e,t,r,n){var i=this.adapterFor(e.constructor);Ember.assert("You tried to load a hasMany relationship but you have no adapter (for "+e.constructor+")",i),Ember.assert("You tried to load a hasMany relationship from a specified `link` in the original payload but your adapter does not implement `findHasMany`",i.findHasMany);var a=this.recordArrayManager.createManyArray(r.type,Ember.A([]));return n.resolve(p(i,this,e,t,r)),a},findBelongsTo:function(e,t,r,n){var i=this.adapterFor(e.constructor);Ember.assert("You tried to load a belongsTo relationship but you have no adapter (for "+e.constructor+")",i),Ember.assert("You tried to load a belongsTo relationship from a specified `link` in the original payload but your adapter does not implement `findBelongsTo`",i.findBelongsTo),n.resolve(f(i,this,e,t,r))},findQuery:function(e,t){e=this.modelFor(e);var r=this.recordArrayManager.createAdapterPopulatedRecordArray(e,t),n=this.adapterFor(e),i="DS: Store#findQuery "+e,a=Ember.RSVP.defer(i);return Ember.assert("You tried to load a query but you have no adapter (for "+e+")",n),Ember.assert("You tried to load a query but your adapter does not implement `findQuery`",n.findQuery),a.resolve(y(n,this,e,t,r)),o(a.promise)},findAll:function(e){return e=this.modelFor(e),this.fetchAll(e,this.all(e))},fetchAll:function(e,t){var r=this.adapterFor(e),n=this.typeMapFor(e).metadata.since;return v(t,"isUpdating",!0),Ember.assert("You tried to load all records but you have no adapter (for "+e+")",r),Ember.assert("You tried to load all records but your adapter does not implement `findAll`",r.findAll),o(m(r,this,e,n))},didUpdateAll:function(e){var t=this.typeMapFor(e).findAllCache;v(t,"isUpdating",!1)},all:function(e){e=this.modelFor(e);var t=this.typeMapFor(e),r=t.findAllCache;if(r)return r;var n=this.recordArrayManager.createRecordArray(e);return t.findAllCache=n,n},unloadAll:function(e){e=this.modelFor(e);for(var t,r=this.typeMapFor(e),n=r.records.splice(0);t=n.pop();)t.unloadRecord();r.findAllCache=null},filter:function(e,t,r){var n;3===arguments.length?n=this.findQuery(e,t):2===arguments.length&&(r=t),e=this.modelFor(e);var i=this.recordArrayManager.createFilteredRecordArray(e,r);return n=n||A(i),o(n.then(function(){return i},null,"DS: Store#filter of "+e))},recordIsLoaded:function(e,t){return this.hasRecordForId(e,t)?!g(this.recordForId(e,t),"isEmpty"):!1},metadataFor:function(e){return e=this.modelFor(e),this.typeMapFor(e).metadata},dataWasUpdated:function(e,t){this.recordArrayManager.recordDidChange(t)},scheduleSave:function(e,t){e.adapterWillCommit(),this._pendingSave.push([e,t]),E(this,"flushPendingSave")},flushPendingSave:function(){var e=this._pendingSave.slice();this._pendingSave=[],S(e,function(e){var t,r=e[0],n=e[1],i=this.adapterFor(r.constructor);t=g(r,"isNew")?"createRecord":g(r,"isDeleted")?"deleteRecord":"updateRecord",n.resolve(b(i,this,t,r))},this)},didSaveRecord:function(t,r){r&&(r=e(this,t.constructor,r,t),this.updateId(t,r)),t.adapterDidCommit(r)},recordWasInvalid:function(e,t){e.adapterDidInvalidate(t)},recordWasError:function(e){e.adapterDidError()},updateId:function(e,t){var r=g(e,"id"),n=C(t.id);Ember.assert("An adapter cannot assign a new id to a record that already has an id. "+e+" had id: "+r+" and you tried to update it with "+n+". This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.",null===r||n===r),this.typeMapFor(e.constructor).idToRecord[n]=e,v(e,"id",n)},typeMapFor:function(e){var t,r=g(this,"typeMaps"),n=Ember.guidFor(e);return(t=r[n])?t:(t={idToRecord:{},records:[],metadata:{}},r[n]=t,t)},_load:function(e,t,r){var n=C(t.id),i=this.recordForId(e,n);return i.setupData(t,r),this.recordArrayManager.recordDidChange(i),i},modelFor:function(e){var t;if("string"==typeof e){var r=this.container.normalize("model:"+e);if(t=this.container.lookupFactory(r),!t)throw new Ember.Error("No model was found for '"+e+"'");t.typeKey=r.split(":",2)[1]}else t=e;return t.store=this,t},push:function(t,r,n){return Ember.assert("You must include an `id` in a hash passed to `push`",null!=r.id),t=this.modelFor(t),r=e(this,t,r),this._load(t,r,n),this.recordForId(t,r.id)},pushPayload:function(e,t){var r;t?r=this.serializerFor(e):(t=e,r=u(this.container),Ember.assert("You cannot use `store#pushPayload` without a type unless your default serializer defines `pushPayload`",r.pushPayload)),r.pushPayload(this,t)},update:function(e,t){return Ember.assert("You must include an `id` in a hash passed to `update`",null!=t.id),this.push(e,t,!0)},pushMany:function(e,t){return T(t,function(t){return this.push(e,t)},this)},metaForType:function(e,t){e=this.modelFor(e),Ember.merge(this.typeMapFor(e).metadata,t)},buildRecord:function(e,t,r){var n=this.typeMapFor(e),i=n.idToRecord;Ember.assert("The id "+t+" has already been used with another record of type "+e.toString()+".",!t||!i[t]);var a=e._create({id:t,store:this,container:this.container});return r&&a.setupData(r),t&&(i[t]=a),n.records.push(a),a},dematerializeRecord:function(e){var t=e.constructor,r=this.typeMapFor(t),n=g(e,"id");e.updateRecordArrays(),n&&delete r.idToRecord[n];var i=D(r.records,e);r.records.splice(i,1)},addRelationshipChangeFor:function(e,t,r,n,i){var a=e.clientId,o=r?r:r,s=t+n,d=this._relationshipChanges;a in d||(d[a]={}),o in d[a]||(d[a][o]={}),s in d[a][o]||(d[a][o][s]={}),d[a][o][s][i.changeType]=i},removeRelationshipChangeFor:function(e,t,r,n,i){var a=e.clientId,o=r?r.clientId:r,s=this._relationshipChanges,d=t+n;a in s&&o in s[a]&&d in s[a][o]&&delete s[a][o][d][i]},relationshipChangePairsFor:function(e){var t=[];if(!e)return t;var r=this._relationshipChanges[e.clientId];for(var n in r)if(r.hasOwnProperty(n))for(var i in r[n])r[n].hasOwnProperty(i)&&t.push(r[n][i]);return t},adapterFor:function(e){var t,r=this.container;return r&&(t=r.lookup("adapter:"+e.typeKey)||r.lookup("adapter:application")),t||g(this,"defaultAdapter")},serializerFor:function(e){e=this.modelFor(e);var t=this.adapterFor(e);return d(this.container,e.typeKey,t&&t.defaultSerializer)}}),DS.PromiseArray=Ember.ArrayProxy.extend(Ember.PromiseProxyMixin),DS.PromiseObject=Ember.ObjectProxy.extend(Ember.PromiseProxyMixin)}(),function(){function e(t){var r,n={};for(var i in t)r=t[i],n[i]=r&&"object"==typeof r?e(r):r;return n}function t(e,t){for(var r in t)e[r]=t[r];return e}function r(r){var n=e(s);return t(n,r)}function n(e,r,i){e=t(r?Ember.create(r):{},e),e.parentState=r,e.stateName=i;for(var a in e)e.hasOwnProperty(a)&&"parentState"!==a&&"stateName"!==a&&"object"==typeof e[a]&&(e[a]=n(e[a],e,i+"."+a));return e}var i=Ember.get,a=Ember.set,o=function(e,t){t.value===t.originalValue?(delete e._attributes[t.name],e.send("propertyWasReset",t.name)):t.value!==t.oldValue&&e.send("becomeDirty"),e.updateRecordArraysLater()},s={initialState:"uncommitted",isDirty:!0,uncommitted:{didSetProperty:o,propertyWasReset:function(e){var t=!1;for(var r in e._attributes){t=!0;break}t||e.send("rolledBack")},pushedData:Ember.K,becomeDirty:Ember.K,willCommit:function(e){e.transitionTo("inFlight")},reloadRecord:function(e,t){t(i(e,"store").reloadRecord(e))},rolledBack:function(e){e.transitionTo("loaded.saved")},becameInvalid:function(e){e.transitionTo("invalid")},rollback:function(e){e.rollback()}},inFlight:{isSaving:!0,didSetProperty:o,becomeDirty:Ember.K,pushedData:Ember.K,willCommit:Ember.K,didCommit:function(e){var t=i(this,"dirtyType");e.transitionTo("saved"),e.send("invokeLifecycleCallbacks",t)},becameInvalid:function(e){e.transitionTo("invalid"),e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("uncommitted"),e.triggerLater("becameError",e)}},invalid:{isValid:!1,deleteRecord:function(e){e.transitionTo("deleted.uncommitted"),e.clearRelationships()},didSetProperty:function(e,t){i(e,"errors").remove(t.name),o(e,t)},becomeDirty:Ember.K,rolledBack:function(e){i(e,"errors").clear()},becameValid:function(e){e.transitionTo("uncommitted")},invokeLifecycleCallbacks:function(e){e.triggerLater("becameInvalid",e)}}},d=r({dirtyType:"created",isNew:!0});d.uncommitted.rolledBack=function(e){e.transitionTo("deleted.saved")};var u=r({dirtyType:"updated"});d.uncommitted.deleteRecord=function(e){e.clearRelationships(),e.transitionTo("deleted.saved")},d.uncommitted.rollback=function(e){s.uncommitted.rollback.apply(this,arguments),e.transitionTo("deleted.saved")},d.uncommitted.propertyWasReset=Ember.K,u.uncommitted.deleteRecord=function(e){e.transitionTo("deleted.uncommitted"),e.clearRelationships()};var c={isEmpty:!1,isLoading:!1,isLoaded:!1,isDirty:!1,isSaving:!1,isDeleted:!1,isNew:!1,isValid:!0,rolledBack:Ember.K,propertyWasReset:Ember.K,empty:{isEmpty:!0,loadingData:function(e,t){e._loadingPromise=t,e.transitionTo("loading")},loadedData:function(e){e.transitionTo("loaded.created.uncommitted"),e.suspendRelationshipObservers(function(){e.notifyPropertyChange("data")})},pushedData:function(e){e.transitionTo("loaded.saved"),e.triggerLater("didLoad")}},loading:{isLoading:!0,exit:function(e){e._loadingPromise=null},pushedData:function(e){e.transitionTo("loaded.saved"),e.triggerLater("didLoad"),a(e,"isError",!1)},becameError:function(e){e.triggerLater("becameError",e)},notFound:function(e){e.transitionTo("empty")}},loaded:{initialState:"saved",isLoaded:!0,saved:{setup:function(e){var t=e._attributes,r=!1;for(var n in t)if(t.hasOwnProperty(n)){r=!0;break}r&&e.adapterDidDirty()},didSetProperty:o,pushedData:Ember.K,becomeDirty:function(e){e.transitionTo("updated.uncommitted")},willCommit:function(e){e.transitionTo("updated.inFlight")},reloadRecord:function(e,t){t(i(e,"store").reloadRecord(e))},deleteRecord:function(e){e.transitionTo("deleted.uncommitted"),e.clearRelationships()},unloadRecord:function(e){e.clearRelationships(),e.transitionTo("deleted.saved")},didCommit:function(e){e.send("invokeLifecycleCallbacks",i(e,"lastDirtyType"))},notFound:Ember.K},created:d,updated:u},deleted:{initialState:"uncommitted",dirtyType:"deleted",isDeleted:!0,isLoaded:!0,isDirty:!0,setup:function(e){e.updateRecordArrays()},uncommitted:{willCommit:function(e){e.transitionTo("inFlight")},rollback:function(e){e.rollback()},becomeDirty:Ember.K,deleteRecord:Ember.K,rolledBack:function(e){e.transitionTo("loaded.saved")}},inFlight:{isSaving:!0,willCommit:Ember.K,didCommit:function(e){e.transitionTo("saved"),e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("uncommitted"),e.triggerLater("becameError",e)}},saved:{isDirty:!1,setup:function(e){var t=i(e,"store");t.dematerializeRecord(e)},invokeLifecycleCallbacks:function(e){e.triggerLater("didDelete",e),e.triggerLater("didCommit",e)}}},invokeLifecycleCallbacks:function(e,t){"created"===t?e.triggerLater("didCreate",e):e.triggerLater("didUpdate",e),e.triggerLater("didCommit",e)}};c=n(c,null,"root"),DS.RootState=c}(),function(){var e=Ember.get,t=Ember.isEmpty;DS.Errors=Ember.Object.extend(Ember.Enumerable,Ember.Evented,{registerHandlers:function(e,t,r){this.on("becameInvalid",e,t),this.on("becameValid",e,r)},errorsByAttributeName:Ember.reduceComputed("content",{initialValue:function(){return Ember.MapWithDefault.create({defaultValue:function(){return Ember.A()}})},addedItem:function(e,t){return e.get(t.attribute).pushObject(t),e},removedItem:function(e,t){return e.get(t.attribute).removeObject(t),e}}),errorsFor:function(t){return e(this,"errorsByAttributeName").get(t)},messages:Ember.computed.mapBy("content","message"),content:Ember.computed(function(){return Ember.A()}),unknownProperty:function(e){var r=this.errorsFor(e);return t(r)?null:r},nextObject:function(t){return e(this,"content").objectAt(t)},length:Ember.computed.oneWay("content.length").readOnly(),isEmpty:Ember.computed.not("length").readOnly(),add:function(t,r){var n=e(this,"isEmpty");r=this._findOrCreateMessages(t,r),e(this,"content").addObjects(r),this.notifyPropertyChange(t),this.enumerableContentDidChange(),n&&!e(this,"isEmpty")&&this.trigger("becameInvalid")},_findOrCreateMessages:function(e,t){var r=this.errorsFor(e);return Ember.makeArray(t).map(function(t){return r.findBy("message",t)||{attribute:e,message:t}})},remove:function(t){if(!e(this,"isEmpty")){var r=e(this,"content").rejectBy("attribute",t);e(this,"content").setObjects(r),this.notifyPropertyChange(t),this.enumerableContentDidChange(),e(this,"isEmpty")&&this.trigger("becameValid")}},clear:function(){e(this,"isEmpty")||(e(this,"content").clear(),this.enumerableContentDidChange(),this.trigger("becameValid"))},has:function(e){return!t(this.errorsFor(e))}})}(),function(){var e=Ember.get,t=Ember.set,r=Ember.merge,n=Ember.computed("currentState",function(t){return e(e(this,"currentState"),t)}).readOnly();DS.Model=Ember.Object.extend(Ember.Evented,{isEmpty:n,isLoading:n,isLoaded:n,isDirty:n,isSaving:n,isDeleted:n,isNew:n,isValid:n,dirtyType:n,isError:!1,isReloading:!1,clientId:null,id:null,transaction:null,currentState:null,errors:null,serialize:function(t){var r=e(this,"store");return r.serialize(this,t)},toJSON:function(e){var t=DS.JSONSerializer.create({container:this.container});return t.serialize(this,e)},didLoad:Ember.K,didUpdate:Ember.K,didCreate:Ember.K,didDelete:Ember.K,becameInvalid:Ember.K,becameError:Ember.K,data:Ember.computed(function(){return this._data=this._data||{},this._data}).property(),_data:null,init:function(){t(this,"currentState",DS.RootState.empty);var e=DS.Errors.create();e.registerHandlers(this,function(){this.send("becameInvalid")},function(){this.send("becameValid")}),t(this,"errors",e),this._super(),this._setup()},_setup:function(){this._changesToSync={},this._deferredTriggers=[],this._data={},this._attributes={},this._inFlightAttributes={},this._relationships={}},send:function(t,r){var n=e(this,"currentState");return n[t]||this._unhandledEvent(n,t,r),n[t](this,r)},transitionTo:function(r){var n=r.split(".",1),i=e(this,"currentState"),a=i;do a.exit&&a.exit(this),a=a.parentState;while(!a.hasOwnProperty(n));var o,s,d=r.split("."),u=[],c=[];for(o=0,s=d.length;s>o;o++)a=a[d[o]],a.enter&&c.push(a),a.setup&&u.push(a);for(o=0,s=c.length;s>o;o++)c[o].enter(this);for(t(this,"currentState",a),o=0,s=u.length;s>o;o++)u[o].setup(this);this.updateRecordArraysLater()},_unhandledEvent:function(e,t,r){var n="Attempted to handle event `"+t+"` ";throw n+="on "+String(this)+" while in state ",n+=e.stateName+". ",void 0!==r&&(n+="Called with "+Ember.inspect(r)+"."),new Ember.Error(n)
9
+ },withTransaction:function(t){var r=e(this,"transaction");r&&t(r)},loadingData:function(e){this.send("loadingData",e)},loadedData:function(){this.send("loadedData")},notFound:function(){this.send("notFound")},pushedData:function(){this.send("pushedData")},deleteRecord:function(){this.send("deleteRecord")},destroyRecord:function(){return this.deleteRecord(),this.save()},unloadRecord:function(){Ember.assert("You can only unload a loaded, non-dirty record.",!e(this,"isDirty")),this.send("unloadRecord")},clearRelationships:function(){this.eachRelationship(function(e,r){if("belongsTo"===r.kind)t(this,e,null);else if("hasMany"===r.kind){var n=this._relationships[r.name];n&&n.clear()}},this)},updateRecordArrays:function(){this._updatingRecordArraysLater=!1,e(this,"store").dataWasUpdated(this.constructor,this)},changedAttributes:function(){var t,r=e(this,"_data"),n=e(this,"_attributes"),i={};for(t in n)i[t]=[r[t],n[t]];return i},adapterWillCommit:function(){this.send("willCommit")},adapterDidCommit:function(e){t(this,"isError",!1),e?this._data=e:Ember.mixin(this._data,this._inFlightAttributes),this._inFlightAttributes={},this.send("didCommit"),this.updateRecordArraysLater(),e&&this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},adapterDidDirty:function(){this.send("becomeDirty"),this.updateRecordArraysLater()},dataDidChange:Ember.observer(function(){this.reloadHasManys()},"data"),reloadHasManys:function(){var t=e(this.constructor,"relationshipsByName");this.updateRecordArraysLater(),t.forEach(function(e,t){this._data.links&&this._data.links[e]||"hasMany"===t.kind&&this.hasManyDidChange(t.key)},this)},hasManyDidChange:function(e){var r=this._relationships[e];if(r){var n=this._data[e]||[];t(r,"content",Ember.A(n)),t(r,"isLoaded",!0),r.trigger("didLoad")}},updateRecordArraysLater:function(){this._updatingRecordArraysLater||(this._updatingRecordArraysLater=!0,Ember.run.schedule("actions",this,this.updateRecordArrays))},setupData:function(e,t){t?Ember.merge(this._data,e):this._data=e;var r=this._relationships;this.eachRelationship(function(t,n){e.links&&e.links[t]||n.options.async&&(r[t]=null)}),e&&this.pushedData(),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},materializeId:function(e){t(this,"id",e)},materializeAttributes:function(e){Ember.assert("Must pass a hash of attributes to materializeAttributes",!!e),r(this._data,e)},materializeAttribute:function(e,t){this._data[e]=t},updateHasMany:function(e,t){this._data[e]=t,this.hasManyDidChange(e)},updateBelongsTo:function(e,t){this._data[e]=t},rollback:function(){this._attributes={},e(this,"isError")&&(this._inFlightAttributes={},t(this,"isError",!1)),e(this,"isValid")||(this._inFlightAttributes={}),this.send("rolledBack"),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},toStringExtension:function(){return e(this,"id")},suspendRelationshipObservers:function(t,r){var n=e(this.constructor,"relationshipNames").belongsTo,i=this;try{this._suspendedRelationships=!0,Ember._suspendObservers(i,n,null,"belongsToDidChange",function(){Ember._suspendBeforeObservers(i,n,null,"belongsToWillChange",function(){t.call(r||i)})})}finally{this._suspendedRelationships=!1}},save:function(){var e="DS: Model#save "+this,t=Ember.RSVP.defer(e);return this.get("store").scheduleSave(this,t),this._inFlightAttributes=this._attributes,this._attributes={},DS.PromiseObject.create({promise:t.promise})},reload:function(){t(this,"isReloading",!0);var e=this,r="DS: Model#reload of "+this,n=new Ember.RSVP.Promise(function(t){e.send("reloadRecord",t)},r).then(function(){return e.set("isReloading",!1),e.set("isError",!1),e},function(t){throw e.set("isError",!0),t},"DS: Model#reload complete, update flags");return DS.PromiseObject.create({promise:n})},adapterDidUpdateAttribute:function(e,t){void 0!==t?(this._data[e]=t,this.notifyPropertyChange(e)):this._data[e]=this._inFlightAttributes[e],this.updateRecordArraysLater()},adapterDidInvalidate:function(t){function r(e){t[e]&&n.add(e,t[e])}var n=e(this,"errors");this.eachAttribute(r),this.eachRelationship(r)},adapterDidError:function(){this.send("becameError"),t(this,"isError",!0)},trigger:function(e){Ember.tryInvoke(this,e,[].slice.call(arguments,1)),this._super.apply(this,arguments)},triggerLater:function(){1===this._deferredTriggers.push(arguments)&&Ember.run.schedule("actions",this,"_triggerDeferredTriggers")},_triggerDeferredTriggers:function(){for(var e=0,t=this._deferredTriggers.length;t>e;e++)this.trigger.apply(this,this._deferredTriggers[e]);this._deferredTriggers.length=0}}),DS.Model.reopenClass({_create:DS.Model.create,create:function(){throw new Ember.Error("You should not call `create` on a model. Instead, call `store.createRecord` with the attributes you would like to set.")}})}(),function(){function e(e,t){return"function"==typeof t.defaultValue?t.defaultValue():t.defaultValue}function t(e,t){return e._attributes.hasOwnProperty(t)||e._inFlightAttributes.hasOwnProperty(t)||e._data.hasOwnProperty(t)}function r(e,t){return e._attributes.hasOwnProperty(t)?e._attributes[t]:e._inFlightAttributes.hasOwnProperty(t)?e._inFlightAttributes[t]:e._data[t]}var n=Ember.get;DS.Model.reopenClass({attributes:Ember.computed(function(){var e=Ember.Map.create();return this.eachComputedProperty(function(t,r){r.isAttribute&&(Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from "+this.toString(),"id"!==t),r.name=t,e.set(t,r))}),e}),transformedAttributes:Ember.computed(function(){var e=Ember.Map.create();return this.eachAttribute(function(t,r){r.type&&e.set(t,r.type)}),e}),eachAttribute:function(e,t){n(this,"attributes").forEach(function(r,n){e.call(t,r,n)},t)},eachTransformedAttribute:function(e,t){n(this,"transformedAttributes").forEach(function(r,n){e.call(t,r,n)})}}),DS.Model.reopen({eachAttribute:function(e,t){this.constructor.eachAttribute(e,t)}}),DS.attr=function(n,i){i=i||{};var a={type:n,isAttribute:!0,options:i};return Ember.computed(function(n,a){if(arguments.length>1){Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from "+this.constructor.toString(),"id"!==n);var o=this._attributes[n]||this._inFlightAttributes[n]||this._data[n];return this.send("didSetProperty",{name:n,oldValue:o,originalValue:this._data[n],value:a}),this._attributes[n]=a,a}return t(this,n)?r(this,n):e(this,i,n)}).property("data").meta(a)}}(),function(){var e=DS.AttributeChange=function(e){this.record=e.record,this.store=e.store,this.name=e.name,this.value=e.value,this.oldValue=e.oldValue};e.createChange=function(t){return new e(t)},e.prototype={sync:function(){this.value!==this.oldValue&&(this.record.send("becomeDirty"),this.record.updateRecordArraysLater()),this.destroy()},destroy:function(){delete this.record._changesToSync[this.name]}}}(),function(){function e(e){return"object"==typeof e&&(!e.then||"function"!=typeof e.then)}var t=Ember.get,r=Ember.set,n=Ember.EnumerableUtils.forEach;DS.RelationshipChange=function(e){this.parentRecord=e.parentRecord,this.childRecord=e.childRecord,this.firstRecord=e.firstRecord,this.firstRecordKind=e.firstRecordKind,this.firstRecordName=e.firstRecordName,this.secondRecord=e.secondRecord,this.secondRecordKind=e.secondRecordKind,this.secondRecordName=e.secondRecordName,this.changeType=e.changeType,this.store=e.store,this.committed={}},DS.RelationshipChangeAdd=function(e){DS.RelationshipChange.call(this,e)},DS.RelationshipChangeRemove=function(e){DS.RelationshipChange.call(this,e)},DS.RelationshipChange.create=function(e){return new DS.RelationshipChange(e)},DS.RelationshipChangeAdd.create=function(e){return new DS.RelationshipChangeAdd(e)},DS.RelationshipChangeRemove.create=function(e){return new DS.RelationshipChangeRemove(e)},DS.OneToManyChange={},DS.OneToNoneChange={},DS.ManyToNoneChange={},DS.OneToOneChange={},DS.ManyToManyChange={},DS.RelationshipChange._createChange=function(e){return"add"===e.changeType?DS.RelationshipChangeAdd.create(e):"remove"===e.changeType?DS.RelationshipChangeRemove.create(e):void 0},DS.RelationshipChange.determineRelationshipType=function(e,t){var r,n,i=t.key,a=t.kind,o=e.inverseFor(i);return o&&(r=o.name,n=o.kind),o?"belongsTo"===n?"belongsTo"===a?"oneToOne":"manyToOne":"belongsTo"===a?"oneToMany":"manyToMany":"belongsTo"===a?"oneToNone":"manyToNone"},DS.RelationshipChange.createChange=function(e,t,r,n){var i,a=e.constructor;return i=DS.RelationshipChange.determineRelationshipType(a,n),"oneToMany"===i?DS.OneToManyChange.createChange(e,t,r,n):"manyToOne"===i?DS.OneToManyChange.createChange(t,e,r,n):"oneToNone"===i?DS.OneToNoneChange.createChange(e,t,r,n):"manyToNone"===i?DS.ManyToNoneChange.createChange(e,t,r,n):"oneToOne"===i?DS.OneToOneChange.createChange(e,t,r,n):"manyToMany"===i?DS.ManyToManyChange.createChange(e,t,r,n):void 0},DS.OneToNoneChange.createChange=function(e,t,r,n){var i=n.key,a=DS.RelationshipChange._createChange({parentRecord:t,childRecord:e,firstRecord:e,store:r,changeType:n.changeType,firstRecordName:i,firstRecordKind:"belongsTo"});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.ManyToNoneChange.createChange=function(e,t,r,n){var i=n.key,a=DS.RelationshipChange._createChange({parentRecord:e,childRecord:t,secondRecord:e,store:r,changeType:n.changeType,secondRecordName:n.key,secondRecordKind:"hasMany"});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.ManyToManyChange.createChange=function(e,t,r,n){var i=n.key,a=DS.RelationshipChange._createChange({parentRecord:t,childRecord:e,firstRecord:e,secondRecord:t,firstRecordKind:"hasMany",secondRecordKind:"hasMany",store:r,changeType:n.changeType,firstRecordName:i});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.OneToOneChange.createChange=function(e,t,r,n){var i;n.parentType?i=n.parentType.inverseFor(n.key).name:n.key?i=n.key:Ember.assert("You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent",!1);var a=DS.RelationshipChange._createChange({parentRecord:t,childRecord:e,firstRecord:e,secondRecord:t,firstRecordKind:"belongsTo",secondRecordKind:"belongsTo",store:r,changeType:n.changeType,firstRecordName:i});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.OneToOneChange.maintainInvariant=function(e,r,n,i){if("add"===e.changeType&&r.recordIsMaterialized(n)){var a=t(n,i);if(a){var o=DS.OneToOneChange.createChange(n,a,r,{parentType:e.parentType,hasManyName:e.hasManyName,changeType:"remove",key:e.key});r.addRelationshipChangeFor(n,i,e.parentRecord,null,o),o.sync()}}},DS.OneToManyChange.createChange=function(e,t,r,n){var i;n.parentType?(i=n.parentType.inverseFor(n.key).name,DS.OneToManyChange.maintainInvariant(n,r,e,i)):n.key?i=n.key:Ember.assert("You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent",!1);var a=DS.RelationshipChange._createChange({parentRecord:t,childRecord:e,firstRecord:e,secondRecord:t,firstRecordKind:"belongsTo",secondRecordKind:"hasMany",store:r,changeType:n.changeType,firstRecordName:i});return r.addRelationshipChangeFor(e,i,t,a.getSecondRecordName(),a),a},DS.OneToManyChange.maintainInvariant=function(e,r,n,i){if("add"===e.changeType&&n){var a=t(n,i);if(a){var o=DS.OneToManyChange.createChange(n,a,r,{parentType:e.parentType,hasManyName:e.hasManyName,changeType:"remove",key:e.key});r.addRelationshipChangeFor(n,i,e.parentRecord,o.getSecondRecordName(),o),o.sync()}}},DS.RelationshipChange.prototype={getSecondRecordName:function(){var e,t=this.secondRecordName;if(!t){if(e=this.secondRecord,!e)return;var r=this.firstRecord.constructor,n=r.inverseFor(this.firstRecordName);this.secondRecordName=n.name}return this.secondRecordName},getFirstRecordName:function(){var e=this.firstRecordName;return e},destroy:function(){var e=this.childRecord,t=this.getFirstRecordName(),r=this.getSecondRecordName(),n=this.store;n.removeRelationshipChangeFor(e,t,this.parentRecord,r,this.changeType)},getSecondRecord:function(){return this.secondRecord},getFirstRecord:function(){return this.firstRecord},coalesce:function(){var e=this.store.relationshipChangePairsFor(this.firstRecord);n(e,function(e){var t=e.add,r=e.remove;t&&r&&(t.destroy(),r.destroy())})}},DS.RelationshipChangeAdd.prototype=Ember.create(DS.RelationshipChange.create({})),DS.RelationshipChangeRemove.prototype=Ember.create(DS.RelationshipChange.create({})),DS.RelationshipChangeAdd.prototype.changeType="add",DS.RelationshipChangeAdd.prototype.sync=function(){var n=this.getSecondRecordName(),i=this.getFirstRecordName(),a=this.getFirstRecord(),o=this.getSecondRecord();o instanceof DS.Model&&a instanceof DS.Model&&("belongsTo"===this.secondRecordKind?o.suspendRelationshipObservers(function(){r(o,n,a)}):"hasMany"===this.secondRecordKind&&o.suspendRelationshipObservers(function(){var r=t(o,n);e(r)&&r.addObject(a)})),a instanceof DS.Model&&o instanceof DS.Model&&t(a,i)!==o&&("belongsTo"===this.firstRecordKind?a.suspendRelationshipObservers(function(){r(a,i,o)}):"hasMany"===this.firstRecordKind&&a.suspendRelationshipObservers(function(){var r=t(a,i);e(r)&&r.addObject(o)})),this.coalesce()},DS.RelationshipChangeRemove.prototype.changeType="remove",DS.RelationshipChangeRemove.prototype.sync=function(){var n=this.getSecondRecordName(),i=this.getFirstRecordName(),a=this.getFirstRecord(),o=this.getSecondRecord();o instanceof DS.Model&&a instanceof DS.Model&&("belongsTo"===this.secondRecordKind?o.suspendRelationshipObservers(function(){r(o,n,null)}):"hasMany"===this.secondRecordKind&&o.suspendRelationshipObservers(function(){var r=t(o,n);e(r)&&r.removeObject(a)})),a instanceof DS.Model&&t(a,i)&&("belongsTo"===this.firstRecordKind?a.suspendRelationshipObservers(function(){r(a,i,null)}):"hasMany"===this.firstRecordKind&&a.suspendRelationshipObservers(function(){var r=t(a,i);e(r)&&r.removeObject(o)})),this.coalesce()}}(),function(){function e(e,n,i){return Ember.computed(function(n,a){var o=t(this,"data"),s=t(this,"store"),d="DS: Async belongsTo "+this+" : "+n;if(2===arguments.length)return Ember.assert("You can only add a '"+e+"' record to this relationship",!a||a instanceof s.modelFor(e)),void 0===a?null:DS.PromiseObject.create({promise:Ember.RSVP.resolve(a,d)});var u=o.links&&o.links[n],c=o[n];if(r(c)){if(u){var l=Ember.RSVP.defer("DS: Async belongsTo (link) "+this+" : "+n);return s.findBelongsTo(this,u,i,l),DS.PromiseObject.create({promise:l.promise})}return null}var h=s.fetchRecord(c)||Ember.RSVP.resolve(c,d);return DS.PromiseObject.create({promise:h})}).property("data").meta(i)}var t=Ember.get,r=(Ember.set,Ember.isNone);DS.belongsTo=function(n,i){"object"==typeof n?(i=n,n=void 0):Ember.assert("The first argument DS.belongsTo must be a model type or string, like DS.belongsTo(App.Person)",!!n&&("string"==typeof n||DS.Model.detect(n))),i=i||{};var a={type:n,isRelationship:!0,options:i,kind:"belongsTo"};return i.async?e(n,i,a):Ember.computed(function(e,i){var a,o,s=t(this,"data"),d=t(this,"store");return o="string"==typeof n?d.modelFor(n):n,2===arguments.length?(Ember.assert("You can only add a '"+n+"' record to this relationship",!i||i instanceof o),void 0===i?null:i):(a=s[e],r(a)?null:(d.fetchRecord(a),a))}).property("data").meta(a)},DS.Model.reopen({belongsToWillChange:Ember.beforeObserver(function(e,r){if(t(e,"isLoaded")){var n=t(e,r);if(n){var i=t(e,"store"),a=DS.RelationshipChange.createChange(e,n,i,{key:r,kind:"belongsTo",changeType:"remove"});a.sync(),this._changesToSync[r]=a}}}),belongsToDidChange:Ember.immediateObserver(function(e,r){if(t(e,"isLoaded")){var n=t(e,r);if(n){var i=t(e,"store"),a=DS.RelationshipChange.createChange(e,n,i,{key:r,kind:"belongsTo",changeType:"add"});a.sync()}}delete this._changesToSync[r]})})}(),function(){function e(e,r,n){return Ember.computed(function(e){var a=this._relationships[e],o="DS: Async hasMany "+this+" : "+e;if(!a){var s=Ember.RSVP.defer(o);a=t(this,e,r,function(t,r){var a,o=r.links&&r.links[e];return a=o?t.findHasMany(this,o,n,s):t.findMany(this,r[e],n.type,s),i(a,"promise",s.promise),a})}var d=a.get("promise").then(function(){return a},null,"DS: Async hasMany records received");return DS.PromiseArray.create({promise:d})}).property("data").meta(n)}function t(e,t,r,i){var o=e._relationships;if(o[t])return o[t];var s=n(e,"data"),d=n(e,"store"),u=o[t]=i.call(e,d,s);return a(u,{owner:e,name:t,isPolymorphic:r.polymorphic})}function r(r,n){n=n||{};var i={type:r,isRelationship:!0,options:n,kind:"hasMany"};return n.async?e(r,n,i):Ember.computed(function(e){return t(this,e,n,function(t,r){var n=r[e];return Ember.assert("You looked up the '"+e+"' relationship on '"+this+"' but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)",Ember.A(n).everyProperty("isEmpty",!1)),t.findMany(this,r[e],i.type)})}).property("data").meta(i)}var n=Ember.get,i=Ember.set,a=Ember.setProperties;DS.hasMany=function(e,t){return"object"==typeof e&&(t=e,e=void 0),r(e,t)}}(),function(){{var e=Ember.get;Ember.set}DS.Model.reopen({didDefineProperty:function(e,t,r){if(r instanceof Ember.Descriptor){var n=r.meta();n.isRelationship&&"belongsTo"===n.kind&&(Ember.addObserver(e,t,null,"belongsToDidChange"),Ember.addBeforeObserver(e,t,null,"belongsToWillChange")),n.parentType=e.constructor}}}),DS.Model.reopenClass({typeForRelationship:function(t){var r=e(this,"relationshipsByName").get(t);return r&&r.type},inverseFor:function(t){function r(t,n,i){i=i||[];var a=e(n,"relationships");if(a){var o=a.get(t);return o&&i.push.apply(i,a.get(t)),t.superclass&&r(t.superclass,n,i),i}}var n=this.typeForRelationship(t);if(!n)return null;var i=this.metaForProperty(t).options;if(null===i.inverse)return null;var a,o;if(i.inverse)a=i.inverse,o=Ember.get(n,"relationshipsByName").get(a).kind;else{var s=r(this,n);if(0===s.length)return null;Ember.assert("You defined the '"+t+"' relationship on "+this+", but multiple possible inverse relationships of type "+this+" were found on "+n+". Look at http://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses",1===s.length),a=s[0].name,o=s[0].kind}return{type:n,name:a,kind:o}},relationships:Ember.computed(function(){var e=new Ember.MapWithDefault({defaultValue:function(){return[]}});return this.eachComputedProperty(function(t,r){if(r.isRelationship){"string"==typeof r.type&&(r.type=this.store.modelFor(r.type));var n=e.get(r.type);n.push({name:t,kind:r.kind})}}),e}),relationshipNames:Ember.computed(function(){var e={hasMany:[],belongsTo:[]};return this.eachComputedProperty(function(t,r){r.isRelationship&&e[r.kind].push(t)}),e}),relatedTypes:Ember.computed(function(){var t,r=Ember.A();return this.eachComputedProperty(function(n,i){i.isRelationship&&(t=i.type,"string"==typeof t&&(t=e(this,t,!1)||this.store.modelFor(t)),Ember.assert("You specified a hasMany ("+i.type+") on "+i.parentType+" but "+i.type+" was not found.",t),r.contains(t)||(Ember.assert("Trying to sideload "+n+" on "+this.toString()+" but the type doesn't exist.",!!t),r.push(t)))}),r}),relationshipsByName:Ember.computed(function(){var e,t=Ember.Map.create();return this.eachComputedProperty(function(r,n){n.isRelationship&&(n.key=r,e=n.type,e||"hasMany"!==n.kind?e||(e=r):e=Ember.String.singularize(r),"string"==typeof e&&(n.type=this.store.modelFor(e)),t.set(r,n))}),t}),fields:Ember.computed(function(){var e=Ember.Map.create();return this.eachComputedProperty(function(t,r){r.isRelationship?e.set(t,r.kind):r.isAttribute&&e.set(t,"attribute")}),e}),eachRelationship:function(t,r){e(this,"relationshipsByName").forEach(function(e,n){t.call(r,e,n)})},eachRelatedType:function(t,r){e(this,"relatedTypes").forEach(function(e){t.call(r,e)})}}),DS.Model.reopen({eachRelationship:function(e,t){this.constructor.eachRelationship(e,t)}})}(),function(){var e=Ember.get,t=(Ember.set,Ember.EnumerableUtils.forEach);DS.RecordArrayManager=Ember.Object.extend({init:function(){this.filteredRecordArrays=Ember.MapWithDefault.create({defaultValue:function(){return[]}}),this.changedRecords=[]},recordDidChange:function(e){1===this.changedRecords.push(e)&&Ember.run.schedule("actions",this,this.updateRecordArrays)},recordArraysForRecord:function(e){return e._recordArrays=e._recordArrays||Ember.OrderedSet.create(),e._recordArrays},updateRecordArrays:function(){t(this.changedRecords,function(t){e(t,"isDeleted")?this._recordWasDeleted(t):this._recordWasChanged(t)},this),this.changedRecords.length=0},_recordWasDeleted:function(e){var r=e._recordArrays;r&&t(r,function(t){t.removeRecord(e)})},_recordWasChanged:function(r){var n,i=r.constructor,a=this.filteredRecordArrays.get(i);t(a,function(t){n=e(t,"filterFunction"),this.updateRecordArray(t,n,i,r)},this);var o=r._loadingRecordArrays;if(o){for(var s=0,d=o.length;d>s;s++)o[s].loadedRecord();r._loadingRecordArrays=[]}},updateRecordArray:function(e,t,r,n){var i;i=t?t(n):!0;var a=this.recordArraysForRecord(n);i?(a.add(e),e.addRecord(n)):i||(a.remove(e),e.removeRecord(n))},updateFilter:function(t,r,n){for(var i,a=this.store.typeMapFor(r),o=a.records,s=0,d=o.length;d>s;s++)i=o[s],e(i,"isDeleted")||e(i,"isEmpty")||this.updateRecordArray(t,n,r,i)},createManyArray:function(e,r){var n=DS.ManyArray.create({type:e,content:r,store:this.store});return t(r,function(e){var t=this.recordArraysForRecord(e);t.add(n)},this),n},createRecordArray:function(e){var t=DS.RecordArray.create({type:e,content:Ember.A(),store:this.store,isLoaded:!0});return this.registerFilteredRecordArray(t,e),t},createFilteredRecordArray:function(e,t){var r=DS.FilteredRecordArray.create({type:e,content:Ember.A(),store:this.store,manager:this,filterFunction:t});return this.registerFilteredRecordArray(r,e,t),r},createAdapterPopulatedRecordArray:function(e,t){return DS.AdapterPopulatedRecordArray.create({type:e,query:t,content:Ember.A(),store:this.store})},registerFilteredRecordArray:function(e,t,r){var n=this.filteredRecordArrays.get(t);n.push(e),this.updateFilter(e,t,r)},registerWaitingRecordArray:function(e,t){var r=e._loadingRecordArrays||[];r.push(t),e._loadingRecordArrays=r}})}(),function(){var e=Ember.get,t=(Ember.set,Ember.ArrayPolyfills.map),r=["description","fileName","lineNumber","message","name","number","stack"];DS.InvalidError=function(e){var t=Error.prototype.constructor.call(this,"The backend rejected the commit because it was invalid: "+Ember.inspect(e));this.errors=e;for(var n=0,i=r.length;i>n;n++)this[r[n]]=t[r[n]]},DS.InvalidError.prototype=Ember.create(Error.prototype),DS.Adapter=Ember.Object.extend({find:Ember.required(Function),findAll:null,findQuery:null,generateIdForRecord:null,serialize:function(t,r){return e(t,"store").serializerFor(t.constructor.typeKey).serialize(t,r)},createRecord:Ember.required(Function),updateRecord:Ember.required(Function),deleteRecord:Ember.required(Function),findMany:function(e,r,n){var i=t.call(n,function(t){return this.find(e,r,t)},this);return Ember.RSVP.all(i)}})}(),function(){var e=Ember.get,t=Ember.String.fmt,r=Ember.EnumerableUtils.indexOf,n=0;DS.FixtureAdapter=DS.Adapter.extend({serializer:null,simulateRemoteResponse:!0,latency:50,fixturesForType:function(e){if(e.FIXTURES){var r=Ember.A(e.FIXTURES);return r.map(function(e){var r=typeof e.id;if("number"!==r&&"string"!==r)throw new Error(t("the id property must be defined as a number or string for fixture %@",[e]));return e.id=e.id+"",e})}return null},queryFixtures:function(){Ember.assert("Not implemented: You must override the DS.FixtureAdapter::queryFixtures method to support querying the fixture store.")},updateFixtures:function(e,t){e.FIXTURES||(e.FIXTURES=[]);var r=e.FIXTURES;this.deleteLoadedFixture(e,t),r.push(t)},mockJSON:function(e,t,r){return e.serializerFor(t).serialize(r,{includeId:!0})},generateIdForRecord:function(){return"fixture-"+n++},find:function(e,t,r){var n,i=this.fixturesForType(t);return Ember.assert("Unable to find fixtures for model type "+t.toString(),i),i&&(n=Ember.A(i).findProperty("id",r)),n?this.simulateRemoteCall(function(){return n},this):void 0},findMany:function(e,t,n){var i=this.fixturesForType(t);return Ember.assert("Unable to find fixtures for model type "+t.toString(),i),i&&(i=i.filter(function(e){return-1!==r(n,e.id)})),i?this.simulateRemoteCall(function(){return i},this):void 0},findAll:function(e,t){var r=this.fixturesForType(t);return Ember.assert("Unable to find fixtures for model type "+t.toString(),r),this.simulateRemoteCall(function(){return r},this)},findQuery:function(e,t,r){var n=this.fixturesForType(t);return Ember.assert("Unable to find fixtures for model type "+t.toString(),n),n=this.queryFixtures(n,r,t),n?this.simulateRemoteCall(function(){return n},this):void 0},createRecord:function(e,t,r){var n=this.mockJSON(e,t,r);return this.updateFixtures(t,n),this.simulateRemoteCall(function(){return n},this)},updateRecord:function(e,t,r){var n=this.mockJSON(e,t,r);return this.updateFixtures(t,n),this.simulateRemoteCall(function(){return n},this)},deleteRecord:function(e,t,r){var n=this.mockJSON(e,t,r);return this.deleteLoadedFixture(t,n),this.simulateRemoteCall(function(){return null})},deleteLoadedFixture:function(e,t){var n=this.findExistingFixture(e,t);if(n){var i=r(e.FIXTURES,n);return e.FIXTURES.splice(i,1),!0}},findExistingFixture:function(t,r){var n=this.fixturesForType(t),i=e(r,"id");return this.findFixtureById(n,i)},findFixtureById:function(t,r){return Ember.A(t).find(function(t){return""+e(t,"id")==""+r?!0:!1})},simulateRemoteCall:function(t,r){var n=this;return new Ember.RSVP.Promise(function(i){e(n,"simulateRemoteResponse")?Ember.run.later(function(){i(t.call(r))},e(n,"latency")):Ember.run.schedule("actions",null,function(){i(t.call(r))})},"DS: FixtureAdapter#simulateRemoteCall")}})}(),function(){function e(e){return null==e?null:e+""}var t=Ember.get,r=(Ember.set,Ember.ArrayPolyfills.forEach),n=Ember.ArrayPolyfills.map;DS.RESTSerializer=DS.JSONSerializer.extend({normalize:function(e,t,r){return this.normalizeId(t),this.normalizeAttributes(e,t),this.normalizeRelationships(e,t),this.normalizeUsingDeclaredMapping(e,t),this.normalizeHash&&this.normalizeHash[r]&&this.normalizeHash[r](t),this._super(e,t,r)},normalizePayload:function(e,t){return t},normalizeId:function(e){var r=t(this,"primaryKey");"id"!==r&&(e.id=e[r],delete e[r])},normalizeUsingDeclaredMapping:function(e,r){var n,i,a=t(this,"attrs");if(a)for(i in a)n=a[i],n&&n.key&&(n=n.key),"string"==typeof n&&(r[i]=r[n],delete r[n])},normalizeAttributes:function(e,t){var r;this.keyForAttribute&&e.eachAttribute(function(e){r=this.keyForAttribute(e),e!==r&&(t[e]=t[r],delete t[r])},this)},normalizeRelationships:function(e,t){var r;this.keyForRelationship&&e.eachRelationship(function(e,n){r=this.keyForRelationship(e,n.kind),e!==r&&(t[e]=t[r],delete t[r])},this)},extractSingle:function(t,n,i,a){i=this.normalizePayload(n,i);var o,s=n.typeKey;for(var d in i){var u=this.typeForRoot(d),c=t.modelFor(u),l=c.typeKey===s;l&&"array"!==Ember.typeOf(i[d])?o=this.normalize(n,i[d],d):r.call(i[d],function(r){var n=this.typeForRoot(d),i=t.modelFor(n),s=t.serializerFor(i);r=s.normalize(i,r,d);var u=l&&!a&&!o,c=l&&e(r.id)===a;u||c?o=r:t.push(n,r)},this)}return o},extractArray:function(e,t,r){r=this.normalizePayload(t,r);var i,a=t.typeKey;for(var o in r){var s=o,d=!1;"_"===o.charAt(0)&&(d=!0,s=o.substr(1));var u=this.typeForRoot(s),c=e.modelFor(u),l=e.serializerFor(c),h=!d&&c.typeKey===a,p=n.call(r[o],function(e){return l.normalize(c,e,o)},this);h?i=p:e.pushMany(u,p)}return i},pushPayload:function(e,t){t=this.normalizePayload(null,t);for(var r in t){var i=this.typeForRoot(r),a=e.modelFor(i),o=n.call(Ember.makeArray(t[r]),function(e){return this.normalize(a,e,r)},this);e.pushMany(i,o)}},typeForRoot:function(e){return Ember.String.singularize(e)},serialize:function(){return this._super.apply(this,arguments)},serializeIntoHash:function(e,t,r,n){var i=Ember.String.camelize(t.typeKey);e[i]=this.serialize(r,n)},serializePolymorphicType:function(e,r,n){var i=n.key,a=t(e,i);i=this.keyForAttribute?this.keyForAttribute(i):i,r[i+"Type"]=Ember.String.camelize(a.constructor.typeKey)}})}(),function(){var e=Ember.get,t=(Ember.set,Ember.ArrayPolyfills.forEach);DS.RESTAdapter=DS.Adapter.extend({defaultSerializer:"-rest",find:function(e,t,r){return this.ajax(this.buildURL(t.typeKey,r),"GET")},findAll:function(e,t,r){var n;return r&&(n={since:r}),this.ajax(this.buildURL(t.typeKey),"GET",{data:n})},findQuery:function(e,t,r){return this.ajax(this.buildURL(t.typeKey),"GET",{data:r})},findMany:function(e,t,r){return this.ajax(this.buildURL(t.typeKey),"GET",{data:{ids:r}})},findHasMany:function(t,r,n){var i=e(this,"host"),a=e(r,"id"),o=r.constructor.typeKey;return i&&"/"===n.charAt(0)&&"/"!==n.charAt(1)&&(n=i+n),this.ajax(this.urlPrefix(n,this.buildURL(o,a)),"GET")},findBelongsTo:function(t,r,n){var i=e(r,"id"),a=r.constructor.typeKey;return this.ajax(this.urlPrefix(n,this.buildURL(a,i)),"GET")},createRecord:function(e,t,r){var n={},i=e.serializerFor(t.typeKey);return i.serializeIntoHash(n,t,r,{includeId:!0}),this.ajax(this.buildURL(t.typeKey),"POST",{data:n})},updateRecord:function(t,r,n){var i={},a=t.serializerFor(r.typeKey);a.serializeIntoHash(i,r,n);var o=e(n,"id");return this.ajax(this.buildURL(r.typeKey,o),"PUT",{data:i})},deleteRecord:function(t,r,n){var i=e(n,"id");return this.ajax(this.buildURL(r.typeKey,i),"DELETE")},buildURL:function(t,r){var n=[],i=e(this,"host"),a=this.urlPrefix();return t&&n.push(this.pathForType(t)),r&&n.push(r),a&&n.unshift(a),n=n.join("/"),!i&&n&&(n="/"+n),n},urlPrefix:function(t,r){var n=e(this,"host"),i=e(this,"namespace"),a=[];return t?"/"===t.charAt(0)?n&&(t=t.slice(1),a.push(n)):/^http(s)?:\/\//.test(t)||a.push(r):(n&&a.push(n),i&&a.push(i)),t&&a.push(t),a.join("/")},pathForType:function(e){var t=Ember.String.camelize(e);return Ember.String.pluralize(t)},ajaxError:function(e){return e&&(e.then=null),e},ajax:function(e,t,r){var n=this;return new Ember.RSVP.Promise(function(i,a){r=n.ajaxOptions(e,t,r),r.success=function(e){Ember.run(null,i,e)},r.error=function(e){Ember.run(null,a,n.ajaxError(e))},Ember.$.ajax(r)},"DS: RestAdapter#ajax "+t+" to "+e)},ajaxOptions:function(e,r,n){if(n=n||{},n.url=e,n.type=r,n.dataType="json",n.context=this,n.data&&"GET"!==r&&(n.contentType="application/json; charset=utf-8",n.data=JSON.stringify(n.data)),void 0!==this.headers){var i=this.headers;n.beforeSend=function(e){t.call(Ember.keys(i),function(t){e.setRequestHeader(t,i[t])})}}return n}})}(),function(){DS.Model.reopen({_debugInfo:function(){var e=["id"],t={belongsTo:[],hasMany:[]},r=[];this.eachAttribute(function(t){e.push(t)},this),this.eachRelationship(function(e,n){t[n.kind].push(e),r.push(e)});var n=[{name:"Attributes",properties:e,expand:!0},{name:"Belongs To",properties:t.belongsTo,expand:!0},{name:"Has Many",properties:t.hasMany,expand:!0},{name:"Flags",properties:["isLoaded","isDirty","isSaving","isDeleted","isError","isNew","isValid"]}];return{propertyInfo:{includeOtherProperties:!0,groups:n,expensiveProperties:r}}}})}(),function(){Ember.String.pluralize=function(e){return Ember.Inflector.inflector.pluralize(e)},Ember.String.singularize=function(e){return Ember.Inflector.inflector.singularize(e)}}(),function(){function e(e,t){for(var r=0,n=t.length;n>r;r++)e.uncountable[t[r].toLowerCase()]=!0}function t(e,t){for(var r,n=0,i=t.length;i>n;n++)r=t[n],e.irregular[r[0].toLowerCase()]=r[1],e.irregularInverse[r[1].toLowerCase()]=r[0]}function r(r){r=r||{},r.uncountable=r.uncountable||{},r.irregularPairs=r.irregularPairs||{};var n=this.rules={plurals:r.plurals||[],singular:r.singular||[],irregular:{},irregularInverse:{},uncountable:{}};e(n,r.uncountable),t(n,r.irregularPairs)}var n=/^\s*$/;r.prototype={plural:function(e,t){this.rules.plurals.push([e,t.toLowerCase()])},singular:function(e,t){this.rules.singular.push([e,t.toLowerCase()])},uncountable:function(t){e(this.rules,[t.toLowerCase()])},irregular:function(e,r){t(this.rules,[[e,r]])},pluralize:function(e){return this.inflect(e,this.rules.plurals,this.rules.irregular)},singularize:function(e){return this.inflect(e,this.rules.singular,this.rules.irregularInverse)},inflect:function(e,t,r){var i,a,o,s,d,u,c,l;if(d=n.test(e))return e;if(s=e.toLowerCase(),u=this.rules.uncountable[s])return e;if(c=r&&r[s])return c;for(var h=t.length,p=0;h>p&&(i=t[h-1],l=i[0],!l.test(e));h--);return i=i||[],l=i[0],a=i[1],o=e.replace(l,a)}},Ember.Inflector=r}(),function(){Ember.Inflector.defaultRules={plurals:[[/$/,"s"],[/s$/i,"s"],[/^(ax|test)is$/i,"$1es"],[/(octop|vir)us$/i,"$1i"],[/(octop|vir)i$/i,"$1i"],[/(alias|status)$/i,"$1es"],[/(bu)s$/i,"$1ses"],[/(buffal|tomat)o$/i,"$1oes"],[/([ti])um$/i,"$1a"],[/([ti])a$/i,"$1a"],[/sis$/i,"ses"],[/(?:([^f])fe|([lr])f)$/i,"$1$2ves"],[/(hive)$/i,"$1s"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/(x|ch|ss|sh)$/i,"$1es"],[/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"],[/^(m|l)ouse$/i,"$1ice"],[/^(m|l)ice$/i,"$1ice"],[/^(ox)$/i,"$1en"],[/^(oxen)$/i,"$1"],[/(quiz)$/i,"$1zes"]],singular:[[/s$/i,""],[/(ss)$/i,"$1"],[/(n)ews$/i,"$1ews"],[/([ti])a$/i,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i,"$1sis"],[/(^analy)(sis|ses)$/i,"$1sis"],[/([^f])ves$/i,"$1fe"],[/(hive)s$/i,"$1"],[/(tive)s$/i,"$1"],[/([lr])ves$/i,"$1f"],[/([^aeiouy]|qu)ies$/i,"$1y"],[/(s)eries$/i,"$1eries"],[/(m)ovies$/i,"$1ovie"],[/(x|ch|ss|sh)es$/i,"$1"],[/^(m|l)ice$/i,"$1ouse"],[/(bus)(es)?$/i,"$1"],[/(o)es$/i,"$1"],[/(shoe)s$/i,"$1"],[/(cris|test)(is|es)$/i,"$1is"],[/^(a)x[ie]s$/i,"$1xis"],[/(octop|vir)(us|i)$/i,"$1us"],[/(alias|status)(es)?$/i,"$1"],[/^(ox)en/i,"$1"],[/(vert|ind)ices$/i,"$1ex"],[/(matr)ices$/i,"$1ix"],[/(quiz)zes$/i,"$1"],[/(database)s$/i,"$1"]],irregularPairs:[["person","people"],["man","men"],["child","children"],["sex","sexes"],["move","moves"],["cow","kine"],["zombie","zombies"]],uncountable:["equipment","information","rice","money","species","series","fish","sheep","jeans","police"]}
10
+ }(),function(){(Ember.EXTEND_PROTOTYPES===!0||Ember.EXTEND_PROTOTYPES.String)&&(String.prototype.pluralize=function(){return Ember.String.pluralize(this)},String.prototype.singularize=function(){return Ember.String.singularize(this)})}(),function(){Ember.Inflector.inflector=new Ember.Inflector(Ember.Inflector.defaultRules)}(),function(){var e=Ember.get,t=Ember.EnumerableUtils.forEach,r=Ember.String.camelize,n=Ember.String.capitalize,i=Ember.String.decamelize,a=Ember.String.singularize,o=Ember.String.underscore;DS.ActiveModelSerializer=DS.RESTSerializer.extend({keyForAttribute:function(e){return i(e)},keyForRelationship:function(e,t){return e=i(e),"belongsTo"===t?e+"_id":"hasMany"===t?a(e)+"_ids":e},serializeHasMany:Ember.K,serializeIntoHash:function(e,t,r,n){var a=o(i(t.typeKey));e[a]=this.serialize(r,n)},serializePolymorphicType:function(t,i,a){var o=a.key,s=e(t,o);o=this.keyForAttribute(o),i[o+"_type"]=n(r(s.constructor.typeKey))},typeForRoot:function(e){var t=r(e);return a(t)},normalize:function(e,t,r){return this.normalizeLinks(t),this._super(e,t,r)},normalizeLinks:function(e){if(e.links){var t=e.links;for(var n in t){var i=r(n);i!==n&&(t[i]=t[n],delete t[n])}}},normalizeRelationships:function(e,r){var n,i;this.keyForRelationship&&e.eachRelationship(function(e,a){if(a.options.polymorphic){if(n=this.keyForAttribute(e),i=r[n],i&&i.type)i.type=this.typeForRoot(i.type);else if(i&&"hasMany"===a.kind){var o=this;t(i,function(e){e.type=o.typeForRoot(e.type)})}}else n=this.keyForRelationship(e,a.kind),i=r[n];r[e]=i,e!==n&&delete r[n]},this)}})}(),function(){function e(n,i,a,o,s){var d=t(i,"attrs");d&&a.eachRelationship(function(i,a){var u,c,l,h,p=d[i],f=n.serializerFor(a.type.typeKey),m=t(f,"primaryKey");if("hasMany"===a.kind&&p&&("always"===p.embedded||"load"===p.embedded)){if(c="_"+Ember.String.pluralize(a.type.typeKey),u=this.keyForRelationship(i,a.kind),l=this.keyForAttribute(i),h=[],!o[l])return;s[c]=s[c]||[],r(o[l],function(t){var r=n.modelFor(a.type.typeKey);e(n,f,r,t,s),h.push(t[m]),s[c].push(t)}),o[u]=h,delete o[l]}},i)}var t=Ember.get,r=Ember.EnumerableUtils.forEach;DS.EmbeddedRecordsMixin=Ember.Mixin.create({serializeHasMany:function(e,r,n){var i=n.key,a=t(this,"attrs"),o=a&&a[i]&&"always"===a[i].embedded;o&&(r[this.keyForAttribute(i)]=t(e,i).map(function(e){var r=e.serialize(),n=t(this,"primaryKey");return r[n]=t(e,n),r},this))},extractSingle:function(t,r,n,i,a){var o=this.keyForAttribute(r.typeKey),s=n[o];return e(t,this,r,s,n),this._super(t,r,n,i,a)},extractArray:function(t,n,i){var a=this.keyForAttribute(n.typeKey),o=i[Ember.String.pluralize(a)];return r(o,function(r){e(t,this,n,r,i)},this),this._super(t,n,i)}})}(),function(){var e=Ember.EnumerableUtils.forEach,t=Ember.String.decamelize,r=Ember.String.underscore,n=Ember.String.pluralize;DS.ActiveModelAdapter=DS.RESTAdapter.extend({defaultSerializer:"-active-model",pathForType:function(e){var i=t(e),a=r(i);return n(a)},ajaxError:function(t){var r=this._super(t);if(t&&422===t.status){var n=Ember.$.parseJSON(t.responseText),i={};if(void 0!==n.errors){var a=n.errors;e(Ember.keys(a),function(e){i[Ember.String.camelize(e)]=a[e]})}return new DS.InvalidError(i)}return r}})}(),function(){Ember.onLoad("Ember.Application",function(e){e.initializer({name:"activeModelAdapter",initialize:function(e,t){var r=new DS.ContainerProxy(e);r.registerDeprecations([{deprecated:"serializer:_ams",valid:"serializer:-active-model"},{deprecated:"adapter:_ams",valid:"adapter:-active-model"}]),t.register("serializer:-active-model",DS.ActiveModelSerializer),t.register("adapter:-active-model",DS.ActiveModelAdapter)}})})}()}(),"undefined"==typeof location||"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname||Ember.Logger.warn("You are running a production build of Ember on localhost and won't receive detailed error messages. If you want full error messages please use the non-minified build provided on the Ember website.");
@@ -3,7 +3,7 @@
3
3
  * @copyright Copyright 2011-2014 Tilde Inc. and contributors.
4
4
  * Portions Copyright 2011 LivingSocial Inc.
5
5
  * @license Licensed under MIT license (see license.js)
6
- * @version 1.0.0-beta.5
6
+ * @version 1.0.0-beta.6
7
7
  */
8
8
 
9
9
 
@@ -62,11 +62,11 @@ if ('undefined' === typeof DS) {
62
62
  /**
63
63
  @property VERSION
64
64
  @type String
65
- @default '1.0.0-beta.5'
65
+ @default '1.0.0-beta.6'
66
66
  @static
67
67
  */
68
68
  DS = Ember.Namespace.create({
69
- VERSION: '1.0.0-beta.5'
69
+ VERSION: '1.0.0-beta.6'
70
70
  });
71
71
 
72
72
  if ('undefined' !== typeof window) {
@@ -82,6 +82,60 @@ if ('undefined' === typeof DS) {
82
82
 
83
83
 
84
84
 
85
+ (function() {
86
+ /**
87
+ This is used internally to enable deprecation of container paths and provide
88
+ a decent message to the user indicating how to fix the issue.
89
+
90
+ @class ContainerProxy
91
+ @namespace DS
92
+ @private
93
+ */
94
+ var ContainerProxy = function (container){
95
+ this.container = container;
96
+ };
97
+
98
+ ContainerProxy.prototype.aliasedFactory = function(path, preLookup) {
99
+ var _this = this;
100
+
101
+ return {create: function(){
102
+ if (preLookup) { preLookup(); }
103
+
104
+ return _this.container.lookup(path);
105
+ }};
106
+ };
107
+
108
+ ContainerProxy.prototype.registerAlias = function(source, dest, preLookup) {
109
+ var factory = this.aliasedFactory(dest, preLookup);
110
+
111
+ return this.container.register(source, factory);
112
+ };
113
+
114
+ ContainerProxy.prototype.registerDeprecation = function(deprecated, valid) {
115
+ var preLookupCallback = function(){
116
+ Ember.deprecate("You tried to look up '" + deprecated + "', " +
117
+ "but this has been deprecated in favor of '" + valid + "'.", false);
118
+ };
119
+
120
+ return this.registerAlias(deprecated, valid, preLookupCallback);
121
+ };
122
+
123
+ ContainerProxy.prototype.registerDeprecations = function(proxyPairs) {
124
+ for (var i = proxyPairs.length; i > 0; i--) {
125
+ var proxyPair = proxyPairs[i - 1],
126
+ deprecated = proxyPair['deprecated'],
127
+ valid = proxyPair['valid'];
128
+
129
+ this.registerDeprecation(deprecated, valid);
130
+ }
131
+ };
132
+
133
+ DS.ContainerProxy = ContainerProxy;
134
+
135
+ })();
136
+
137
+
138
+
85
139
  (function() {
86
140
  var get = Ember.get, set = Ember.set, isNone = Ember.isNone;
87
141
 
@@ -95,11 +149,11 @@ function aliasMethod(methodName) {
95
149
 
96
150
  /**
97
151
  In Ember Data a Serializer is used to serialize and deserialize
98
- records when they are transfered in and out of an external source.
152
+ records when they are transferred in and out of an external source.
99
153
  This process involves normalizing property names, transforming
100
- attribute values and serializeing relationships.
154
+ attribute values and serializing relationships.
101
155
 
102
- For maximum performance Ember Data recomends you use the
156
+ For maximum performance Ember Data recommends you use the
103
157
  [RESTSerializer](DS.RESTSerializer.html) or one of its subclasses.
104
158
 
105
159
  `JSONSerializer` is useful for simpler or legacy backends that may
@@ -111,9 +165,9 @@ function aliasMethod(methodName) {
111
165
  DS.JSONSerializer = Ember.Object.extend({
112
166
  /**
113
167
  The primaryKey is used when serializing and deserializing
114
- data. Ember Data always uses the `id` propery to store the id of
168
+ data. Ember Data always uses the `id` property to store the id of
115
169
  the record. The external source may not always follow this
116
- convention. In these cases it is usesful to override the
170
+ convention. In these cases it is useful to override the
117
171
  primaryKey property to match the primaryKey of your external
118
172
  store.
119
173
 
@@ -517,7 +571,7 @@ DS.JSONSerializer = Ember.Object.extend({
517
571
  such as the `RESTSerializer` may push records into the store as
518
572
  part of the extract call.
519
573
 
520
- This method deletegates to a more specific extract method based on
574
+ This method delegates to a more specific extract method based on
521
575
  the `requestType`.
522
576
 
523
577
  Example
@@ -777,7 +831,7 @@ DS.JSONSerializer = Ember.Object.extend({
777
831
 
778
832
  /**
779
833
  `keyForRelationship` can be used to define a custom key when
780
- serializeing relationship properties. By default `JSONSerializer`
834
+ serializing relationship properties. By default `JSONSerializer`
781
835
  does not provide an implementation of this method.
782
836
 
783
837
  Example
@@ -807,7 +861,7 @@ DS.JSONSerializer = Ember.Object.extend({
807
861
  */
808
862
  transformFor: function(attributeType, skipAssertion) {
809
863
  var transform = this.container.lookup('transform:' + attributeType);
810
-
864
+ Ember.assert("Unable to find transform for '" + attributeType + "'", skipAssertion || !!transform);
811
865
  return transform;
812
866
  }
813
867
  });
@@ -1095,32 +1149,12 @@ DS.DateTransform = DS.Transform.extend({
1095
1149
 
1096
1150
  serialize: function(date) {
1097
1151
  if (date instanceof Date) {
1098
- var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
1099
- var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
1100
-
1101
- var pad = function(num) {
1102
- return num < 10 ? "0"+num : ""+num;
1103
- };
1104
-
1105
- var utcYear = date.getUTCFullYear(),
1106
- utcMonth = date.getUTCMonth(),
1107
- utcDayOfMonth = date.getUTCDate(),
1108
- utcDay = date.getUTCDay(),
1109
- utcHours = date.getUTCHours(),
1110
- utcMinutes = date.getUTCMinutes(),
1111
- utcSeconds = date.getUTCSeconds();
1112
-
1113
-
1114
- var dayOfWeek = days[utcDay];
1115
- var dayOfMonth = pad(utcDayOfMonth);
1116
- var month = months[utcMonth];
1117
-
1118
- return dayOfWeek + ", " + dayOfMonth + " " + month + " " + utcYear + " " +
1119
- pad(utcHours) + ":" + pad(utcMinutes) + ":" + pad(utcSeconds) + " GMT";
1152
+ // Serialize it as a number to maintain millisecond precision
1153
+ return Number(date);
1120
1154
  } else {
1121
1155
  return null;
1122
1156
  }
1123
- }
1157
+ }
1124
1158
 
1125
1159
  });
1126
1160
 
@@ -1255,9 +1289,20 @@ Ember.onLoad('Ember.Application', function(Application) {
1255
1289
 
1256
1290
  initialize: function(container, application) {
1257
1291
  application.register('store:main', application.Store || DS.Store);
1258
- application.register('serializer:_default', DS.JSONSerializer);
1259
- application.register('serializer:_rest', DS.RESTSerializer);
1260
- application.register('adapter:_rest', DS.RESTAdapter);
1292
+
1293
+ // allow older names to be looked up
1294
+
1295
+ var proxy = new DS.ContainerProxy(container);
1296
+ proxy.registerDeprecations([
1297
+ {deprecated: 'serializer:_default', valid: 'serializer:-default'},
1298
+ {deprecated: 'serializer:_rest', valid: 'serializer:-rest'},
1299
+ {deprecated: 'adapter:_rest', valid: 'adapter:-rest'}
1300
+ ]);
1301
+
1302
+ // new go forward paths
1303
+ application.register('serializer:-default', DS.JSONSerializer);
1304
+ application.register('serializer:-rest', DS.RESTSerializer);
1305
+ application.register('adapter:-rest', DS.RESTAdapter);
1261
1306
 
1262
1307
  // Eagerly generate the store so defaultStore is populated.
1263
1308
  // TODO: Do this in a finisher hook
@@ -1278,11 +1323,11 @@ Ember.onLoad('Ember.Application', function(Application) {
1278
1323
  });
1279
1324
 
1280
1325
  Application.initializer({
1281
- name: "dataAdapter",
1326
+ name: "data-adapter",
1282
1327
  before: "store",
1283
1328
 
1284
1329
  initialize: function(container, application) {
1285
- application.register('dataAdapter:main', DS.DebugAdapter);
1330
+ application.register('data-adapter:main', DS.DebugAdapter);
1286
1331
  }
1287
1332
  });
1288
1333
 
@@ -1294,7 +1339,7 @@ Ember.onLoad('Ember.Application', function(Application) {
1294
1339
  application.inject('controller', 'store', 'store:main');
1295
1340
  application.inject('route', 'store', 'store:main');
1296
1341
  application.inject('serializer', 'store', 'store:main');
1297
- application.inject('dataAdapter', 'store', 'store:main');
1342
+ application.inject('data-adapter', 'store', 'store:main');
1298
1343
  }
1299
1344
  });
1300
1345
 
@@ -1492,7 +1537,7 @@ DS.RecordArray = Ember.ArrayProxy.extend(Ember.Evented, {
1492
1537
  var store = get(this, 'store'),
1493
1538
  type = get(this, 'type');
1494
1539
 
1495
- store.fetchAll(type, this);
1540
+ return store.fetchAll(type, this);
1496
1541
  },
1497
1542
 
1498
1543
  /**
@@ -1790,7 +1835,7 @@ DS.ManyArray = DS.RecordArray.extend({
1790
1835
  replaceContent: function(index, removed, added) {
1791
1836
  // Map the array of record objects into an array of client ids.
1792
1837
  added = map(added, function(record) {
1793
-
1838
+ Ember.assert("You cannot add '" + record.constructor.typeKey + "' records to this relationship (only '" + this.type.typeKey + "' allowed)", !this.type || record instanceof this.type);
1794
1839
  return record;
1795
1840
  }, this);
1796
1841
 
@@ -1885,6 +1930,7 @@ DS.ManyArray = DS.RecordArray.extend({
1885
1930
  type = get(this, 'type'),
1886
1931
  record;
1887
1932
 
1933
+ Ember.assert("You cannot add '" + type.typeKey + "' records to this polymorphic relationship.", !get(this, 'isPolymorphic'));
1888
1934
 
1889
1935
  record = store.createRecord.call(store, type, hash);
1890
1936
  this.pushObject(record);
@@ -2025,7 +2071,7 @@ DS.Store = Ember.Object.extend({
2025
2071
  @default DS.RESTAdapter
2026
2072
  @type {DS.Adapter|String}
2027
2073
  */
2028
- adapter: '_rest',
2074
+ adapter: '-rest',
2029
2075
 
2030
2076
  /**
2031
2077
  Returns a JSON representation of the record using a custom
@@ -2063,9 +2109,10 @@ DS.Store = Ember.Object.extend({
2063
2109
  defaultAdapter: Ember.computed('adapter', function() {
2064
2110
  var adapter = get(this, 'adapter');
2065
2111
 
2112
+ Ember.assert('You tried to set `adapter` property to an instance of `DS.Adapter`, where it should be a name or a factory', !(adapter instanceof DS.Adapter));
2066
2113
 
2067
2114
  if (typeof adapter === 'string') {
2068
- adapter = this.container.lookup('adapter:' + adapter) || this.container.lookup('adapter:application') || this.container.lookup('adapter:_rest');
2115
+ adapter = this.container.lookup('adapter:' + adapter) || this.container.lookup('adapter:application') || this.container.lookup('adapter:-rest');
2069
2116
  }
2070
2117
 
2071
2118
  if (DS.Adapter.detect(adapter)) {
@@ -2159,7 +2206,7 @@ DS.Store = Ember.Object.extend({
2159
2206
  title: "Rails is omakase"
2160
2207
  });
2161
2208
 
2162
- store.deletedRecord(post);
2209
+ store.deleteRecord(post);
2163
2210
  ```
2164
2211
 
2165
2212
  @method deleteRecord
@@ -2311,7 +2358,8 @@ DS.Store = Ember.Object.extend({
2311
2358
 
2312
2359
  var adapter = this.adapterFor(type);
2313
2360
 
2314
-
2361
+ Ember.assert("You tried to find a record but you have no adapter (for " + type + ")", adapter);
2362
+ Ember.assert("You tried to find a record but your adapter (for " + type + ") does not implement 'find'", adapter.find);
2315
2363
 
2316
2364
  var promise = _find(adapter, this, type, id);
2317
2365
  record.loadingData(promise);
@@ -2358,8 +2406,9 @@ DS.Store = Ember.Object.extend({
2358
2406
  adapter = this.adapterFor(type),
2359
2407
  id = get(record, 'id');
2360
2408
 
2361
-
2362
-
2409
+ Ember.assert("You cannot reload a record without an ID", id);
2410
+ Ember.assert("You tried to reload a record but you have no adapter (for " + type + ")", adapter);
2411
+ Ember.assert("You tried to reload a record but your adapter does not implement `find`", adapter.find);
2363
2412
 
2364
2413
  return _find(adapter, this, type, id);
2365
2414
  },
@@ -2398,7 +2447,8 @@ DS.Store = Ember.Object.extend({
2398
2447
  var ids = records.mapProperty('id'),
2399
2448
  adapter = this.adapterFor(type);
2400
2449
 
2401
-
2450
+ Ember.assert("You tried to load many records but you have no adapter (for " + type + ")", adapter);
2451
+ Ember.assert("You tried to load many records but your adapter does not implement `findMany`", adapter.findMany);
2402
2452
 
2403
2453
  resolver.resolve(_findMany(adapter, this, type, ids, owner));
2404
2454
  }, this);
@@ -2502,7 +2552,8 @@ DS.Store = Ember.Object.extend({
2502
2552
  findHasMany: function(owner, link, relationship, resolver) {
2503
2553
  var adapter = this.adapterFor(owner.constructor);
2504
2554
 
2505
-
2555
+ Ember.assert("You tried to load a hasMany relationship but you have no adapter (for " + owner.constructor + ")", adapter);
2556
+ Ember.assert("You tried to load a hasMany relationship from a specified `link` in the original payload but your adapter does not implement `findHasMany`", adapter.findHasMany);
2506
2557
 
2507
2558
  var records = this.recordArrayManager.createManyArray(relationship.type, Ember.A([]));
2508
2559
  resolver.resolve(_findHasMany(adapter, this, owner, link, relationship));
@@ -2520,7 +2571,8 @@ DS.Store = Ember.Object.extend({
2520
2571
  findBelongsTo: function(owner, link, relationship, resolver) {
2521
2572
  var adapter = this.adapterFor(owner.constructor);
2522
2573
 
2523
-
2574
+ Ember.assert("You tried to load a belongsTo relationship but you have no adapter (for " + owner.constructor + ")", adapter);
2575
+ Ember.assert("You tried to load a belongsTo relationship from a specified `link` in the original payload but your adapter does not implement `findBelongsTo`", adapter.findBelongsTo);
2524
2576
 
2525
2577
  resolver.resolve(_findBelongsTo(adapter, this, owner, link, relationship));
2526
2578
  },
@@ -2552,7 +2604,8 @@ DS.Store = Ember.Object.extend({
2552
2604
  promiseLabel = "DS: Store#findQuery " + type,
2553
2605
  resolver = Ember.RSVP.defer(promiseLabel);
2554
2606
 
2555
-
2607
+ Ember.assert("You tried to load a query but you have no adapter (for " + type + ")", adapter);
2608
+ Ember.assert("You tried to load a query but your adapter does not implement `findQuery`", adapter.findQuery);
2556
2609
 
2557
2610
  resolver.resolve(_findQuery(adapter, this, type, query, array));
2558
2611
 
@@ -2588,7 +2641,8 @@ DS.Store = Ember.Object.extend({
2588
2641
 
2589
2642
  set(array, 'isUpdating', true);
2590
2643
 
2591
-
2644
+ Ember.assert("You tried to load all records but you have no adapter (for " + type + ")", adapter);
2645
+ Ember.assert("You tried to load all records but your adapter does not implement `findAll`", adapter.findAll);
2592
2646
 
2593
2647
  return promiseArray(_findAll(adapter, this, type, sinceToken));
2594
2648
  },
@@ -2651,7 +2705,7 @@ DS.Store = Ember.Object.extend({
2651
2705
  type = this.modelFor(type);
2652
2706
 
2653
2707
  var typeMap = this.typeMapFor(type),
2654
- records = typeMap.records, record;
2708
+ records = typeMap.records.splice(0), record;
2655
2709
 
2656
2710
  while(record = records.pop()) {
2657
2711
  record.unloadRecord();
@@ -2688,7 +2742,7 @@ DS.Store = Ember.Object.extend({
2688
2742
  }).then(function(unreadPosts) {
2689
2743
  unreadPosts.get('length'); // 5
2690
2744
  var unreadPost = unreadPosts.objectAt(0);
2691
- unreadPosts.set('unread', false);
2745
+ unreadPost.set('unread', false);
2692
2746
  unreadPosts.get('length'); // 4
2693
2747
  });
2694
2748
  ```
@@ -2891,6 +2945,7 @@ DS.Store = Ember.Object.extend({
2891
2945
  var oldId = get(record, 'id'),
2892
2946
  id = coerceId(data.id);
2893
2947
 
2948
+ Ember.assert("An adapter cannot assign a new id to a record that already has an id. " + record + " had id: " + oldId + " and you tried to update it with " + id + ". This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.", oldId === null || id === oldId);
2894
2949
 
2895
2950
  this.typeMapFor(record.constructor).idToRecord[id] = record;
2896
2951
 
@@ -3043,6 +3098,7 @@ DS.Store = Ember.Object.extend({
3043
3098
  // If passed, it means that the data should be
3044
3099
  // merged into the existing data, not replace it.
3045
3100
 
3101
+ Ember.assert("You must include an `id` in a hash passed to `push`", data.id != null);
3046
3102
 
3047
3103
  type = this.modelFor(type);
3048
3104
 
@@ -3092,7 +3148,7 @@ DS.Store = Ember.Object.extend({
3092
3148
  if (!payload) {
3093
3149
  payload = type;
3094
3150
  serializer = defaultSerializer(this.container);
3095
-
3151
+ Ember.assert("You cannot use `store#pushPayload` without a type unless your default serializer defines `pushPayload`", serializer.pushPayload);
3096
3152
  } else {
3097
3153
  serializer = this.serializerFor(type);
3098
3154
  }
@@ -3100,7 +3156,7 @@ DS.Store = Ember.Object.extend({
3100
3156
  },
3101
3157
 
3102
3158
  update: function(type, data) {
3103
-
3159
+ Ember.assert("You must include an `id` in a hash passed to `update`", data.id != null);
3104
3160
 
3105
3161
  return this.push(type, data, true);
3106
3162
  },
@@ -3150,6 +3206,7 @@ DS.Store = Ember.Object.extend({
3150
3206
  var typeMap = this.typeMapFor(type),
3151
3207
  idToRecord = typeMap.idToRecord;
3152
3208
 
3209
+ Ember.assert('The id ' + id + ' has already been used with another record of type ' + type.toString() + '.', !id || !idToRecord[id]);
3153
3210
 
3154
3211
  // lookupFactory should really return an object that creates
3155
3212
  // instances with the injections applied
@@ -3444,12 +3501,12 @@ function serializerFor(container, type, defaultSerializer) {
3444
3501
  return container.lookup('serializer:'+type) ||
3445
3502
  container.lookup('serializer:application') ||
3446
3503
  container.lookup('serializer:' + defaultSerializer) ||
3447
- container.lookup('serializer:_default');
3504
+ container.lookup('serializer:-default');
3448
3505
  }
3449
3506
 
3450
3507
  function defaultSerializer(container) {
3451
3508
  return container.lookup('serializer:application') ||
3452
- container.lookup('serializer:_default');
3509
+ container.lookup('serializer:-default');
3453
3510
  }
3454
3511
 
3455
3512
  function serializerForAdapter(adapter, type) {
@@ -3475,7 +3532,7 @@ function _find(adapter, store, type, id) {
3475
3532
  serializer = serializerForAdapter(adapter, type);
3476
3533
 
3477
3534
  return resolve(promise, "DS: Handle Adapter#find of " + type + " with id: " + id).then(function(payload) {
3478
-
3535
+ Ember.assert("You made a request for a " + type.typeKey + " with id " + id + ", but the adapter's response did not have any data", payload);
3479
3536
  payload = serializer.extract(store, type, payload, id, 'find');
3480
3537
 
3481
3538
  return store.push(type, payload);
@@ -3493,6 +3550,7 @@ function _findMany(adapter, store, type, ids, owner) {
3493
3550
  return resolve(promise, "DS: Handle Adapter#findMany of " + type).then(function(payload) {
3494
3551
  payload = serializer.extract(store, type, payload, null, 'findMany');
3495
3552
 
3553
+ Ember.assert("The response from a findMany must be an Array, not " + Ember.inspect(payload), Ember.typeOf(payload) === 'array');
3496
3554
 
3497
3555
  store.pushMany(type, payload);
3498
3556
  }, null, "DS: Extract payload of " + type);
@@ -3505,6 +3563,7 @@ function _findHasMany(adapter, store, record, link, relationship) {
3505
3563
  return resolve(promise, "DS: Handle Adapter#findHasMany of " + record + " : " + relationship.type).then(function(payload) {
3506
3564
  payload = serializer.extract(store, relationship.type, payload, null, 'findHasMany');
3507
3565
 
3566
+ Ember.assert("The response from a findHasMany must be an Array, not " + Ember.inspect(payload), Ember.typeOf(payload) === 'array');
3508
3567
 
3509
3568
  var records = store.pushMany(relationship.type, payload);
3510
3569
  record.updateHasMany(relationship.key, records);
@@ -3531,6 +3590,7 @@ function _findAll(adapter, store, type, sinceToken) {
3531
3590
  return resolve(promise, "DS: Handle Adapter#findAll of " + type).then(function(payload) {
3532
3591
  payload = serializer.extract(store, type, payload, null, 'findAll');
3533
3592
 
3593
+ Ember.assert("The response from a findAll must be an Array, not " + Ember.inspect(payload), Ember.typeOf(payload) === 'array');
3534
3594
 
3535
3595
  store.pushMany(type, payload);
3536
3596
  store.didUpdateAll(type);
@@ -3545,6 +3605,7 @@ function _findQuery(adapter, store, type, query, recordArray) {
3545
3605
  return resolve(promise, "DS: Handle Adapter#findQuery of " + type).then(function(payload) {
3546
3606
  payload = serializer.extract(store, type, payload, null, 'findQuery');
3547
3607
 
3608
+ Ember.assert("The response from a findQuery must be an Array, not " + Ember.inspect(payload), Ember.typeOf(payload) === 'array');
3548
3609
 
3549
3610
  recordArray.load(payload);
3550
3611
  return recordArray;
@@ -3556,6 +3617,7 @@ function _commit(adapter, store, operation, record) {
3556
3617
  promise = adapter[operation](store, type, record),
3557
3618
  serializer = serializerForAdapter(adapter, type);
3558
3619
 
3620
+ Ember.assert("Your adapter's '" + operation + "' method must return a promise, but it returned " + promise, isThenable(promise));
3559
3621
 
3560
3622
  return promise.then(function(payload) {
3561
3623
  if (payload) { payload = serializer.extract(store, type, payload, get(record, 'id'), operation); }
@@ -3993,6 +4055,8 @@ createdState.uncommitted.rollback = function(record) {
3993
4055
  record.transitionTo('deleted.saved');
3994
4056
  };
3995
4057
 
4058
+ createdState.uncommitted.propertyWasReset = Ember.K;
4059
+
3996
4060
  updatedState.uncommitted.deleteRecord = function(record) {
3997
4061
  record.transitionTo('deleted.uncommitted');
3998
4062
  record.clearRelationships();
@@ -4049,7 +4113,7 @@ var RootState = {
4049
4113
  }
4050
4114
  },
4051
4115
 
4052
- // A record enters this state when the store askes
4116
+ // A record enters this state when the store asks
4053
4117
  // the adapter for its data. It remains in this state
4054
4118
  // until the adapter provides the requested data.
4055
4119
  //
@@ -4488,7 +4552,7 @@ DS.Errors = Ember.Object.extend(Ember.Enumerable, Ember.Evented, {
4488
4552
  */
4489
4553
 
4490
4554
  var get = Ember.get, set = Ember.set,
4491
- merge = Ember.merge, once = Ember.run.once;
4555
+ merge = Ember.merge;
4492
4556
 
4493
4557
  var retrieveFromCurrentState = Ember.computed('currentState', function(key, value) {
4494
4558
  return get(get(this, 'currentState'), key);
@@ -4520,7 +4584,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
4520
4584
  isEmpty: retrieveFromCurrentState,
4521
4585
  /**
4522
4586
  If this property is `true` the record is in the `loading` state. A
4523
- record enters this state when the store askes the adapter for its
4587
+ record enters this state when the store asks the adapter for its
4524
4588
  data. It remains in this state until the adapter provides the
4525
4589
  requested data.
4526
4590
 
@@ -4632,7 +4696,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
4632
4696
  var record = store.createRecord(App.Model);
4633
4697
  record.get('isNew'); // true
4634
4698
 
4635
- store.find('model', 1).then(function(model) {
4699
+ record.save().then(function(model) {
4636
4700
  model.get('isNew'); // false
4637
4701
  });
4638
4702
  ```
@@ -4754,7 +4818,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
4754
4818
  /**
4755
4819
  When the record is in the `invalid` state this object will contain
4756
4820
  any errors returned by the adapter. When present the errors hash
4757
- typically contains keys coresponding to the invalid property names
4821
+ typically contains keys corresponding to the invalid property names
4758
4822
  and values which are an array of error messages.
4759
4823
 
4760
4824
  ```javascript
@@ -5055,7 +5119,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5055
5119
  @private
5056
5120
  */
5057
5121
  unloadRecord: function() {
5058
-
5122
+ Ember.assert("You can only unload a loaded, non-dirty record.", !get(this, 'isDirty'));
5059
5123
 
5060
5124
  this.send('unloadRecord');
5061
5125
  },
@@ -5080,6 +5144,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5080
5144
  @private
5081
5145
  */
5082
5146
  updateRecordArrays: function() {
5147
+ this._updatingRecordArraysLater = false;
5083
5148
  get(this, 'store').dataWasUpdated(this.constructor, this);
5084
5149
  },
5085
5150
 
@@ -5194,7 +5259,11 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5194
5259
  @private
5195
5260
  */
5196
5261
  updateRecordArraysLater: function() {
5197
- Ember.run.once(this, this.updateRecordArrays);
5262
+ // quick hack (something like this could be pushed into run.once
5263
+ if (this._updatingRecordArraysLater) { return; }
5264
+ this._updatingRecordArraysLater = true;
5265
+
5266
+ Ember.run.schedule('actions', this, this.updateRecordArrays);
5198
5267
  },
5199
5268
 
5200
5269
  /**
@@ -5230,7 +5299,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5230
5299
  },
5231
5300
 
5232
5301
  materializeAttributes: function(attributes) {
5233
-
5302
+ Ember.assert("Must pass a hash of attributes to materializeAttributes", !!attributes);
5234
5303
  merge(this._data, attributes);
5235
5304
  },
5236
5305
 
@@ -5260,7 +5329,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5260
5329
  },
5261
5330
 
5262
5331
  /**
5263
- If the model `isDirty` this function will which discard any unsaved
5332
+ If the model `isDirty` this function will discard any unsaved
5264
5333
  changes
5265
5334
 
5266
5335
  Example
@@ -5461,8 +5530,8 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5461
5530
  },
5462
5531
 
5463
5532
  triggerLater: function() {
5464
- this._deferredTriggers.push(arguments);
5465
- once(this, '_triggerDeferredTriggers');
5533
+ if (this._deferredTriggers.push(arguments) !== 1) { return; }
5534
+ Ember.run.schedule('actions', this, '_triggerDeferredTriggers');
5466
5535
  },
5467
5536
 
5468
5537
  _triggerDeferredTriggers: function() {
@@ -5470,7 +5539,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5470
5539
  this.trigger.apply(this, this._deferredTriggers[i]);
5471
5540
  }
5472
5541
 
5473
- this._deferredTriggers = [];
5542
+ this._deferredTriggers.length = 0;
5474
5543
  }
5475
5544
  });
5476
5545
 
@@ -5556,7 +5625,7 @@ DS.Model.reopenClass({
5556
5625
 
5557
5626
  this.eachComputedProperty(function(name, meta) {
5558
5627
  if (meta.isAttribute) {
5559
-
5628
+ Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from " + this.toString(), name !== 'id');
5560
5629
 
5561
5630
  meta.name = name;
5562
5631
  map.set(name, meta);
@@ -5669,7 +5738,7 @@ DS.Model.reopenClass({
5669
5738
  ```
5670
5739
 
5671
5740
  - `name` the name of the current property in the iteration
5672
- - `type` a tring contrining the name of the type of transformed
5741
+ - `type` a string containing the name of the type of transformed
5673
5742
  applied to the attribute
5674
5743
 
5675
5744
  Note that in addition to a callback, you can also pass an optional target
@@ -5781,7 +5850,7 @@ DS.attr = function(type, options) {
5781
5850
 
5782
5851
  return Ember.computed(function(key, value) {
5783
5852
  if (arguments.length > 1) {
5784
-
5853
+ Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from " + this.constructor.toString(), key !== 'id');
5785
5854
  var oldValue = this._attributes[key] || this._inFlightAttributes[key] || this._data[key];
5786
5855
 
5787
5856
  this.send('didSetProperty', {
@@ -5885,7 +5954,7 @@ var forEach = Ember.EnumerableUtils.forEach;
5885
5954
  @class RelationshipChange
5886
5955
  @namespace DS
5887
5956
  @private
5888
- @construtor
5957
+ @constructor
5889
5958
  */
5890
5959
  DS.RelationshipChange = function(options) {
5891
5960
  this.parentRecord = options.parentRecord;
@@ -5906,7 +5975,7 @@ DS.RelationshipChange = function(options) {
5906
5975
  @class RelationshipChangeAdd
5907
5976
  @namespace DS
5908
5977
  @private
5909
- @construtor
5978
+ @constructor
5910
5979
  */
5911
5980
  DS.RelationshipChangeAdd = function(options){
5912
5981
  DS.RelationshipChange.call(this, options);
@@ -5916,7 +5985,7 @@ DS.RelationshipChangeAdd = function(options){
5916
5985
  @class RelationshipChangeRemove
5917
5986
  @namespace DS
5918
5987
  @private
5919
- @construtor
5988
+ @constructor
5920
5989
  */
5921
5990
  DS.RelationshipChangeRemove = function(options){
5922
5991
  DS.RelationshipChange.call(this, options);
@@ -6070,7 +6139,7 @@ DS.OneToOneChange.createChange = function(childRecord, parentRecord, store, opti
6070
6139
  } else if (options.key) {
6071
6140
  key = options.key;
6072
6141
  } else {
6073
-
6142
+ Ember.assert("You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent", false);
6074
6143
  }
6075
6144
 
6076
6145
  var change = DS.RelationshipChange._createChange({
@@ -6120,7 +6189,7 @@ DS.OneToManyChange.createChange = function(childRecord, parentRecord, store, opt
6120
6189
  } else if (options.key) {
6121
6190
  key = options.key;
6122
6191
  } else {
6123
-
6192
+ Ember.assert("You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent", false);
6124
6193
  }
6125
6194
 
6126
6195
  var change = DS.RelationshipChange._createChange({
@@ -6347,7 +6416,7 @@ function asyncBelongsTo(type, options, meta) {
6347
6416
  promiseLabel = "DS: Async belongsTo " + this + " : " + key;
6348
6417
 
6349
6418
  if (arguments.length === 2) {
6350
-
6419
+ Ember.assert("You can only add a '" + type + "' record to this relationship", !value || value instanceof store.modelFor(type));
6351
6420
  return value === undefined ? null : DS.PromiseObject.create({ promise: Ember.RSVP.resolve(value, promiseLabel) });
6352
6421
  }
6353
6422
 
@@ -6419,7 +6488,7 @@ DS.belongsTo = function(type, options) {
6419
6488
  options = type;
6420
6489
  type = undefined;
6421
6490
  } else {
6422
-
6491
+ Ember.assert("The first argument DS.belongsTo must be a model type or string, like DS.belongsTo(App.Person)", !!type && (typeof type === 'string' || DS.Model.detect(type)));
6423
6492
  }
6424
6493
 
6425
6494
  options = options || {};
@@ -6441,7 +6510,7 @@ DS.belongsTo = function(type, options) {
6441
6510
  }
6442
6511
 
6443
6512
  if (arguments.length === 2) {
6444
-
6513
+ Ember.assert("You can only add a '" + type + "' record to this relationship", !value || value instanceof typeClass);
6445
6514
  return value === undefined ? null : value;
6446
6515
  }
6447
6516
 
@@ -6577,7 +6646,7 @@ function hasRelationship(type, options) {
6577
6646
  return Ember.computed(function(key, value) {
6578
6647
  return buildRelationship(this, key, options, function(store, data) {
6579
6648
  var records = data[key];
6580
-
6649
+ Ember.assert("You looked up the '" + key + "' relationship on '" + this + "' but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)", Ember.A(records).everyProperty('isEmpty', false));
6581
6650
  return store.findMany(this, data[key], meta.type);
6582
6651
  });
6583
6652
  }).property('data').meta(meta);
@@ -6785,7 +6854,7 @@ DS.Model.reopenClass({
6785
6854
  var options = this.metaForProperty(name).options;
6786
6855
 
6787
6856
  if (options.inverse === null) { return null; }
6788
-
6857
+
6789
6858
  var inverseName, inverseKind;
6790
6859
 
6791
6860
  if (options.inverse) {
@@ -6796,6 +6865,7 @@ DS.Model.reopenClass({
6796
6865
 
6797
6866
  if (possibleRelationships.length === 0) { return null; }
6798
6867
 
6868
+ Ember.assert("You defined the '" + name + "' relationship on " + this + ", but multiple possible inverse relationships of type " + this + " were found on " + inverseType + ". Look at http://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses", possibleRelationships.length === 1);
6799
6869
 
6800
6870
  inverseName = possibleRelationships[0].name;
6801
6871
  inverseKind = possibleRelationships[0].kind;
@@ -6967,9 +7037,10 @@ DS.Model.reopenClass({
6967
7037
  type = get(this, type, false) || this.store.modelFor(type);
6968
7038
  }
6969
7039
 
7040
+ Ember.assert("You specified a hasMany (" + meta.type + ") on " + meta.parentType + " but " + meta.type + " was not found.", type);
6970
7041
 
6971
7042
  if (!types.contains(type)) {
6972
-
7043
+ Ember.assert("Trying to sideload " + name + " on " + this.toString() + " but the type doesn't exist.", !!type);
6973
7044
  types.push(type);
6974
7045
  }
6975
7046
  }
@@ -7151,7 +7222,6 @@ DS.Model.reopen({
7151
7222
  */
7152
7223
 
7153
7224
  var get = Ember.get, set = Ember.set;
7154
- var once = Ember.run.once;
7155
7225
  var forEach = Ember.EnumerableUtils.forEach;
7156
7226
 
7157
7227
  /**
@@ -7170,8 +7240,9 @@ DS.RecordArrayManager = Ember.Object.extend({
7170
7240
  },
7171
7241
 
7172
7242
  recordDidChange: function(record) {
7173
- this.changedRecords.push(record);
7174
- once(this, this.updateRecordArrays);
7243
+ if (this.changedRecords.push(record) !== 1) { return; }
7244
+
7245
+ Ember.run.schedule('actions', this, this.updateRecordArrays);
7175
7246
  },
7176
7247
 
7177
7248
  recordArraysForRecord: function(record) {
@@ -7200,7 +7271,7 @@ DS.RecordArrayManager = Ember.Object.extend({
7200
7271
  }
7201
7272
  }, this);
7202
7273
 
7203
- this.changedRecords = [];
7274
+ this.changedRecords.length = 0;
7204
7275
  },
7205
7276
 
7206
7277
  _recordWasDeleted: function (record) {
@@ -7479,7 +7550,7 @@ DS.InvalidError.prototype = Ember.create(Error.prototype);
7479
7550
 
7480
7551
  ```javascript
7481
7552
  App.store = DS.Store.create({
7482
- adapter: App.MyAdapter.create()
7553
+ adapter: 'MyAdapter'
7483
7554
  });
7484
7555
  ```
7485
7556
 
@@ -7931,7 +8002,7 @@ DS.FixtureAdapter = DS.Adapter.extend({
7931
8002
  @return {Promise|Array}
7932
8003
  */
7933
8004
  queryFixtures: function(fixtures, query, type) {
7934
-
8005
+ Ember.assert('Not implemented: You must override the DS.FixtureAdapter::queryFixtures method to support querying the fixture store.');
7935
8006
  },
7936
8007
 
7937
8008
  /**
@@ -7983,6 +8054,7 @@ DS.FixtureAdapter = DS.Adapter.extend({
7983
8054
  var fixtures = this.fixturesForType(type),
7984
8055
  fixture;
7985
8056
 
8057
+ Ember.assert("Unable to find fixtures for model type "+type.toString(), fixtures);
7986
8058
 
7987
8059
  if (fixtures) {
7988
8060
  fixture = Ember.A(fixtures).findProperty('id', id);
@@ -8005,6 +8077,7 @@ DS.FixtureAdapter = DS.Adapter.extend({
8005
8077
  findMany: function(store, type, ids) {
8006
8078
  var fixtures = this.fixturesForType(type);
8007
8079
 
8080
+ Ember.assert("Unable to find fixtures for model type "+type.toString(), fixtures);
8008
8081
 
8009
8082
  if (fixtures) {
8010
8083
  fixtures = fixtures.filter(function(item) {
@@ -8030,6 +8103,7 @@ DS.FixtureAdapter = DS.Adapter.extend({
8030
8103
  findAll: function(store, type) {
8031
8104
  var fixtures = this.fixturesForType(type);
8032
8105
 
8106
+ Ember.assert("Unable to find fixtures for model type "+type.toString(), fixtures);
8033
8107
 
8034
8108
  return this.simulateRemoteCall(function() {
8035
8109
  return fixtures;
@@ -8048,6 +8122,7 @@ DS.FixtureAdapter = DS.Adapter.extend({
8048
8122
  findQuery: function(store, type, query, array) {
8049
8123
  var fixtures = this.fixturesForType(type);
8050
8124
 
8125
+ Ember.assert("Unable to find fixtures for model type "+type.toString(), fixtures);
8051
8126
 
8052
8127
  fixtures = this.queryFixtures(fixtures, query, type);
8053
8128
 
@@ -8279,7 +8354,7 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8279
8354
  The key under `normalizeHash` is usually just the original key
8280
8355
  that was in the original payload. However, key names will be
8281
8356
  impacted by any modifications done in the `normalizePayload`
8282
- method. The `DS.RESTSerializer`'s default implemention makes no
8357
+ method. The `DS.RESTSerializer`'s default implementation makes no
8283
8358
  changes to the payload keys.
8284
8359
 
8285
8360
  @property normalizeHash
@@ -8545,7 +8620,8 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8545
8620
 
8546
8621
  for (var prop in payload) {
8547
8622
  var typeName = this.typeForRoot(prop),
8548
- isPrimary = typeName === primaryTypeName;
8623
+ type = store.modelFor(typeName),
8624
+ isPrimary = type.typeKey === primaryTypeName;
8549
8625
 
8550
8626
  // legacy support for singular resources
8551
8627
  if (isPrimary && Ember.typeOf(payload[prop]) !== "array" ) {
@@ -8553,8 +8629,6 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8553
8629
  continue;
8554
8630
  }
8555
8631
 
8556
- var type = store.modelFor(typeName);
8557
-
8558
8632
  /*jshint loopfunc:true*/
8559
8633
  forEach.call(payload[prop], function(hash) {
8560
8634
  var typeName = this.typeForRoot(prop),
@@ -8702,7 +8776,7 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8702
8776
  var typeName = this.typeForRoot(typeKey),
8703
8777
  type = store.modelFor(typeName),
8704
8778
  typeSerializer = store.serializerFor(type),
8705
- isPrimary = (!forcedSecondary && (typeName === primaryTypeName));
8779
+ isPrimary = (!forcedSecondary && (type.typeKey === primaryTypeName));
8706
8780
 
8707
8781
  /*jshint loopfunc:true*/
8708
8782
  var normalizedArray = map.call(payload[prop], function(hash) {
@@ -8959,7 +9033,8 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8959
9033
  @param {Object} options
8960
9034
  */
8961
9035
  serializeIntoHash: function(hash, type, record, options) {
8962
- hash[type.typeKey] = this.serialize(record, options);
9036
+ var root = Ember.String.camelize(type.typeKey);
9037
+ hash[root] = this.serialize(record, options);
8963
9038
  },
8964
9039
 
8965
9040
  /**
@@ -8976,7 +9051,7 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8976
9051
  var key = relationship.key,
8977
9052
  belongsTo = get(record, key);
8978
9053
  key = this.keyForAttribute ? this.keyForAttribute(key) : key;
8979
- json[key + "Type"] = belongsTo.constructor.typeKey;
9054
+ json[key + "Type"] = Ember.String.camelize(belongsTo.constructor.typeKey);
8980
9055
  }
8981
9056
  });
8982
9057
 
@@ -9091,7 +9166,7 @@ var forEach = Ember.ArrayPolyfills.forEach;
9091
9166
  @extends DS.Adapter
9092
9167
  */
9093
9168
  DS.RESTAdapter = DS.Adapter.extend({
9094
- defaultSerializer: '_rest',
9169
+ defaultSerializer: '-rest',
9095
9170
 
9096
9171
 
9097
9172
  /**
@@ -9149,7 +9224,7 @@ DS.RESTAdapter = DS.Adapter.extend({
9149
9224
  The `find` method makes an Ajax request to a URL computed by `buildURL`, and returns a
9150
9225
  promise for the resulting payload.
9151
9226
 
9152
- This method performs an HTTP `GET` request with the id provided as part of the querystring.
9227
+ This method performs an HTTP `GET` request with the id provided as part of the query string.
9153
9228
 
9154
9229
  @method find
9155
9230
  @param {DS.Store} store
@@ -9479,11 +9554,12 @@ DS.RESTAdapter = DS.Adapter.extend({
9479
9554
  @returns {String} path
9480
9555
  **/
9481
9556
  pathForType: function(type) {
9482
- return Ember.String.pluralize(type);
9557
+ var camelized = Ember.String.camelize(type);
9558
+ return Ember.String.pluralize(camelized);
9483
9559
  },
9484
9560
 
9485
9561
  /**
9486
- Takes an ajax response, and returns a relavant error.
9562
+ Takes an ajax response, and returns a relevant error.
9487
9563
 
9488
9564
  Returning a `DS.InvalidError` from this method will cause the
9489
9565
  record to transition into the `invalid` state and make the
@@ -9544,7 +9620,7 @@ DS.RESTAdapter = DS.Adapter.extend({
9544
9620
  @method ajax
9545
9621
  @private
9546
9622
  @param {String} url
9547
- @param {String} type The request type GET, POST, PUT, DELETE ect.
9623
+ @param {String} type The request type GET, POST, PUT, DELETE etc.
9548
9624
  @param {Object} hash
9549
9625
  @return {Promise} promise
9550
9626
  */
@@ -9570,7 +9646,7 @@ DS.RESTAdapter = DS.Adapter.extend({
9570
9646
  @method ajaxOptions
9571
9647
  @private
9572
9648
  @param {String} url
9573
- @param {String} type The request type GET, POST, PUT, DELETE ect.
9649
+ @param {String} type The request type GET, POST, PUT, DELETE etc.
9574
9650
  @param {Object} hash
9575
9651
  @return {Object} hash
9576
9652
  */
@@ -10050,8 +10126,13 @@ Ember.Inflector.inflector = new Ember.Inflector(Ember.Inflector.defaultRules);
10050
10126
  @module ember-data
10051
10127
  */
10052
10128
 
10053
- var get = Ember.get;
10054
- var forEach = Ember.EnumerableUtils.forEach;
10129
+ var get = Ember.get,
10130
+ forEach = Ember.EnumerableUtils.forEach,
10131
+ camelize = Ember.String.camelize,
10132
+ capitalize = Ember.String.capitalize,
10133
+ decamelize = Ember.String.decamelize,
10134
+ singularize = Ember.String.singularize,
10135
+ underscore = Ember.String.underscore;
10055
10136
 
10056
10137
  DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10057
10138
  // SERIALIZE
@@ -10064,7 +10145,7 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10064
10145
  @returns String
10065
10146
  */
10066
10147
  keyForAttribute: function(attr) {
10067
- return Ember.String.decamelize(attr);
10148
+ return decamelize(attr);
10068
10149
  },
10069
10150
 
10070
10151
  /**
@@ -10077,11 +10158,11 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10077
10158
  @returns String
10078
10159
  */
10079
10160
  keyForRelationship: function(key, kind) {
10080
- key = Ember.String.decamelize(key);
10161
+ key = decamelize(key);
10081
10162
  if (kind === "belongsTo") {
10082
10163
  return key + "_id";
10083
10164
  } else if (kind === "hasMany") {
10084
- return Ember.String.singularize(key) + "_ids";
10165
+ return singularize(key) + "_ids";
10085
10166
  } else {
10086
10167
  return key;
10087
10168
  }
@@ -10102,7 +10183,7 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10102
10183
  @param {Object} options
10103
10184
  */
10104
10185
  serializeIntoHash: function(data, type, record, options) {
10105
- var root = Ember.String.decamelize(type.typeKey);
10186
+ var root = underscore(decamelize(type.typeKey));
10106
10187
  data[root] = this.serialize(record, options);
10107
10188
  },
10108
10189
 
@@ -10118,7 +10199,7 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10118
10199
  var key = relationship.key,
10119
10200
  belongsTo = get(record, key);
10120
10201
  key = this.keyForAttribute(key);
10121
- json[key + "_type"] = Ember.String.capitalize(belongsTo.constructor.typeKey);
10202
+ json[key + "_type"] = capitalize(camelize(belongsTo.constructor.typeKey));
10122
10203
  },
10123
10204
 
10124
10205
  // EXTRACT
@@ -10131,8 +10212,8 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10131
10212
  @returns String the model's typeKey
10132
10213
  */
10133
10214
  typeForRoot: function(root) {
10134
- var camelized = Ember.String.camelize(root);
10135
- return Ember.String.singularize(camelized);
10215
+ var camelized = camelize(root);
10216
+ return singularize(camelized);
10136
10217
  },
10137
10218
 
10138
10219
  /**
@@ -10187,7 +10268,7 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10187
10268
  var links = data.links;
10188
10269
 
10189
10270
  for (var link in links) {
10190
- var camelizedLink = Ember.String.camelize(link);
10271
+ var camelizedLink = camelize(link);
10191
10272
 
10192
10273
  if (camelizedLink !== link) {
10193
10274
  links[camelizedLink] = links[link];
@@ -10387,6 +10468,9 @@ function updatePayloadWithEmbedded(store, serializer, type, partial, payload) {
10387
10468
  */
10388
10469
 
10389
10470
  var forEach = Ember.EnumerableUtils.forEach;
10471
+ var decamelize = Ember.String.decamelize,
10472
+ underscore = Ember.String.underscore,
10473
+ pluralize = Ember.String.pluralize;
10390
10474
 
10391
10475
  /**
10392
10476
  The ActiveModelAdapter is a subclass of the RESTAdapter designed to integrate
@@ -10438,7 +10522,7 @@ var forEach = Ember.EnumerableUtils.forEach;
10438
10522
  **/
10439
10523
 
10440
10524
  DS.ActiveModelAdapter = DS.RESTAdapter.extend({
10441
- defaultSerializer: '_ams',
10525
+ defaultSerializer: '-active-model',
10442
10526
  /**
10443
10527
  The ActiveModelAdapter overrides the `pathForType` method to build
10444
10528
  underscored URLs by decamelizing and pluralizing the object type name.
@@ -10453,8 +10537,9 @@ DS.ActiveModelAdapter = DS.RESTAdapter.extend({
10453
10537
  @returns String
10454
10538
  */
10455
10539
  pathForType: function(type) {
10456
- var decamelized = Ember.String.decamelize(type);
10457
- return Ember.String.pluralize(decamelized);
10540
+ var decamelized = decamelize(type);
10541
+ var underscored = underscore(decamelized);
10542
+ return pluralize(underscored);
10458
10543
  },
10459
10544
 
10460
10545
  /**
@@ -10477,12 +10562,16 @@ DS.ActiveModelAdapter = DS.RESTAdapter.extend({
10477
10562
  var error = this._super(jqXHR);
10478
10563
 
10479
10564
  if (jqXHR && jqXHR.status === 422) {
10480
- var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)["errors"],
10565
+ var response = Ember.$.parseJSON(jqXHR.responseText),
10481
10566
  errors = {};
10482
10567
 
10483
- forEach(Ember.keys(jsonErrors), function(key) {
10484
- errors[Ember.String.camelize(key)] = jsonErrors[key];
10485
- });
10568
+ if (response.errors !== undefined) {
10569
+ var jsonErrors = response.errors;
10570
+
10571
+ forEach(Ember.keys(jsonErrors), function(key) {
10572
+ errors[Ember.String.camelize(key)] = jsonErrors[key];
10573
+ });
10574
+ }
10486
10575
 
10487
10576
  return new DS.InvalidError(errors);
10488
10577
  } else {
@@ -10507,8 +10596,14 @@ Ember.onLoad('Ember.Application', function(Application) {
10507
10596
  name: "activeModelAdapter",
10508
10597
 
10509
10598
  initialize: function(container, application) {
10510
- application.register('serializer:_ams', DS.ActiveModelSerializer);
10511
- application.register('adapter:_ams', DS.ActiveModelAdapter);
10599
+ var proxy = new DS.ContainerProxy(container);
10600
+ proxy.registerDeprecations([
10601
+ {deprecated: 'serializer:_ams', valid: 'serializer:-active-model'},
10602
+ {deprecated: 'adapter:_ams', valid: 'adapter:-active-model'}
10603
+ ]);
10604
+
10605
+ application.register('serializer:-active-model', DS.ActiveModelSerializer);
10606
+ application.register('adapter:-active-model', DS.ActiveModelAdapter);
10512
10607
  }
10513
10608
  });
10514
10609
  });