ember-data-source 1.0.0.beta.7 → 1.0.0.beta.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,8 +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.7+canary.f482da04
6
+ * @version 1.0.0-beta.8.2a68c63a
7
7
  */
8
- !function(a){var b,c,d,e;!function(){var a={},f={};b=function(b,c,d){a[b]={deps:c,callback:d}},e=d=c=function(b){function d(a){if("."!==a.charAt(0))return a;for(var c=a.split("/"),d=b.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(e._eak_seen=a,f[b])return f[b];if(f[b]={},!a[b])throw new Error("Could not find module "+b);for(var g,h=a[b],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:c(d(i[l])));var n=j.apply(this,k);return f[b]=g||n}}(),b("activemodel-adapter/lib/initializers",["../../ember-data/lib/system/container_proxy","./system/active_model_serializer","./system/active_model_adapter"],function(a,b,c){"use strict";var d=a["default"],e=b["default"],f=c["default"];Ember.onLoad("Ember.Application",function(a){a.initializer({name:"activeModelAdapter",initialize:function(a,b){var c=new d(a);c.registerDeprecations([{deprecated:"serializer:_ams",valid:"serializer:-active-model"},{deprecated:"adapter:_ams",valid:"adapter:-active-model"}]),b.register("serializer:-active-model",e),b.register("adapter:-active-model",f)}})})}),b("activemodel-adapter/lib/main",["./system","./initializers","exports"],function(a,b,c){"use strict";var d=a.ActiveModelAdapter,e=a.ActiveModelSerializer,f=a.EmbeddedRecordsMixin;c.ActiveModelAdapter=d,c.ActiveModelSerializer=e,c.EmbeddedRecordsMixin=f}),b("activemodel-adapter/lib/system",["./system/embedded_records_mixin","./system/active_model_adapter","./system/active_model_serializer","exports"],function(a,b,c,d){"use strict";var e=a["default"],f=b["default"],g=c["default"];d.EmbeddedRecordsMixin=e,d.ActiveModelAdapter=f,d.ActiveModelSerializer=g}),b("activemodel-adapter/lib/system/active_model_adapter",["../../../ember-data/lib/adapters","../../../ember-data/lib/system/adapter","../../../ember-inflector/lib/main","./active_model_serializer","./embedded_records_mixin","exports"],function(a,b,c,d,e,f){"use strict";var g=a.RESTAdapter,h=b.InvalidError,i=c.pluralize,j=(d["default"],e["default"],Ember.EnumerableUtils.forEach),k=Ember.String.decamelize,l=Ember.String.underscore,m=g.extend({defaultSerializer:"-active-model",pathForType:function(a){var b=k(a),c=l(b);return i(c)},ajaxError:function(a){var b=this._super(a);if(a&&422===a.status){var c=Ember.$.parseJSON(a.responseText),d={};if(void 0!==c.errors){var e=c.errors;j(Ember.keys(e),function(a){d[Ember.String.camelize(a)]=e[a]})}return new h(d)}return b}});f["default"]=m}),b("activemodel-adapter/lib/system/active_model_serializer",["../../../ember-inflector/lib/main","../../../ember-data/lib/serializers/rest_serializer","exports"],function(a,b,c){"use strict";var d=a.singularize,e=b["default"],f=Ember.get,g=Ember.EnumerableUtils.forEach,h=Ember.String.camelize,i=Ember.String.capitalize,j=Ember.String.decamelize,k=Ember.String.underscore,l=e.extend({keyForAttribute:function(a){return j(a)},keyForRelationship:function(a,b){return a=j(a),"belongsTo"===b?a+"_id":"hasMany"===b?d(a)+"_ids":a},serializeHasMany:Ember.K,serializeIntoHash:function(a,b,c,d){var e=k(j(b.typeKey));a[e]=this.serialize(c,d)},serializePolymorphicType:function(a,b,c){var d=c.key,e=f(a,d);d=this.keyForAttribute(d),b[d+"_type"]=i(h(e.constructor.typeKey))},typeForRoot:function(a){var b=h(a);return d(b)},normalize:function(a,b,c){return this.normalizeLinks(b),this._super(a,b,c)},normalizeLinks:function(a){if(a.links){var b=a.links;for(var c in b){var d=h(c);d!==c&&(b[d]=b[c],delete b[c])}}},normalizeRelationships:function(a,b){var c,d;this.keyForRelationship&&a.eachRelationship(function(a,e){if(e.options.polymorphic){if(c=this.keyForAttribute(a),d=b[c],d&&d.type)d.type=this.typeForRoot(d.type);else if(d&&"hasMany"===e.kind){var f=this;g(d,function(a){a.type=f.typeForRoot(a.type)})}}else c=this.keyForRelationship(a,e.kind),d=b[c];b[a]=d,a!==c&&delete b[c]},this)}});c["default"]=l}),b("activemodel-adapter/lib/system/embedded_records_mixin",["../../../ember-inflector/lib/main","exports"],function(a,b){"use strict";function c(a,b,f,g,h){var i=d(b,"attrs");i&&f.eachRelationship(function(b,f){var j,k,l,m,n=i[b],o=a.serializerFor(f.type.typeKey),p=d(o,"primaryKey");if("hasMany"===f.kind&&n&&("always"===n.embedded||"load"===n.embedded)){if(k="_"+Ember.String.pluralize(f.type.typeKey),j=this.keyForRelationship(b,f.kind),l=this.keyForAttribute(b),m=[],!g[l])return;h[k]=h[k]||[],e(g[l],function(b){var d=a.modelFor(f.type.typeKey);c(a,o,d,b,h),m.push(b[p]),h[k].push(b)}),g[j]=m,delete g[l]}},b)}var d=Ember.get,e=Ember.EnumerableUtils.forEach,f=a.pluralize,g=Ember.Mixin.create({serializeHasMany:function(a,b,c){var e=c.key,f=d(this,"attrs"),g=f&&f[e]&&"always"===f[e].embedded;g&&(b[this.keyForAttribute(e)]=d(a,e).map(function(a){var b=a.serialize(),c=d(this,"primaryKey");return b[c]=d(a,c),b},this))},extractSingle:function(a,b,d,e,f){var g=this.keyForAttribute(b.typeKey),h=d[g];return c(a,this,b,h,d),this._super(a,b,d,e,f)},extractArray:function(a,b,d){var g=this.keyForAttribute(b.typeKey),h=d[f(g)];return e(h,function(e){c(a,this,b,e,d)},this),this._super(a,b,d)}});b["default"]=g}),b("ember-data/lib/adapters",["./adapters/fixture_adapter","./adapters/rest_adapter","exports"],function(a,b,c){"use strict";var d=a["default"],e=b["default"];c.RESTAdapter=e,c.FixtureAdapter=d}),b("ember-data/lib/adapters/fixture_adapter",["../system/adapter","exports"],function(a,b){"use strict";var c=Ember.get,d=Ember.String.fmt,e=Ember.EnumerableUtils.indexOf,f=0,g=a["default"],h=g.extend({serializer:null,simulateRemoteResponse:!0,latency:50,fixturesForType:function(a){if(a.FIXTURES){var b=Ember.A(a.FIXTURES);return b.map(function(a){var b=typeof a.id;if("number"!==b&&"string"!==b)throw new Error(d("the id property must be defined as a number or string for fixture %@",[a]));return a.id=a.id+"",a})}return null},queryFixtures:function(){},updateFixtures:function(a,b){a.FIXTURES||(a.FIXTURES=[]);var c=a.FIXTURES;this.deleteLoadedFixture(a,b),c.push(b)},mockJSON:function(a,b,c){return a.serializerFor(b).serialize(c,{includeId:!0})},generateIdForRecord:function(){return"fixture-"+f++},find:function(a,b,c){var d,e=this.fixturesForType(b);return e&&(d=Ember.A(e).findProperty("id",c)),d?this.simulateRemoteCall(function(){return d},this):void 0},findMany:function(a,b,c){var d=this.fixturesForType(b);return d&&(d=d.filter(function(a){return-1!==e(c,a.id)})),d?this.simulateRemoteCall(function(){return d},this):void 0},findAll:function(a,b){var c=this.fixturesForType(b);return this.simulateRemoteCall(function(){return c},this)},findQuery:function(a,b,c){var d=this.fixturesForType(b);return d=this.queryFixtures(d,c,b),d?this.simulateRemoteCall(function(){return d},this):void 0},createRecord:function(a,b,c){var d=this.mockJSON(a,b,c);return this.updateFixtures(b,d),this.simulateRemoteCall(function(){return d},this)},updateRecord:function(a,b,c){var d=this.mockJSON(a,b,c);return this.updateFixtures(b,d),this.simulateRemoteCall(function(){return d},this)},deleteRecord:function(a,b,c){var d=this.mockJSON(a,b,c);return this.deleteLoadedFixture(b,d),this.simulateRemoteCall(function(){return null})},deleteLoadedFixture:function(a,b){var c=this.findExistingFixture(a,b);if(c){var d=e(a.FIXTURES,c);return a.FIXTURES.splice(d,1),!0}},findExistingFixture:function(a,b){var d=this.fixturesForType(a),e=c(b,"id");return this.findFixtureById(d,e)},findFixtureById:function(a,b){return Ember.A(a).find(function(a){return""+c(a,"id")==""+b?!0:!1})},simulateRemoteCall:function(a,b){var d=this;return new Ember.RSVP.Promise(function(e){c(d,"simulateRemoteResponse")?Ember.run.later(function(){e(a.call(b))},c(d,"latency")):Ember.run.schedule("actions",null,function(){e(a.call(b))})},"DS: FixtureAdapter#simulateRemoteCall")}});b["default"]=h}),b("ember-data/lib/adapters/rest_adapter",["../system/adapter","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.get,e=(Ember.set,Ember.ArrayPolyfills.forEach),f=c.extend({defaultSerializer:"-rest",find:function(a,b,c){return this.ajax(this.buildURL(b.typeKey,c),"GET")},findAll:function(a,b,c){var d;return c&&(d={since:c}),this.ajax(this.buildURL(b.typeKey),"GET",{data:d})},findQuery:function(a,b,c){return this.ajax(this.buildURL(b.typeKey),"GET",{data:c})},findMany:function(a,b,c){return this.ajax(this.buildURL(b.typeKey),"GET",{data:{ids:c}})},findHasMany:function(a,b,c){var e=d(this,"host"),f=d(b,"id"),g=b.constructor.typeKey;return e&&"/"===c.charAt(0)&&"/"!==c.charAt(1)&&(c=e+c),this.ajax(this.urlPrefix(c,this.buildURL(g,f)),"GET")},findBelongsTo:function(a,b,c){var e=d(b,"id"),f=b.constructor.typeKey;return this.ajax(this.urlPrefix(c,this.buildURL(f,e)),"GET")},createRecord:function(a,b,c){var d={},e=a.serializerFor(b.typeKey);return e.serializeIntoHash(d,b,c,{includeId:!0}),this.ajax(this.buildURL(b.typeKey),"POST",{data:d})},updateRecord:function(a,b,c){var e={},f=a.serializerFor(b.typeKey);f.serializeIntoHash(e,b,c);var g=d(c,"id");return this.ajax(this.buildURL(b.typeKey,g),"PUT",{data:e})},deleteRecord:function(a,b,c){var e=d(c,"id");return this.ajax(this.buildURL(b.typeKey,e),"DELETE")},buildURL:function(a,b){var c=[],e=d(this,"host"),f=this.urlPrefix();return a&&c.push(this.pathForType(a)),b&&c.push(b),f&&c.unshift(f),c=c.join("/"),!e&&c&&(c="/"+c),c},urlPrefix:function(a,b){var c=d(this,"host"),e=d(this,"namespace"),f=[];return a?"/"===a.charAt(0)?c&&(a=a.slice(1),f.push(c)):/^http(s)?:\/\//.test(a)||f.push(b):(c&&f.push(c),e&&f.push(e)),a&&f.push(a),f.join("/")},pathForType:function(a){var b=Ember.String.camelize(a);return Ember.String.pluralize(b)},ajaxError:function(a){return a&&(a.then=null),a},ajax:function(a,b,c){var d=this;return new Ember.RSVP.Promise(function(e,f){c=d.ajaxOptions(a,b,c),c.success=function(a){Ember.run(null,e,a)},c.error=function(a){Ember.run(null,f,d.ajaxError(a))},Ember.$.ajax(c)},"DS: RestAdapter#ajax "+b+" to "+a)},ajaxOptions:function(a,b,c){if(c=c||{},c.url=a,c.type=b,c.dataType="json",c.context=this,c.data&&"GET"!==b&&(c.contentType="application/json; charset=utf-8",c.data=JSON.stringify(c.data)),void 0!==this.headers){var d=this.headers;c.beforeSend=function(a){e.call(Ember.keys(d),function(b){a.setRequestHeader(b,d[b])})}}return c}});b["default"]=f}),b("ember-data/lib/core",["exports"],function(a){"use strict";var b;"undefined"==typeof b&&(b=Ember.Namespace.create({VERSION:"1.0.0-beta.7+canary.f482da04"}),"undefined"!=typeof window&&(window.DS=b),Ember.libraries&&Ember.libraries.registerCoreLibrary("Ember Data",b.VERSION)),a["default"]=b}),b("ember-data/lib/ext/date",[],function(){"use strict";Ember.Date=Ember.Date||{};var a=Date.parse,b=[1,4,5,6,7,10,11];Ember.Date.parse=function(c){var d,e,f=0;if(e=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(c)){for(var g,h=0;g=b[h];++h)e[g]=+e[g]||0;e[2]=(+e[2]||1)-1,e[3]=+e[3]||1,"Z"!==e[8]&&void 0!==e[9]&&(f=60*e[10]+e[11],"+"===e[9]&&(f=0-f)),d=Date.UTC(e[1],e[2],e[3],e[4],e[5]+f,e[6],e[7])}else d=a?a(c):0/0;return d},(Ember.EXTEND_PROTOTYPES===!0||Ember.EXTEND_PROTOTYPES.Date)&&(Date.parse=Ember.Date.parse)}),b("ember-data/lib/initializers",["./system/store","./serializers","./adapters","./system/debug/debug_adapter","./system/container_proxy","./transforms"],function(a,b,c,d,e,f){"use strict";{var g=a["default"],h=b.JSONSerializer,i=b.RESTSerializer,j=c.RESTAdapter,k=d["default"],l=e["default"],m=f.BooleanTransform,n=f.DateTransform,o=f.StringTransform,p=f.NumberTransform;Ember.set}Ember.onLoad("Ember.Application",function(a){a.initializer({name:"store",initialize:function(a,b){b.register("store:main",b.Store||g);var c=new l(a);c.registerDeprecations([{deprecated:"serializer:_default",valid:"serializer:-default"},{deprecated:"serializer:_rest",valid:"serializer:-rest"},{deprecated:"adapter:_rest",valid:"adapter:-rest"}]),b.register("serializer:-default",h),b.register("serializer:-rest",i),b.register("adapter:-rest",j),a.lookup("store:main")}}),a.initializer({name:"transforms",before:"store",initialize:function(a,b){b.register("transform:boolean",m),b.register("transform:date",n),b.register("transform:number",p),b.register("transform:string",o)}}),a.initializer({name:"data-adapter",before:"store",initialize:function(a,b){b.register("data-adapter:main",k)}}),a.initializer({name:"injectStore",before:"store",initialize:function(a,b){b.inject("controller","store","store:main"),b.inject("route","store","store:main"),b.inject("serializer","store","store:main"),b.inject("data-adapter","store","store:main")}})})}),b("ember-data/lib/main",["./core","./ext/date","./system/store","./system/model","./system/changes","./system/adapter","./system/debug","./system/record_arrays","./system/record_array_manager","./adapters","./serializers/json_serializer","./serializers/rest_serializer","../../ember-inflector/lib/main","../../activemodel-adapter/lib/main","./transforms","./system/relationships","./initializers","./system/container_proxy","exports"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){"use strict";Ember.RSVP.Promise.cast=Ember.RSVP.Promise.cast||Ember.RSVP.resolve;var t=a["default"],u=c.Store,v=c.PromiseArray,w=c.PromiseObject,x=d.Model,y=d.Errors,z=d.RootState,A=d.attr,B=e.AttributeChange,C=e.RelationshipChange,D=e.RelationshipChangeAdd,E=(e.RelationshipChangeRemove,e.OneToManyChange),F=(e.ManyToNoneChange,e.OneToOneChange),G=e.ManyToManyChange,H=f.InvalidError,I=f.Adapter,J=g["default"],K=h.RecordArray,L=h.FilteredRecordArray,M=h.AdapterPopulatedRecordArray,N=h.ManyArray,O=i["default"],P=j.RESTAdapter,Q=j.FixtureAdapter,R=k["default"],S=l["default"],T=n.ActiveModelAdapter,U=n.ActiveModelSerializer,V=n.EmbeddedRecordsMixin,W=o.Transform,X=o.DateTransform,Y=o.NumberTransform,Z=o.StringTransform,$=o.BooleanTransform,_=p.hasMany,ab=p.belongsTo,bb=r["default"];t.Store=u,t.PromiseArray=v,t.PromiseObject=w,t.Model=x,t.RootState=z,t.attr=A,t.Errors=y,t.AttributeChange=B,t.RelationshipChange=C,t.RelationshipChangeAdd=D,t.OneToManyChange=E,t.ManyToNoneChange=E,t.OneToOneChange=F,t.ManyToManyChange=G,t.Adapter=I,t.InvalidError=H,t.DebugAdapter=J,t.RecordArray=K,t.FilteredRecordArray=L,t.AdapterPopulatedRecordArray=M,t.ManyArray=N,t.RecordArrayManager=O,t.RESTAdapter=P,t.FixtureAdapter=Q,t.RESTSerializer=S,t.JSONSerializer=R,t.Transform=W,t.DateTransform=X,t.StringTransform=Z,t.NumberTransform=Y,t.BooleanTransform=$,t.ActiveModelAdapter=T,t.ActiveModelSerializer=U,t.EmbeddedRecordsMixin=V,t.belongsTo=ab,t.hasMany=_,t.ContainerProxy=bb,s["default"]=t}),b("ember-data/lib/serializers",["./serializers/json_serializer","./serializers/rest_serializer","exports"],function(a,b,c){"use strict";var d=a["default"],e=b["default"];c.JSONSerializer=d,c.RESTSerializer=e}),b("ember-data/lib/serializers/json_serializer",["exports"],function(a){"use strict";var b=Ember.get,c=(Ember.set,Ember.isNone),d=Ember.Object.extend({primaryKey:"id",applyTransforms:function(a,b){return a.eachTransformedAttribute(function(a,c){var d=this.transformFor(c);b[a]=d.deserialize(b[a])},this),b},normalize:function(a,b){return b?(this.applyTransforms(a,b),b):b},serialize:function(a,c){var d={};if(c&&c.includeId){var e=b(a,"id");e&&(d[b(this,"primaryKey")]=e)}return a.eachAttribute(function(b,c){this.serializeAttribute(a,d,b,c)},this),a.eachRelationship(function(b,c){"belongsTo"===c.kind?this.serializeBelongsTo(a,d,c):"hasMany"===c.kind&&this.serializeHasMany(a,d,c)},this),d},serializeAttribute:function(a,c,d,e){var f=b(this,"attrs"),g=b(a,d),h=e.type;if(h){var i=this.transformFor(h);g=i.serialize(g)}d=f&&f[d]||(this.keyForAttribute?this.keyForAttribute(d):d),c[d]=g},serializeBelongsTo:function(a,d,e){var f=e.key,g=b(a,f);f=this.keyForRelationship?this.keyForRelationship(f,"belongsTo"):f,d[f]=c(g)?g:b(g,"id"),e.options.polymorphic&&this.serializePolymorphicType(a,d,e)},serializeHasMany:function(a,c,d){var e=d.key,f=DS.RelationshipChange.determineRelationshipType(a.constructor,d);("manyToNone"===f||"manyToMany"===f)&&(c[e]=b(a,e).mapBy("id"))},serializePolymorphicType:Ember.K,extract:function(a,b,c,d,e){this.extractMeta(a,b,c);var f="extract"+e.charAt(0).toUpperCase()+e.substr(1);return this[f](a,b,c,d,e)},extractFindAll:function(a,b,c){return this.extractArray(a,b,c)},extractFindQuery:function(a,b,c){return this.extractArray(a,b,c)},extractFindMany:function(a,b,c){return this.extractArray(a,b,c)},extractFindHasMany:function(a,b,c){return this.extractArray(a,b,c)},extractCreateRecord:function(a,b,c){return this.extractSave(a,b,c)},extractUpdateRecord:function(a,b,c){return this.extractSave(a,b,c)},extractDeleteRecord:function(a,b,c){return this.extractSave(a,b,c)},extractFind:function(a,b,c){return this.extractSingle(a,b,c)},extractFindBelongsTo:function(a,b,c){return this.extractSingle(a,b,c)},extractSave:function(a,b,c){return this.extractSingle(a,b,c)},extractSingle:function(a,b,c){return this.normalize(b,c)},extractArray:function(a,b,c){return this.normalize(b,c)},extractMeta:function(a,b,c){c&&c.meta&&(a.metaForType(b,c.meta),delete c.meta)},transformFor:function(a){var b=this.container.lookup("transform:"+a);return b}});a["default"]=d}),b("ember-data/lib/serializers/rest_serializer",["./json_serializer","exports"],function(a,b){"use strict";function c(a){return null==a?null:a+""}var d=a["default"],e=Ember.get,f=(Ember.set,Ember.ArrayPolyfills.forEach),g=Ember.ArrayPolyfills.map,h=d.extend({normalize:function(a,b,c){return this.normalizeId(b),this.normalizeAttributes(a,b),this.normalizeRelationships(a,b),this.normalizeUsingDeclaredMapping(a,b),this.normalizeHash&&this.normalizeHash[c]&&this.normalizeHash[c](b),this._super(a,b,c)},normalizePayload:function(a,b){return b},normalizeId:function(a){var b=e(this,"primaryKey");"id"!==b&&(a.id=a[b],delete a[b])},normalizeUsingDeclaredMapping:function(a,b){var c,d,f=e(this,"attrs");if(f)for(d in f)c=f[d],c&&c.key&&(c=c.key),"string"==typeof c&&(b[d]=b[c],delete b[c])},normalizeAttributes:function(a,b){var c;this.keyForAttribute&&a.eachAttribute(function(a){c=this.keyForAttribute(a),a!==c&&(b[a]=b[c],delete b[c])},this)},normalizeRelationships:function(a,b){var c;this.keyForRelationship&&a.eachRelationship(function(a,d){c=this.keyForRelationship(a,d.kind),a!==c&&(b[a]=b[c],delete b[c])},this)},extractSingle:function(a,b,d,e){d=this.normalizePayload(b,d);var g,h=b.typeKey;for(var i in d){var j=this.typeForRoot(i),k=a.modelFor(j),l=k.typeKey===h;l&&"array"!==Ember.typeOf(d[i])?g=this.normalize(b,d[i],i):f.call(d[i],function(b){var d=this.typeForRoot(i),f=a.modelFor(d),h=a.serializerFor(f);b=h.normalize(f,b,i);var j=l&&!e&&!g,k=l&&c(b.id)===e;j||k?g=b:a.push(d,b)},this)}return g},extractArray:function(a,b,c){c=this.normalizePayload(b,c);var d,e=b.typeKey;for(var f in c){var h=f,i=!1;"_"===f.charAt(0)&&(i=!0,h=f.substr(1));var j=this.typeForRoot(h),k=a.modelFor(j),l=a.serializerFor(k),m=!i&&k.typeKey===e,n=g.call(c[f],function(a){return l.normalize(k,a,f)},this);m?d=n:a.pushMany(j,n)}return d},pushPayload:function(a,b){b=this.normalizePayload(null,b);for(var c in b){var d=this.typeForRoot(c),e=a.modelFor(d),f=g.call(Ember.makeArray(b[c]),function(a){return this.normalize(e,a,c)},this);a.pushMany(d,f)}},typeForRoot:function(a){return Ember.String.singularize(a)},serialize:function(){return this._super.apply(this,arguments)},serializeIntoHash:function(a,b,c,d){var e=Ember.String.camelize(b.typeKey);a[e]=this.serialize(c,d)},serializePolymorphicType:function(a,b,c){var d=c.key,f=e(a,d);d=this.keyForAttribute?this.keyForAttribute(d):d,b[d+"Type"]=Ember.String.camelize(f.constructor.typeKey)}});b["default"]=h}),b("ember-data/lib/system/adapter",["exports"],function(a){"use strict";var b=Ember.get,c=(Ember.set,Ember.ArrayPolyfills.map),d=["description","fileName","lineNumber","message","name","number","stack"],e=function(a){var b=Error.prototype.constructor.call(this,"The backend rejected the commit because it was invalid: "+Ember.inspect(a));this.errors=a;for(var c=0,e=d.length;e>c;c++)this[d[c]]=b[d[c]]};e.prototype=Ember.create(Error.prototype);var f=Ember.Object.extend({find:Ember.required(Function),findAll:null,findQuery:null,generateIdForRecord:null,serialize:function(a,c){return b(a,"store").serializerFor(a.constructor.typeKey).serialize(a,c)},createRecord:Ember.required(Function),updateRecord:Ember.required(Function),deleteRecord:Ember.required(Function),findMany:function(a,b,d){var e=c.call(d,function(c){return this.find(a,b,c)},this);return Ember.RSVP.all(e)}});a.InvalidError=e,a.Adapter=f,a["default"]=f}),b("ember-data/lib/system/changes",["./changes/attribute_change","./changes/relationship_change","exports"],function(a,b,c){"use strict";var d=a["default"],e=b.RelationshipChange,f=b.RelationshipChangeAdd,g=b.RelationshipChangeRemove,h=b.OneToManyChange,i=b.ManyToNoneChange,j=b.OneToOneChange,k=b.ManyToManyChange;c.AttributeChange=d,c.RelationshipChange=e,c.RelationshipChangeAdd=f,c.RelationshipChangeRemove=g,c.OneToManyChange=h,c.ManyToNoneChange=i,c.OneToOneChange=j,c.ManyToManyChange=k}),b("ember-data/lib/system/changes/attribute_change",["exports"],function(a){"use strict";function b(a){this.record=a.record,this.store=a.store,this.name=a.name,this.value=a.value,this.oldValue=a.oldValue}b.createChange=function(a){return new b(a)},b.prototype={sync:function(){this.value!==this.oldValue&&(this.record.send("becomeDirty"),this.record.updateRecordArraysLater()),this.destroy()},destroy:function(){delete this.record._changesToSync[this.name]}},a["default"]=b}),b("ember-data/lib/system/changes/relationship_change",["../model","exports"],function(a,b){"use strict";function c(a){return"object"==typeof a&&(!a.then||"function"!=typeof a.then)}var d=a.Model,e=Ember.get,f=Ember.set,g=Ember.EnumerableUtils.forEach,h=function(a){this.parentRecord=a.parentRecord,this.childRecord=a.childRecord,this.firstRecord=a.firstRecord,this.firstRecordKind=a.firstRecordKind,this.firstRecordName=a.firstRecordName,this.secondRecord=a.secondRecord,this.secondRecordKind=a.secondRecordKind,this.secondRecordName=a.secondRecordName,this.changeType=a.changeType,this.store=a.store,this.committed={}},i=function(a){h.call(this,a)},j=function(a){h.call(this,a)};h.create=function(a){return new h(a)},i.create=function(a){return new i(a)},j.create=function(a){return new j(a)};var k={},l={},m={},n={},o={};h._createChange=function(a){return"add"===a.changeType?i.create(a):"remove"===a.changeType?j.create(a):void 0},h.determineRelationshipType=function(a,b){var c,d,e=b.key,f=b.kind,g=a.inverseFor(e);return g&&(c=g.name,d=g.kind),g?"belongsTo"===d?"belongsTo"===f?"oneToOne":"manyToOne":"belongsTo"===f?"oneToMany":"manyToMany":"belongsTo"===f?"oneToNone":"manyToNone"},h.createChange=function(a,b,c,d){var e,f=a.constructor;return e=h.determineRelationshipType(f,d),"oneToMany"===e?k.createChange(a,b,c,d):"manyToOne"===e?k.createChange(b,a,c,d):"oneToNone"===e?l.createChange(a,b,c,d):"manyToNone"===e?m.createChange(a,b,c,d):"oneToOne"===e?n.createChange(a,b,c,d):"manyToMany"===e?o.createChange(a,b,c,d):void 0},l.createChange=function(a,b,c,d){var e=d.key,f=h._createChange({parentRecord:b,childRecord:a,firstRecord:a,store:c,changeType:d.changeType,firstRecordName:e,firstRecordKind:"belongsTo"});return c.addRelationshipChangeFor(a,e,b,null,f),f},m.createChange=function(a,b,c,d){var e=d.key,f=h._createChange({parentRecord:a,childRecord:b,secondRecord:a,store:c,changeType:d.changeType,secondRecordName:d.key,secondRecordKind:"hasMany"});return c.addRelationshipChangeFor(a,e,b,null,f),f},o.createChange=function(a,b,c,d){var e=d.key,f=h._createChange({parentRecord:b,childRecord:a,firstRecord:a,secondRecord:b,firstRecordKind:"hasMany",secondRecordKind:"hasMany",store:c,changeType:d.changeType,firstRecordName:e});return c.addRelationshipChangeFor(a,e,b,null,f),f},n.createChange=function(a,b,c,d){var e;d.parentType?e=d.parentType.inverseFor(d.key).name:d.key&&(e=d.key);var f=h._createChange({parentRecord:b,childRecord:a,firstRecord:a,secondRecord:b,firstRecordKind:"belongsTo",secondRecordKind:"belongsTo",store:c,changeType:d.changeType,firstRecordName:e});return c.addRelationshipChangeFor(a,e,b,null,f),f},n.maintainInvariant=function(a,b,c,d){if("add"===a.changeType&&b.recordIsMaterialized(c)){var f=e(c,d);if(f){var g=n.createChange(c,f,b,{parentType:a.parentType,hasManyName:a.hasManyName,changeType:"remove",key:a.key});b.addRelationshipChangeFor(c,d,a.parentRecord,null,g),g.sync()}}},k.createChange=function(a,b,c,d){var e;d.parentType?(e=d.parentType.inverseFor(d.key).name,k.maintainInvariant(d,c,a,e)):d.key&&(e=d.key);var f=h._createChange({parentRecord:b,childRecord:a,firstRecord:a,secondRecord:b,firstRecordKind:"belongsTo",secondRecordKind:"hasMany",store:c,changeType:d.changeType,firstRecordName:e});return c.addRelationshipChangeFor(a,e,b,f.getSecondRecordName(),f),f},k.maintainInvariant=function(a,b,c,d){if("add"===a.changeType&&c){var f=e(c,d);if(f){var g=k.createChange(c,f,b,{parentType:a.parentType,hasManyName:a.hasManyName,changeType:"remove",key:a.key});b.addRelationshipChangeFor(c,d,a.parentRecord,g.getSecondRecordName(),g),g.sync()}}},h.prototype={getSecondRecordName:function(){var a,b=this.secondRecordName;if(!b){if(a=this.secondRecord,!a)return;var c=this.firstRecord.constructor,d=c.inverseFor(this.firstRecordName);this.secondRecordName=d.name}return this.secondRecordName},getFirstRecordName:function(){var a=this.firstRecordName;return a},destroy:function(){var a=this.childRecord,b=this.getFirstRecordName(),c=this.getSecondRecordName(),d=this.store;d.removeRelationshipChangeFor(a,b,this.parentRecord,c,this.changeType)},getSecondRecord:function(){return this.secondRecord},getFirstRecord:function(){return this.firstRecord},coalesce:function(){var a=this.store.relationshipChangePairsFor(this.firstRecord);g(a,function(a){var b=a.add,c=a.remove;b&&c&&(b.destroy(),c.destroy())})}},i.prototype=Ember.create(h.create({})),j.prototype=Ember.create(h.create({})),i.prototype.changeType="add",i.prototype.sync=function(){var a=this.getSecondRecordName(),b=this.getFirstRecordName(),g=this.getFirstRecord(),h=this.getSecondRecord();h instanceof d&&g instanceof d&&("belongsTo"===this.secondRecordKind?h.suspendRelationshipObservers(function(){f(h,a,g)}):"hasMany"===this.secondRecordKind&&h.suspendRelationshipObservers(function(){var b=e(h,a);c(b)&&b.addObject(g)})),g instanceof d&&h instanceof d&&e(g,b)!==h&&("belongsTo"===this.firstRecordKind?g.suspendRelationshipObservers(function(){f(g,b,h)}):"hasMany"===this.firstRecordKind&&g.suspendRelationshipObservers(function(){var a=e(g,b);c(a)&&a.addObject(h)})),this.coalesce()},j.prototype.changeType="remove",j.prototype.sync=function(){var a=this.getSecondRecordName(),b=this.getFirstRecordName(),g=this.getFirstRecord(),h=this.getSecondRecord();h instanceof d&&g instanceof d&&("belongsTo"===this.secondRecordKind?h.suspendRelationshipObservers(function(){f(h,a,null)}):"hasMany"===this.secondRecordKind&&h.suspendRelationshipObservers(function(){var b=e(h,a);c(b)&&b.removeObject(g)})),g instanceof d&&e(g,b)&&("belongsTo"===this.firstRecordKind?g.suspendRelationshipObservers(function(){f(g,b,null)}):"hasMany"===this.firstRecordKind&&g.suspendRelationshipObservers(function(){var a=e(g,b);c(a)&&a.removeObject(h)})),this.coalesce()},b.RelationshipChange=h,b.RelationshipChangeAdd=i,b.RelationshipChangeRemove=j,b.OneToManyChange=k,b.ManyToNoneChange=m,b.OneToOneChange=n,b.ManyToManyChange=o}),b("ember-data/lib/system/container_proxy",["exports"],function(a){"use strict";var b=function(a){this.container=a};b.prototype.aliasedFactory=function(a,b){var c=this;return{create:function(){return b&&b(),c.container.lookup(a)}}},b.prototype.registerAlias=function(a,b,c){var d=this.aliasedFactory(b,c);return this.container.register(a,d)},b.prototype.registerDeprecation=function(a,b){var c=function(){};return this.registerAlias(a,b,c)},b.prototype.registerDeprecations=function(a){for(var b=a.length;b>0;b--){var c=a[b-1],d=c.deprecated,e=c.valid;this.registerDeprecation(d,e)}},a["default"]=b}),b("ember-data/lib/system/debug",["./debug/debug_info","./debug/debug_adapter","exports"],function(a,b,c){"use strict";var d=b["default"];c["default"]=d}),b("ember-data/lib/system/debug/debug_adapter",["../model","exports"],function(a,b){"use strict";var c=a.Model,d=Ember.get,e=Ember.String.capitalize,f=Ember.String.underscore,g=Ember.DataAdapter.extend({getFilters:function(){return[{name:"isNew",desc:"New"},{name:"isModified",desc:"Modified"},{name:"isClean",desc:"Clean"}]},detect:function(a){return a!==c&&c.detect(a)},columnsForType:function(a){var b=[{name:"id",desc:"Id"}],c=0,g=this;return d(a,"attributes").forEach(function(a){if(c++>g.attributeLimit)return!1;var d=e(f(a).replace("_"," "));b.push({name:a,desc:d})}),b},getRecords:function(a){return this.get("store").all(a)},getRecordColumnValues:function(a){var b=this,c=0,e={id:d(a,"id")};return a.eachAttribute(function(f){if(c++>b.attributeLimit)return!1;var g=d(a,f);e[f]=g}),e},getRecordKeywords:function(a){var b=[],c=Ember.A(["id"]);return a.eachAttribute(function(a){c.push(a)}),c.forEach(function(c){b.push(d(a,c))}),b},getRecordFilterValues:function(a){return{isNew:a.get("isNew"),isModified:a.get("isDirty")&&!a.get("isNew"),isClean:!a.get("isDirty")}},getRecordColor:function(a){var b="black";return a.get("isNew")?b="green":a.get("isDirty")&&(b="blue"),b},observeRecord:function(a,b){var c=Ember.A(),d=this,e=Ember.A(["id","isNew","isDirty"]);a.eachAttribute(function(a){e.push(a)}),e.forEach(function(e){var f=function(){b(d.wrapRecord(a))};Ember.addObserver(a,e,f),c.push(function(){Ember.removeObserver(a,e,f)})});var f=function(){c.forEach(function(a){a()})};return f}});b["default"]=g}),b("ember-data/lib/system/debug/debug_info",["../model","exports"],function(a,b){"use strict";var c=a.Model;c.reopen({_debugInfo:function(){var a=["id"],b={belongsTo:[],hasMany:[]},c=[];this.eachAttribute(function(b){a.push(b)},this),this.eachRelationship(function(a,d){b[d.kind].push(a),c.push(a)});var d=[{name:"Attributes",properties:a,expand:!0},{name:"Belongs To",properties:b.belongsTo,expand:!0},{name:"Has Many",properties:b.hasMany,expand:!0},{name:"Flags",properties:["isLoaded","isDirty","isSaving","isDeleted","isError","isNew","isValid"]}];return{propertyInfo:{includeOtherProperties:!0,groups:d,expensiveProperties:c}}}}),b["default"]=c}),b("ember-data/lib/system/model",["./model/model","./model/attributes","./model/states","./model/errors","exports"],function(a,b,c,d,e){"use strict";var f=a["default"],g=b["default"],h=c["default"],i=d["default"];e.Model=f,e.RootState=h,e.attr=g,e.Errors=i}),b("ember-data/lib/system/model/attributes",["./model","exports"],function(a,b){"use strict";function c(a,b){return"function"==typeof b.defaultValue?b.defaultValue.apply(null,arguments):b.defaultValue}function d(a,b){return a._attributes.hasOwnProperty(b)||a._inFlightAttributes.hasOwnProperty(b)||a._data.hasOwnProperty(b)}function e(a,b){return a._attributes.hasOwnProperty(b)?a._attributes[b]:a._inFlightAttributes.hasOwnProperty(b)?a._inFlightAttributes[b]:a._data[b]}function f(a,b){b=b||{};var f={type:a,isAttribute:!0,options:b};return Ember.computed("data",function(a,f){if(arguments.length>1){var g=e(this,a);return f!==g&&(this._attributes[a]=f,this.send("didSetProperty",{name:a,oldValue:g,originalValue:this._data[a],value:f})),f}return d(this,a)?e(this,a):c(this,b,a)}).meta(f)}var g=a["default"],h=Ember.get;g.reopenClass({attributes:Ember.computed(function(){var a=Ember.Map.create();return this.eachComputedProperty(function(b,c){c.isAttribute&&(c.name=b,a.set(b,c))}),a}),transformedAttributes:Ember.computed(function(){var a=Ember.Map.create();return this.eachAttribute(function(b,c){c.type&&a.set(b,c.type)}),a}),eachAttribute:function(a,b){h(this,"attributes").forEach(function(c,d){a.call(b,c,d)},b)},eachTransformedAttribute:function(a,b){h(this,"transformedAttributes").forEach(function(c,d){a.call(b,c,d)})}}),g.reopen({eachAttribute:function(a,b){this.constructor.eachAttribute(a,b)}}),b["default"]=f
9
- }),b("ember-data/lib/system/model/errors",["exports"],function(a){"use strict";var b=Ember.get,c=Ember.isEmpty,d=Ember.Object.extend(Ember.Enumerable,Ember.Evented,{registerHandlers:function(a,b,c){this.on("becameInvalid",a,b),this.on("becameValid",a,c)},errorsByAttributeName:Ember.reduceComputed("content",{initialValue:function(){return Ember.MapWithDefault.create({defaultValue:function(){return Ember.A()}})},addedItem:function(a,b){return a.get(b.attribute).pushObject(b),a},removedItem:function(a,b){return a.get(b.attribute).removeObject(b),a}}),errorsFor:function(a){return b(this,"errorsByAttributeName").get(a)},messages:Ember.computed.mapBy("content","message"),content:Ember.computed(function(){return Ember.A()}),unknownProperty:function(a){var b=this.errorsFor(a);return c(b)?null:b},nextObject:function(a){return b(this,"content").objectAt(a)},length:Ember.computed.oneWay("content.length").readOnly(),isEmpty:Ember.computed.not("length").readOnly(),add:function(a,c){var d=b(this,"isEmpty");c=this._findOrCreateMessages(a,c),b(this,"content").addObjects(c),this.notifyPropertyChange(a),this.enumerableContentDidChange(),d&&!b(this,"isEmpty")&&this.trigger("becameInvalid")},_findOrCreateMessages:function(a,b){var c=this.errorsFor(a);return Ember.makeArray(b).map(function(b){return c.findBy("message",b)||{attribute:a,message:b}})},remove:function(a){if(!b(this,"isEmpty")){var c=b(this,"content").rejectBy("attribute",a);b(this,"content").setObjects(c),this.notifyPropertyChange(a),this.enumerableContentDidChange(),b(this,"isEmpty")&&this.trigger("becameValid")}},clear:function(){b(this,"isEmpty")||(b(this,"content").clear(),this.enumerableContentDidChange(),this.trigger("becameValid"))},has:function(a){return!c(this.errorsFor(a))}});a["default"]=d}),b("ember-data/lib/system/model/model",["./states","./errors","exports"],function(a,b,c){"use strict";var d=a["default"],e=b["default"],f=Ember.get,g=Ember.set,h=Ember.merge,i=Ember.RSVP.Promise,j=Ember.computed("currentState",function(a){return f(f(this,"currentState"),a)}).readOnly(),k=Ember.Object.extend(Ember.Evented,{_recordArrays:void 0,_relationships:void 0,_loadingRecordArrays:void 0,isEmpty:j,isLoading:j,isLoaded:j,isDirty:j,isSaving:j,isDeleted:j,isNew:j,isValid:j,dirtyType:j,isError:!1,isReloading:!1,clientId:null,id:null,currentState:d.empty,errors:Ember.computed(function(){var a=e.create();return a.registerHandlers(this,function(){this.send("becameInvalid")},function(){this.send("becameValid")}),a}).readOnly(),serialize:function(a){var b=f(this,"store");return b.serialize(this,a)},toJSON:function(a){var b=DS.JSONSerializer.create({container:this.container});return b.serialize(this,a)},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}).readOnly(),_data:null,init:function(){this._super(),this._setup()},_setup:function(){this._changesToSync={},this._deferredTriggers=[],this._data={},this._attributes={},this._inFlightAttributes={},this._relationships={}},send:function(a,b){var c=f(this,"currentState");return c[a]||this._unhandledEvent(c,a,b),c[a](this,b)},transitionTo:function(a){var b=a.split(".",1),c=f(this,"currentState"),d=c;do d.exit&&d.exit(this),d=d.parentState;while(!d.hasOwnProperty(b));var e,h,i=a.split("."),j=[],k=[];for(e=0,h=i.length;h>e;e++)d=d[i[e]],d.enter&&k.push(d),d.setup&&j.push(d);for(e=0,h=k.length;h>e;e++)k[e].enter(this);for(g(this,"currentState",d),e=0,h=j.length;h>e;e++)j[e].setup(this);this.updateRecordArraysLater()},_unhandledEvent:function(a,b,c){var d="Attempted to handle event `"+b+"` ";throw d+="on "+String(this)+" while in state ",d+=a.stateName+". ",void 0!==c&&(d+="Called with "+Ember.inspect(c)+"."),new Ember.Error(d)},withTransaction:function(a){var b=f(this,"transaction");b&&a(b)},loadingData:function(a){this.send("loadingData",a)},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.isDestroyed||this.send("unloadRecord")},clearRelationships:function(){this.eachRelationship(function(a,b){if("belongsTo"===b.kind)g(this,a,null);else if("hasMany"===b.kind){var c=this._relationships[a];c&&c.destroy()}},this)},updateRecordArrays:function(){this._updatingRecordArraysLater=!1,f(this,"store").dataWasUpdated(this.constructor,this)},changedAttributes:function(){var a,b=f(this,"_data"),c=f(this,"_attributes"),d={};for(a in c)d[a]=[b[a],c[a]];return d},adapterWillCommit:function(){this.send("willCommit")},adapterDidCommit:function(a){g(this,"isError",!1),a?this._data=a:Ember.mixin(this._data,this._inFlightAttributes),this._inFlightAttributes={},this.send("didCommit"),this.updateRecordArraysLater(),a&&this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},adapterDidDirty:function(){this.send("becomeDirty"),this.updateRecordArraysLater()},dataDidChange:Ember.observer(function(){this.reloadHasManys()},"data"),reloadHasManys:function(){var a=f(this.constructor,"relationshipsByName");this.updateRecordArraysLater(),a.forEach(function(a,b){this._data.links&&this._data.links[a]||"hasMany"===b.kind&&this.hasManyDidChange(b.key)},this)},hasManyDidChange:function(a){var b=this._relationships[a];if(b){var c=this._data[a]||[];g(b,"content",Ember.A(c)),g(b,"isLoaded",!0),b.trigger("didLoad")}},updateRecordArraysLater:function(){this._updatingRecordArraysLater||(this._updatingRecordArraysLater=!0,Ember.run.schedule("actions",this,this.updateRecordArrays))},setupData:function(a,b){b?Ember.merge(this._data,a):this._data=a;var c=this._relationships;this.eachRelationship(function(b,d){a.links&&a.links[b]||d.options.async&&(c[b]=null)}),a&&this.pushedData(),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},materializeId:function(a){g(this,"id",a)},materializeAttributes:function(a){h(this._data,a)},materializeAttribute:function(a,b){this._data[a]=b},updateHasMany:function(a,b){this._data[a]=b,this.hasManyDidChange(a)},updateBelongsTo:function(a,b){this._data[a]=b},rollback:function(){this._attributes={},f(this,"isError")&&(this._inFlightAttributes={},g(this,"isError",!1)),f(this,"isValid")||(this._inFlightAttributes={}),this.send("rolledBack"),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},toStringExtension:function(){return f(this,"id")},suspendRelationshipObservers:function(a,b){var c=f(this.constructor,"relationshipNames").belongsTo,d=this;try{this._suspendedRelationships=!0,Ember._suspendObservers(d,c,null,"belongsToDidChange",function(){Ember._suspendBeforeObservers(d,c,null,"belongsToWillChange",function(){a.call(b||d)})})}finally{this._suspendedRelationships=!1}},save:function(){var a="DS: Model#save "+this,b=Ember.RSVP.defer(a);return this.get("store").scheduleSave(this,b),this._inFlightAttributes=this._attributes,this._attributes={},DS.PromiseObject.create({promise:b.promise})},reload:function(){g(this,"isReloading",!0);var a=this,b="DS: Model#reload of "+this,c=new i(function(b){a.send("reloadRecord",b)},b).then(function(){return a.set("isReloading",!1),a.set("isError",!1),a},function(b){throw a.set("isError",!0),b},"DS: Model#reload complete, update flags");return DS.PromiseObject.create({promise:c})},adapterDidUpdateAttribute:function(a,b){void 0!==b?(this._data[a]=b,this.notifyPropertyChange(a)):this._data[a]=this._inFlightAttributes[a],this.updateRecordArraysLater()},adapterDidInvalidate:function(a){function b(b){a[b]&&c.add(b,a[b])}var c=f(this,"errors");this.eachAttribute(b),this.eachRelationship(b)},adapterDidError:function(){this.send("becameError"),g(this,"isError",!0)},trigger:function(a){Ember.tryInvoke(this,a,[].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 a=0,b=this._deferredTriggers.length;b>a;a++)this.trigger.apply(this,this._deferredTriggers[a]);this._deferredTriggers.length=0},willDestroy:function(){this._super(),this.clearRelationships()}});k.reopenClass({_create:k.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.")}}),c["default"]=k}),b("ember-data/lib/system/model/states",["exports"],function(a){"use strict";function b(a,b){b.value===b.originalValue?(delete a._attributes[b.name],a.send("propertyWasReset",b.name)):b.value!==b.oldValue&&a.send("becomeDirty"),a.updateRecordArraysLater()}function c(a){var b,d={};for(var e in a)b=a[e],d[e]=b&&"object"==typeof b?c(b):b;return d}function d(a,b){for(var c in b)a[c]=b[c];return a}function e(a){var b=c(j);return d(b,a)}function f(){}function g(a,b,c){a=d(b?Ember.create(b):{},a),a.parentState=b,a.stateName=c;for(var e in a)a.hasOwnProperty(e)&&"parentState"!==e&&"stateName"!==e&&"object"==typeof a[e]&&(a[e]=g(a[e],a,c+"."+e));return a}var h=Ember.get,i=Ember.set,j={initialState:"uncommitted",isDirty:!0,uncommitted:{didSetProperty:b,propertyWasReset:function(a){var b=!1;for(var c in a._attributes){b=!0;break}b||a.send("rolledBack")},pushedData:Ember.K,becomeDirty:Ember.K,willCommit:function(a){a.transitionTo("inFlight")},reloadRecord:function(a,b){b(h(a,"store").reloadRecord(a))},rolledBack:function(a){a.transitionTo("loaded.saved")},becameInvalid:function(a){a.transitionTo("invalid")},rollback:function(a){a.rollback()}},inFlight:{isSaving:!0,didSetProperty:b,becomeDirty:Ember.K,pushedData:Ember.K,unloadRecord:function(){},willCommit:Ember.K,didCommit:function(a){var b=h(this,"dirtyType");a.transitionTo("saved"),a.send("invokeLifecycleCallbacks",b)},becameInvalid:function(a){a.transitionTo("invalid"),a.send("invokeLifecycleCallbacks")},becameError:function(a){a.transitionTo("uncommitted"),a.triggerLater("becameError",a)}},invalid:{isValid:!1,deleteRecord:function(a){a.transitionTo("deleted.uncommitted"),a.clearRelationships()},didSetProperty:function(a,c){h(a,"errors").remove(c.name),b(a,c)},becomeDirty:Ember.K,rolledBack:function(a){h(a,"errors").clear()},becameValid:function(a){a.transitionTo("uncommitted")},invokeLifecycleCallbacks:function(a){a.triggerLater("becameInvalid",a)}}},k=e({dirtyType:"created",isNew:!0});k.uncommitted.rolledBack=function(a){a.transitionTo("deleted.saved")};var l=e({dirtyType:"updated"});k.uncommitted.deleteRecord=function(a){a.clearRelationships(),a.transitionTo("deleted.saved")},k.uncommitted.rollback=function(a){j.uncommitted.rollback.apply(this,arguments),a.transitionTo("deleted.saved")},k.uncommitted.propertyWasReset=Ember.K,l.inFlight.unloadRecord=f,l.uncommitted.deleteRecord=function(a){a.transitionTo("deleted.uncommitted"),a.clearRelationships()};var m={isEmpty:!1,isLoading:!1,isLoaded:!1,isDirty:!1,isSaving:!1,isDeleted:!1,isNew:!1,isValid:!0,rolledBack:Ember.K,unloadRecord:function(a){a.clearRelationships(),a.transitionTo("deleted.saved")},propertyWasReset:Ember.K,empty:{isEmpty:!0,loadingData:function(a,b){a._loadingPromise=b,a.transitionTo("loading")},loadedData:function(a){a.transitionTo("loaded.created.uncommitted"),a.suspendRelationshipObservers(function(){a.notifyPropertyChange("data")})},pushedData:function(a){a.transitionTo("loaded.saved"),a.triggerLater("didLoad")}},loading:{isLoading:!0,exit:function(a){a._loadingPromise=null},pushedData:function(a){a.transitionTo("loaded.saved"),a.triggerLater("didLoad"),i(a,"isError",!1)},becameError:function(a){a.triggerLater("becameError",a)},notFound:function(a){a.transitionTo("empty")}},loaded:{initialState:"saved",isLoaded:!0,saved:{setup:function(a){var b=a._attributes,c=!1;for(var d in b)if(b.hasOwnProperty(d)){c=!0;break}c&&a.adapterDidDirty()},didSetProperty:b,pushedData:Ember.K,becomeDirty:function(a){a.transitionTo("updated.uncommitted")},willCommit:function(a){a.transitionTo("updated.inFlight")},reloadRecord:function(a,b){b(h(a,"store").reloadRecord(a))},deleteRecord:function(a){a.transitionTo("deleted.uncommitted"),a.clearRelationships()},unloadRecord:function(a){a.clearRelationships(),a.transitionTo("deleted.saved")},didCommit:function(a){a.send("invokeLifecycleCallbacks",h(a,"lastDirtyType"))},notFound:Ember.K},created:k,updated:l},deleted:{initialState:"uncommitted",dirtyType:"deleted",isDeleted:!0,isLoaded:!0,isDirty:!0,setup:function(a){a.updateRecordArrays()},uncommitted:{willCommit:function(a){a.transitionTo("inFlight")},rollback:function(a){a.rollback()},becomeDirty:Ember.K,deleteRecord:Ember.K,rolledBack:function(a){a.transitionTo("loaded.saved")}},inFlight:{isSaving:!0,unloadRecord:f,willCommit:Ember.K,didCommit:function(a){a.transitionTo("saved"),a.send("invokeLifecycleCallbacks")},becameError:function(a){a.transitionTo("uncommitted"),a.triggerLater("becameError",a)}},saved:{isDirty:!1,setup:function(a){var b=h(a,"store");b.dematerializeRecord(a)},invokeLifecycleCallbacks:function(a){a.triggerLater("didDelete",a),a.triggerLater("didCommit",a)}}},invokeLifecycleCallbacks:function(a,b){"created"===b?a.triggerLater("didCreate",a):a.triggerLater("didUpdate",a),a.triggerLater("didCommit",a)}};m=g(m,null,"root"),a["default"]=m}),b("ember-data/lib/system/record_array_manager",["./record_arrays","exports"],function(a,b){"use strict";function c(a){for(var b=[],c=Ember.keys(a),d=0;d<c.length;d++)b.push(a[c[d]]);return b}function d(a){a.destroy()}function e(a){for(var b=a.length,c=Ember.A(),d=0;b>d;d++)c=c.concat(a[d]);return c}var f=a.ManyArray,g=Ember.get,h=(Ember.set,Ember.EnumerableUtils.forEach),i=Ember.Object.extend({init:function(){this.filteredRecordArrays=Ember.MapWithDefault.create({defaultValue:function(){return[]}}),this.changedRecords=[],this._adapterPopulatedRecordArrays=[]},recordDidChange:function(a){1===this.changedRecords.push(a)&&Ember.run.schedule("actions",this,this.updateRecordArrays)},recordArraysForRecord:function(a){return a._recordArrays=a._recordArrays||Ember.OrderedSet.create(),a._recordArrays},updateRecordArrays:function(){h(this.changedRecords,function(a){g(a,"isDeleted")?this._recordWasDeleted(a):this._recordWasChanged(a)},this),this.changedRecords.length=0},_recordWasDeleted:function(a){var b=a._recordArrays;b&&h(b,function(b){b.removeRecord(a)})},_recordWasChanged:function(a){var b,c=a.constructor,d=this.filteredRecordArrays.get(c);h(d,function(d){b=g(d,"filterFunction"),this.updateRecordArray(d,b,c,a)},this);var e=a._loadingRecordArrays;if(e){for(var f=0,i=e.length;i>f;f++)e[f].loadedRecord();a._loadingRecordArrays=[]}},updateRecordArray:function(a,b,c,d){var e;e=b?b(d):!0;var f=this.recordArraysForRecord(d);e?(f.add(a),a.addRecord(d)):e||(f.remove(a),a.removeRecord(d))},updateFilter:function(a,b,c){for(var d,e=this.store.typeMapFor(b),f=e.records,h=0,i=f.length;i>h;h++)d=f[h],g(d,"isDeleted")||g(d,"isEmpty")||this.updateRecordArray(a,c,b,d)},createManyArray:function(a,b){var c=f.create({type:a,content:b,store:this.store});return h(b,function(a){var b=this.recordArraysForRecord(a);b.add(c)},this),c},createRecordArray:function(a){var b=DS.RecordArray.create({type:a,content:Ember.A(),store:this.store,isLoaded:!0});return this.registerFilteredRecordArray(b,a),b},createFilteredRecordArray:function(a,b){var c=DS.FilteredRecordArray.create({type:a,content:Ember.A(),store:this.store,manager:this,filterFunction:b});return this.registerFilteredRecordArray(c,a,b),c},createAdapterPopulatedRecordArray:function(a,b){var c=DS.AdapterPopulatedRecordArray.create({type:a,query:b,content:Ember.A(),store:this.store});return this._adapterPopulatedRecordArrays.push(c),c},registerFilteredRecordArray:function(a,b,c){var d=this.filteredRecordArrays.get(b);d.push(a),this.updateFilter(a,b,c)},registerWaitingRecordArray:function(a,b){var c=a._loadingRecordArrays||[];c.push(b),a._loadingRecordArrays=c},willDestroy:function(){this._super(),e(c(this.filteredRecordArrays.values)).forEach(d),this._adapterPopulatedRecordArrays.forEach(d)}});b["default"]=i}),b("ember-data/lib/system/record_arrays",["./record_arrays/record_array","./record_arrays/filtered_record_array","./record_arrays/adapter_populated_record_array","./record_arrays/many_array","exports"],function(a,b,c,d,e){"use strict";var f=a["default"],g=b["default"],h=c["default"],i=d["default"];e.RecordArray=f,e.FilteredRecordArray=g,e.AdapterPopulatedRecordArray=h,e.ManyArray=i}),b("ember-data/lib/system/record_arrays/adapter_populated_record_array",["./record_array","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.get,e=(Ember.set,c.extend({query:null,replace:function(){var a=d(this,"type").toString();throw new Error("The result of a server query (on "+a+") is immutable.")},load:function(a){var b=d(this,"store"),c=d(this,"type"),e=b.pushMany(c,a),f=b.metadataFor(c);this.setProperties({content:Ember.A(e),isLoaded:!0,meta:f}),Ember.run.once(this,"trigger","didLoad")}}));b["default"]=e}),b("ember-data/lib/system/record_arrays/filtered_record_array",["./record_array","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.get,e=c.extend({filterFunction:null,isLoaded:!0,replace:function(){var a=d(this,"type").toString();throw new Error("The result of a client-side filter (on "+a+") is immutable.")},updateFilter:Ember.observer(function(){var a=d(this,"manager");a.updateFilter(this,d(this,"type"),d(this,"filterFunction"))},"filterFunction")});b["default"]=e}),b("ember-data/lib/system/record_arrays/many_array",["./record_array","../changes","exports"],function(a,b,c){"use strict";function d(a){a.sync()}var e=a["default"],f=b.RelationshipChange,g=Ember.get,h=Ember.set,i=Ember.EnumerableUtils.map,j=e.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(a){this.loadingRecordsCount=a},loadedRecord:function(){this.loadingRecordsCount--,0===this.loadingRecordsCount&&(h(this,"isLoaded",!0),this.trigger("didLoad"))},fetch:function(){var a=g(this,"content"),b=g(this,"store"),c=g(this,"owner"),d=Ember.RSVP.defer("DS: ManyArray#fetch "+g(this,"type")),e=a.filterProperty("isEmpty",!0);b.fetchMany(e,c,d)},replaceContent:function(a,b,c){c=i(c,function(a){return a},this),this._super(a,b,c)},arrangedContentDidChange:function(){Ember.run.once(this,"fetch")},arrayContentWillChange:function(a,b){var c=g(this,"owner"),d=g(this,"name");if(!c._suspendedRelationships)for(var e=a;a+b>e;e++){var h=g(this,"content").objectAt(e),i=f.createChange(c,h,g(this,"store"),{parentType:c.constructor,changeType:"remove",kind:"hasMany",key:d});this._changesToSync.add(i)}return this._super.apply(this,arguments)},arrayContentDidChange:function(a,b,c){this._super.apply(this,arguments);var e=g(this,"owner"),h=g(this,"name"),i=g(this,"store");if(!e._suspendedRelationships){for(var j=a;a+c>j;j++){var k=g(this,"content").objectAt(j),l=f.createChange(e,k,i,{parentType:e.constructor,changeType:"add",kind:"hasMany",key:h});l.hasManyName=h,this._changesToSync.add(l)}this._changesToSync.forEach(d),this._changesToSync.clear()}},createRecord:function(a){var b,c=g(this,"owner"),d=g(c,"store"),e=g(this,"type");return b=d.createRecord.call(d,e,a),this.pushObject(b),b}});c["default"]=j}),b("ember-data/lib/system/record_arrays/record_array",["../store","exports"],function(a,b){"use strict";var c=a.PromiseArray,d=Ember.get,e=(Ember.set,Ember.ArrayProxy.extend(Ember.Evented,{type:null,content:null,isLoaded:!1,isUpdating:!1,store:null,objectAtContent:function(a){var b=d(this,"content");return b.objectAt(a)},update:function(){if(!d(this,"isUpdating")){var a=d(this,"store"),b=d(this,"type");return a.fetchAll(b,this)}},addRecord:function(a){d(this,"content").addObject(a)},removeRecord:function(a){d(this,"content").removeObject(a)},save:function(){var a="DS: RecordArray#save "+d(this,"type"),b=Ember.RSVP.all(this.invoke("save"),a).then(function(a){return Ember.A(a)},null,"DS: RecordArray#save apply Ember.NativeArray");return c.create({promise:b})},_dissociateFromOwnRecords:function(){var a=this;this.forEach(function(b){var c=b._recordArrays;c&&c.remove(a)})},willDestroy:function(){this._dissociateFromOwnRecords(),this._super()}}));b["default"]=e}),b("ember-data/lib/system/relationships",["./relationships/belongs_to","./relationships/has_many","../system/relationships/ext","exports"],function(a,b,c,d){"use strict";var e=a["default"],f=b["default"];d.belongsTo=e,d.hasMany=f}),b("ember-data/lib/system/relationships/belongs_to",["../model","exports"],function(a,b){"use strict";function c(a,b,c){return Ember.computed("data",function(a,b){var d,h=e(this,"data"),i=e(this,"store"),j="DS: Async belongsTo "+this+" : "+a;if(2===arguments.length)return void 0===b?null:DS.PromiseObject.create({promise:g.cast(b,j)});var k=h.links&&h.links[a],l=h[a];return f(l)?k?(d=i.findBelongsTo(this,k,c),DS.PromiseObject.create({promise:d})):null:(d=i.fetchRecord(l)||g.cast(l,j),DS.PromiseObject.create({promise:d}))}).meta(c)}function d(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var d={type:a,isRelationship:!0,options:b,kind:"belongsTo"};return b.async?c(a,b,d):Ember.computed("data",function(b,c){var d,g,h=e(this,"data"),i=e(this,"store");return g="string"==typeof a?i.modelFor(a):a,2===arguments.length?void 0===c?null:c:(d=h[b],f(d)?null:(i.fetchRecord(d),d))}).meta(d)}var e=Ember.get,f=(Ember.set,Ember.isNone),g=Ember.RSVP.Promise,h=a.Model;h.reopen({belongsToWillChange:Ember.beforeObserver(function(a,b){if(e(a,"isLoaded")){var c=e(a,b);if(c){var d=e(a,"store"),f=DS.RelationshipChange.createChange(a,c,d,{key:b,kind:"belongsTo",changeType:"remove"});f.sync(),this._changesToSync[b]=f}}}),belongsToDidChange:Ember.immediateObserver(function(a,b){if(e(a,"isLoaded")){var c=e(a,b);if(c){var d=e(a,"store"),f=DS.RelationshipChange.createChange(a,c,d,{key:b,kind:"belongsTo",changeType:"add"});f.sync()}}delete this._changesToSync[b]})}),b["default"]=d}),b("ember-data/lib/system/relationships/ext",["../../../../ember-inflector/lib/system","../model"],function(a,b){"use strict";{var c=a.singularize,d=b.Model,e=Ember.get;Ember.set}d.reopen({didDefineProperty:function(a,b,c){if(c instanceof Ember.Descriptor){var d=c.meta();d.isRelationship&&"belongsTo"===d.kind&&(Ember.addObserver(a,b,null,"belongsToDidChange"),Ember.addBeforeObserver(a,b,null,"belongsToWillChange")),d.parentType=a.constructor}}}),d.reopenClass({typeForRelationship:function(a){var b=e(this,"relationshipsByName").get(a);return b&&b.type},inverseFor:function(a){function b(a,c,d){d=d||[];var f=e(c,"relationships");if(f){var g=f.get(a);return g&&d.push.apply(d,f.get(a)),a.superclass&&b(a.superclass,c,d),d}}var c=this.typeForRelationship(a);if(!c)return null;var d=this.metaForProperty(a).options;if(null===d.inverse)return null;var f,g;if(d.inverse)f=d.inverse,g=Ember.get(c,"relationshipsByName").get(f).kind;else{var h=b(this,c);if(0===h.length)return null;f=h[0].name,g=h[0].kind}return{type:c,name:f,kind:g}},relationships:Ember.computed(function(){var a=new Ember.MapWithDefault({defaultValue:function(){return[]}});return this.eachComputedProperty(function(b,c){if(c.isRelationship){"string"==typeof c.type&&(c.type=this.store.modelFor(c.type));var d=a.get(c.type);d.push({name:b,kind:c.kind})}}),a}),relationshipNames:Ember.computed(function(){var a={hasMany:[],belongsTo:[]};return this.eachComputedProperty(function(b,c){c.isRelationship&&a[c.kind].push(b)}),a}),relatedTypes:Ember.computed(function(){var a,b=Ember.A();return this.eachComputedProperty(function(c,d){d.isRelationship&&(a=d.type,"string"==typeof a&&(a=e(this,a,!1)||this.store.modelFor(a)),b.contains(a)||b.push(a))}),b}),relationshipsByName:Ember.computed(function(){var a,b=Ember.Map.create();return this.eachComputedProperty(function(d,e){e.isRelationship&&(e.key=d,a=e.type,a||"hasMany"!==e.kind?a||(a=d):a=c(d),"string"==typeof a&&(e.type=this.store.modelFor(a)),b.set(d,e))}),b}),fields:Ember.computed(function(){var a=Ember.Map.create();return this.eachComputedProperty(function(b,c){c.isRelationship?a.set(b,c.kind):c.isAttribute&&a.set(b,"attribute")}),a}),eachRelationship:function(a,b){e(this,"relationshipsByName").forEach(function(c,d){a.call(b,c,d)})},eachRelatedType:function(a,b){e(this,"relatedTypes").forEach(function(c){a.call(b,c)})}}),d.reopen({eachRelationship:function(a,b){this.constructor.eachRelationship(a,b)}})}),b("ember-data/lib/system/relationships/has_many",["exports"],function(a){"use strict";function b(a,b,d){return Ember.computed("data",function(a){var e=this._relationships[a],f="DS: Async hasMany "+this+" : "+a;if(!e){var h=Ember.RSVP.defer(f);e=c(this,a,b,function(b,c){var e,f=c.links&&c.links[a];return e=f?b.findHasMany(this,f,d,h):b.findMany(this,c[a],d.type,h),g(e,"promise",h.promise),e})}var i=e.get("promise").then(function(){return e},null,"DS: Async hasMany records received");return DS.PromiseArray.create({promise:i})}).meta(d).readOnly()}function c(a,b,c,d){var e=a._relationships;if(e[b])return e[b];var g=f(a,"data"),i=f(a,"store"),j=e[b]=d.call(a,i,g);return h(j,{owner:a,name:b,isPolymorphic:c.polymorphic})}function d(a,d){d=d||{};var e={type:a,isRelationship:!0,options:d,kind:"hasMany"};return d.async?b(a,d,e):Ember.computed("data",function(a){return c(this,a,d,function(b,c){c[a];return b.findMany(this,c[a],e.type)})}).meta(e).readOnly()}function e(a,b){return"object"==typeof a&&(b=a,a=void 0),d(a,b)}var f=Ember.get,g=Ember.set,h=Ember.setProperties;a["default"]=e}),b("ember-data/lib/system/store",["exports"],function(a){"use strict";function b(a){return null==a?null:a+""}function c(a,b,c,e){return b.eachRelationship(function(b,h){if(c.links&&c.links[b])return void(e&&h.options.async&&(e._relationships[b]=null));var i=h.kind,j=c[b];null!=j&&("belongsTo"===i?d(a,c,b,h,j):"hasMany"===i&&(f(a,c,b,h,j),g(e,b,j)))}),c}function d(a,b,c,d,f){if(!(z(f)||f instanceof DS.Model)){var g;"number"==typeof f||"string"==typeof f?(g=e(d,c,b),b[c]=a.recordForId(g,f)):"object"==typeof f&&(b[c]=a.recordForId(f.type,f.id))}}function e(a,b,c){return a.options.polymorphic?c[b+"Type"]:a.type}function f(a,b,c,e,f){for(var g=0,h=f.length;h>g;g++)d(a,f,g,e,f[g])}function g(a,b,c){a&&c.pushObjects(a.get(b).filterBy("isNew"))}function h(a,b){return u.create({promise:D.cast(a,b)})}function i(a,b){return v.create({promise:D.cast(a,b)})}function j(a,b,c){return a.lookup("serializer:"+b)||a.lookup("serializer:application")||a.lookup("serializer:"+c)||a.lookup("serializer:-default")}function k(a){return a.lookup("serializer:application")||a.lookup("serializer:-default")}function l(a,b){var c=a.serializer,d=a.defaultSerializer,e=a.container;return e&&void 0===c&&(c=j(e,b.typeKey,d)),(null===c||void 0===c)&&(c={extract:function(a,b,c){return c}}),c}function m(a,b,c,d){var e=a.find(b,c,d),f=l(a,c),g="DS: Handle Adapter#find of "+c+" with id: "+d;return D.cast(e,g).then(function(a){var e=f.extract(b,c,a,d,"find");return b.push(c,e)},function(a){var e=b.getById(c,d);throw e.notFound(),a},"DS: Extract payload of '"+c+"'")}function n(a,b,c,d,e){var f=a.findMany(b,c,d,e),g=l(a,c),h="DS: Handle Adapter#findMany of "+c;return D.cast(f,h).then(function(a){var d=g.extract(b,c,a,null,"findMany");b.pushMany(c,d)},null,"DS: Extract payload of "+c)}function o(a,b,c,d,e){var f=a.findHasMany(b,c,d,e),g=l(a,e.type),h="DS: Handle Adapter#findHasMany of "+c+" : "+e.type;return D.cast(f,h).then(function(a){var d=g.extract(b,e.type,a,null,"findHasMany"),f=b.pushMany(e.type,d);c.updateHasMany(e.key,f)},null,"DS: Extract payload of "+c+" : hasMany "+e.type)}function p(a,b,c,d,e){var f=a.findBelongsTo(b,c,d,e),g=l(a,e.type),h="DS: Handle Adapter#findBelongsTo of "+c+" : "+e.type;return D.cast(f,h).then(function(a){var c=g.extract(b,e.type,a,null,"findBelongsTo"),d=b.push(e.type,c);return d.updateBelongsTo(e.key,d),d},null,"DS: Extract payload of "+c+" : "+e.type)}function q(a,b,c,d){var e=a.findAll(b,c,d),f=l(a,c),g="DS: Handle Adapter#findAll of "+c;return D.cast(e,g).then(function(a){var d=f.extract(b,c,a,null,"findAll");return b.pushMany(c,d),b.didUpdateAll(c),b.all(c)},null,"DS: Extract payload of findAll "+c)}function r(a,b,c,d,e){var f=a.findQuery(b,c,d,e),g=l(a,c),h="DS: Handle Adapter#findQuery of "+c;return D.cast(f,h).then(function(a){var d=g.extract(b,c,a,null,"findQuery");return e.load(d),e},null,"DS: Extract payload of findQuery "+c)}function s(a,b,c,d){var e=d.constructor,f=a[c](b,e,d),g=l(a,e),h="DS: Extract and notify about "+c+" completion of "+d;return f.then(function(a){var f;return f=a?g.extract(b,e,a,w(d,"id"),c):a,b.didSaveRecord(d,f),d},function(a){throw a instanceof DS.InvalidError?b.recordWasInvalid(d,a.errors):b.recordWasError(d,a),a},h)}var t,u,v,w=Ember.get,x=Ember.set,y=Ember.run.once,z=Ember.isNone,A=Ember.EnumerableUtils.forEach,B=Ember.EnumerableUtils.indexOf,C=Ember.EnumerableUtils.map,D=Ember.RSVP.Promise,E=Ember.copy;t=Ember.Object.extend({init:function(){this.typeMaps={},this.recordArrayManager=DS.RecordArrayManager.create({store:this}),this._relationshipChanges={},this._pendingSave=[]},adapter:"-rest",serialize:function(a,b){return this.serializerFor(a.constructor.typeKey).serialize(a,b)},defaultAdapter:Ember.computed("adapter",function(){var a=w(this,"adapter");return"string"==typeof a&&(a=this.container.lookup("adapter:"+a)||this.container.lookup("adapter:application")||this.container.lookup("adapter:-rest")),DS.Adapter.detect(a)&&(a=a.create({container:this.container})),a}),createRecord:function(a,c){a=this.modelFor(a),c=E(c)||{},z(c.id)&&(c.id=this._generateId(a)),c.id=b(c.id);var d=this.buildRecord(a,c.id);return d.loadedData(),d.setProperties(c),d},_generateId:function(a){var b=this.adapterFor(a);return b&&b.generateIdForRecord?b.generateIdForRecord(this):null},deleteRecord:function(a){a.deleteRecord()},unloadRecord:function(a){a.unloadRecord()},find:function(a,c){return 1===arguments.length?this.findAll(a):"object"===Ember.typeOf(c)?this.findQuery(a,c):this.findById(a,b(c))},findById:function(a,b){a=this.modelFor(a);var c=this.recordForId(a,b),d=this.fetchRecord(c);return h(d||c,"DS: Store#findById "+a+" with id: "+b)},findByIds:function(a,b){var c=this;return i(Ember.RSVP.all(C(b,function(b){return c.findById(a,b)})).then(Ember.A,null,"DS: Store#findByIds of "+a+" complete"))},fetchRecord:function(a){if(z(a))return null;if(a._loadingPromise)return a._loadingPromise;if(!w(a,"isEmpty"))return null;var b=a.constructor,c=w(a,"id"),d=this.adapterFor(b),e=m(d,this,b,c);return a.loadingData(e),e},getById:function(a,b){return this.hasRecordForId(a,b)?this.recordForId(a,b):null},reloadRecord:function(a){var b=a.constructor,c=this.adapterFor(b),d=w(a,"id");return m(c,this,b,d)},fetchMany:function(a,b){if(a.length){var c=Ember.MapWithDefault.create({defaultValue:function(){return Ember.A()}});A(a,function(a){c.get(a.constructor).push(a)});var d=[];return A(c,function(a,c){var e=c.mapProperty("id"),f=this.adapterFor(a);d.push(n(f,this,a,e,b))},this),Ember.RSVP.all(d)}},hasRecordForId:function(a,c){return c=b(c),a=this.modelFor(a),!!this.typeMapFor(a).idToRecord[c]},recordForId:function(a,c){a=this.modelFor(a),c=b(c);var d=this.typeMapFor(a).idToRecord[c];return d||(d=this.buildRecord(a,c)),d},findMany:function(a,b,c,d){c=this.modelFor(c),b=Ember.A(b);var e=b.filterProperty("isEmpty",!0),f=this.recordArrayManager.createManyArray(c,b);return A(e,function(a){a.loadingData()}),f.loadingRecordsCount=e.length,e.length?(A(e,function(a){this.recordArrayManager.registerWaitingRecordArray(a,f)},this),d.resolve(this.fetchMany(e,a))):(d&&d.resolve(),f.set("isLoaded",!0),y(f,"trigger","didLoad")),f},findHasMany:function(a,b,c,d){var e=this.adapterFor(a.constructor),f=this.recordArrayManager.createManyArray(c.type,Ember.A([]));return d.resolve(o(e,this,a,b,c)),f},findBelongsTo:function(a,b,c){var d=this.adapterFor(a.constructor);return p(d,this,a,b,c)},findQuery:function(a,b){a=this.modelFor(a);
10
- var c=this.recordArrayManager.createAdapterPopulatedRecordArray(a,b),d=this.adapterFor(a);return i(r(d,this,a,b,c))},findAll:function(a){return a=this.modelFor(a),this.fetchAll(a,this.all(a))},fetchAll:function(a,b){var c=this.adapterFor(a),d=this.typeMapFor(a).metadata.since;return x(b,"isUpdating",!0),i(q(c,this,a,d))},didUpdateAll:function(a){var b=this.typeMapFor(a).findAllCache;x(b,"isUpdating",!1)},all:function(a){a=this.modelFor(a);var b=this.typeMapFor(a),c=b.findAllCache;if(c)return c;var d=this.recordArrayManager.createRecordArray(a);return b.findAllCache=d,d},unloadAll:function(a){for(var b,c=this.modelFor(a),d=this.typeMapFor(c),e=d.records.slice(),f=0;f<e.length;f++)b=e[f],b.unloadRecord(),b.destroy();d.findAllCache=null},filter:function(a,b,c){var d;3===arguments.length?d=this.findQuery(a,b):2===arguments.length&&(c=b),a=this.modelFor(a);var e=this.recordArrayManager.createFilteredRecordArray(a,c);return d=d||D.cast(e),i(d.then(function(){return e},null,"DS: Store#filter of "+a))},recordIsLoaded:function(a,b){return this.hasRecordForId(a,b)?!w(this.recordForId(a,b),"isEmpty"):!1},metadataFor:function(a){return a=this.modelFor(a),this.typeMapFor(a).metadata},dataWasUpdated:function(a,b){this.recordArrayManager.recordDidChange(b)},scheduleSave:function(a,b){a.adapterWillCommit(),this._pendingSave.push([a,b]),y(this,"flushPendingSave")},flushPendingSave:function(){var a=this._pendingSave.slice();this._pendingSave=[],A(a,function(a){var b,c=a[0],d=a[1],e=this.adapterFor(c.constructor);b=w(c,"isNew")?"createRecord":w(c,"isDeleted")?"deleteRecord":"updateRecord",d.resolve(s(e,this,b,c))},this)},didSaveRecord:function(a,b){b&&(b=c(this,a.constructor,b,a),this.updateId(a,b)),a.adapterDidCommit(b)},recordWasInvalid:function(a,b){a.adapterDidInvalidate(b)},recordWasError:function(a){a.adapterDidError()},updateId:function(a,c){var d=(w(a,"id"),b(c.id));this.typeMapFor(a.constructor).idToRecord[d]=a,x(a,"id",d)},typeMapFor:function(a){var b,c=w(this,"typeMaps"),d=Ember.guidFor(a);return(b=c[d])?b:(b={idToRecord:{},records:[],metadata:{},type:a},c[d]=b,b)},_load:function(a,c,d){var e=b(c.id),f=this.recordForId(a,e);return f.setupData(c,d),this.recordArrayManager.recordDidChange(f),f},modelFor:function(a){var b;if("string"==typeof a){var c=this.container.normalize("model:"+a);if(b=this.container.lookupFactory(c),!b)throw new Ember.Error("No model was found for '"+a+"'");b.typeKey=c.split(":",2)[1]}else b=a;return b.store=this,b},push:function(a,b,d){return a=this.modelFor(a),b=c(this,a,b),this._load(a,b,d),this.recordForId(a,b.id)},pushPayload:function(a,b){var c;b?c=this.serializerFor(a):(b=a,c=k(this.container)),c.pushPayload(this,b)},update:function(a,b){return this.push(a,b,!0)},pushMany:function(a,b){return C(b,function(b){return this.push(a,b)},this)},metaForType:function(a,b){a=this.modelFor(a),Ember.merge(this.typeMapFor(a).metadata,b)},buildRecord:function(a,b,c){var d=this.typeMapFor(a),e=d.idToRecord,f=a._create({id:b,store:this,container:this.container});return c&&f.setupData(c),b&&(e[b]=f),d.records.push(f),f},dematerializeRecord:function(a){var b=a.constructor,c=this.typeMapFor(b),d=w(a,"id");a.updateRecordArrays(),d&&delete c.idToRecord[d];var e=B(c.records,a);c.records.splice(e,1)},addRelationshipChangeFor:function(a,b,c,d,e){var f=a.clientId,g=c?c:c,h=b+d,i=this._relationshipChanges;f in i||(i[f]={}),g in i[f]||(i[f][g]={}),h in i[f][g]||(i[f][g][h]={}),i[f][g][h][e.changeType]=e},removeRelationshipChangeFor:function(a,b,c,d,e){var f=a.clientId,g=c?c.clientId:c,h=this._relationshipChanges,i=b+d;f in h&&g in h[f]&&i in h[f][g]&&delete h[f][g][i][e]},relationshipChangePairsFor:function(a){var b=[];if(!a)return b;var c=this._relationshipChanges[a.clientId];for(var d in c)if(c.hasOwnProperty(d))for(var e in c[d])c[d].hasOwnProperty(e)&&b.push(c[d][e]);return b},adapterFor:function(a){var b,c=this.container;return c&&(b=c.lookup("adapter:"+a.typeKey)||c.lookup("adapter:application")),b||w(this,"defaultAdapter")},serializerFor:function(a){a=this.modelFor(a);var b=this.adapterFor(a);return j(this.container,a.typeKey,b&&b.defaultSerializer)},willDestroy:function(){function a(a){return b[a].type}var b=this.typeMaps,c=Ember.keys(b),d=c.map(a);this.recordArrayManager.destroy(),d.forEach(this.unloadAll,this)}}),v=Ember.ArrayProxy.extend(Ember.PromiseProxyMixin),u=Ember.ObjectProxy.extend(Ember.PromiseProxyMixin),a.Store=t,a.PromiseArray=v,a.PromiseObject=u,a["default"]=t}),b("ember-data/lib/transforms",["./transforms/base","./transforms/number","./transforms/date","./transforms/string","./transforms/boolean","exports"],function(a,b,c,d,e,f){"use strict";var g=a["default"],h=b["default"],i=c["default"],j=d["default"],k=e["default"];f.Transform=g,f.NumberTransform=h,f.DateTransform=i,f.StringTransform=j,f.BooleanTransform=k}),b("ember-data/lib/transforms/base",["exports"],function(a){"use strict";var b=Ember.Object.extend({serialize:Ember.required(),deserialize:Ember.required()});a["default"]=b}),b("ember-data/lib/transforms/boolean",["./base","exports"],function(a,b){"use strict";var c=a["default"],d=c.extend({deserialize:function(a){var b=typeof a;return"boolean"===b?a:"string"===b?null!==a.match(/^true$|^t$|^1$/i):"number"===b?1===a:!1},serialize:function(a){return Boolean(a)}});b["default"]=d}),b("ember-data/lib/transforms/date",["./base","exports"],function(a,b){"use strict";var c=a["default"],d=c.extend({deserialize:function(a){var b=typeof a;return"string"===b?new Date(Ember.Date.parse(a)):"number"===b?new Date(a):null===a||void 0===a?a:null},serialize:function(a){if(a instanceof Date){var b=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],d=function(a){return 10>a?"0"+a:""+a},e=a.getUTCFullYear(),f=a.getUTCMonth(),g=a.getUTCDate(),h=a.getUTCDay(),i=a.getUTCHours(),j=a.getUTCMinutes(),k=a.getUTCSeconds(),l=b[h],m=d(g),n=c[f];return l+", "+m+" "+n+" "+e+" "+d(i)+":"+d(j)+":"+d(k)+" GMT"}return null}});b["default"]=d}),b("ember-data/lib/transforms/number",["./base","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.isEmpty,e=c.extend({deserialize:function(a){return d(a)?null:Number(a)},serialize:function(a){return d(a)?null:Number(a)}});b["default"]=e}),b("ember-data/lib/transforms/string",["./base","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.isNone,e=c.extend({deserialize:function(a){return d(a)?null:String(a)},serialize:function(a){return d(a)?null:String(a)}});b["default"]=e}),b("ember-inflector/lib/ext/string",["../system/string"],function(a){"use strict";var b=a.pluralize,c=a.singularize;(Ember.EXTEND_PROTOTYPES===!0||Ember.EXTEND_PROTOTYPES.String)&&(String.prototype.pluralize=function(){return b(this)},String.prototype.singularize=function(){return c(this)})}),b("ember-inflector/lib/main",["./system","./ext/string","exports"],function(a,b,c){"use strict";var d=a.Inflector,e=a.inflections,f=a.pluralize,g=a.singularize;d.defaultRules=e,Ember.Inflector=d,Ember.String.pluralize=f,Ember.String.singularize=g,c["default"]=d,c.pluralize=f,c.singularize=g}),b("ember-inflector/lib/system",["./system/inflector","./system/string","./system/inflections","exports"],function(a,b,c,d){"use strict";var e=a["default"],f=b.pluralize,g=b.singularize,h=c["default"];e.inflector=new e(h),d.Inflector=e,d.singularize=g,d.pluralize=f,d.defaultRules=h}),b("ember-inflector/lib/system/inflections",["exports"],function(a){"use strict";var b={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"]};a["default"]=b}),b("ember-inflector/lib/system/inflector",["exports"],function(a){"use strict";function b(a,b){for(var c=0,d=b.length;d>c;c++)a.uncountable[b[c].toLowerCase()]=!0}function c(a,b){for(var c,d=0,e=b.length;e>d;d++)c=b[d],a.irregular[c[0].toLowerCase()]=c[1],a.irregularInverse[c[1].toLowerCase()]=c[0]}function d(a){a=a||{},a.uncountable=a.uncountable||{},a.irregularPairs=a.irregularPairs||{};var d=this.rules={plurals:a.plurals||[],singular:a.singular||[],irregular:{},irregularInverse:{},uncountable:{}};b(d,a.uncountable),c(d,a.irregularPairs)}var e=/^\s*$/;d.prototype={plural:function(a,b){this.rules.plurals.push([a,b.toLowerCase()])},singular:function(a,b){this.rules.singular.push([a,b.toLowerCase()])},uncountable:function(a){b(this.rules,[a.toLowerCase()])},irregular:function(a,b){c(this.rules,[[a,b]])},pluralize:function(a){return this.inflect(a,this.rules.plurals,this.rules.irregular)},singularize:function(a){return this.inflect(a,this.rules.singular,this.rules.irregularInverse)},inflect:function(a,b,c){var d,f,g,h,i,j,k,l;if(i=e.test(a))return a;if(h=a.toLowerCase(),j=this.rules.uncountable[h])return a;if(k=c&&c[h])return k;for(var m=b.length,n=0;m>n&&(d=b[m-1],l=d[0],!l.test(a));m--);return d=d||[],l=d[0],f=d[1],g=a.replace(l,f)}},a["default"]=d}),b("ember-inflector/lib/system/string",["./inflector","exports"],function(a,b){"use strict";var c=a["default"],d=function(a){return c.inflector.pluralize(a)},e=function(a){return c.inflector.singularize(a)};b.pluralize=d,b.singularize=e}),a.DS=c("ember-data/lib/main")["default"]}(window);
8
+ !function(a){var b,c,d,e;!function(){var a={},f={};b=function(b,c,d){a[b]={deps:c,callback:d}},e=d=c=function(b){function d(a){if("."!==a.charAt(0))return a;for(var c=a.split("/"),d=b.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(e._eak_seen=a,f[b])return f[b];if(f[b]={},!a[b])throw new Error("Could not find module "+b);for(var g,h=a[b],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:c(d(i[l])));var n=j.apply(this,k);return f[b]=g||n}}(),b("activemodel-adapter/lib/main",["./system","exports"],function(a,b){"use strict";var c=a.ActiveModelAdapter,d=a.ActiveModelSerializer,e=a.EmbeddedRecordsMixin;b.ActiveModelAdapter=c,b.ActiveModelSerializer=d,b.EmbeddedRecordsMixin=e}),b("activemodel-adapter/lib/setup-container",["../../ember-data/lib/system/container_proxy","./system/active_model_serializer","./system/active_model_adapter","exports"],function(a,b,c,d){"use strict";var e=a["default"],f=b["default"],g=c["default"];d["default"]=function(a){var b=new e(a);b.registerDeprecations([{deprecated:"serializer:_ams",valid:"serializer:-active-model"},{deprecated:"adapter:_ams",valid:"adapter:-active-model"}]),a.register("serializer:-active-model",f),a.register("adapter:-active-model",g)}}),b("activemodel-adapter/lib/system",["./system/embedded_records_mixin","./system/active_model_adapter","./system/active_model_serializer","exports"],function(a,b,c,d){"use strict";var e=a["default"],f=b["default"],g=c["default"];d.EmbeddedRecordsMixin=e,d.ActiveModelAdapter=f,d.ActiveModelSerializer=g}),b("activemodel-adapter/lib/system/active_model_adapter",["../../../ember-data/lib/adapters","../../../ember-data/lib/system/adapter","../../../ember-inflector/lib/main","./active_model_serializer","./embedded_records_mixin","exports"],function(a,b,c,d,e,f){"use strict";var g=a.RESTAdapter,h=b.InvalidError,i=c.pluralize,j=(d["default"],e["default"],Ember.EnumerableUtils.forEach),k=Ember.String.decamelize,l=Ember.String.underscore,m=g.extend({defaultSerializer:"-active-model",pathForType:function(a){var b=k(a),c=l(b);return i(c)},ajaxError:function(a){var b=this._super(a);if(a&&422===a.status){var c=Ember.$.parseJSON(a.responseText),d={};if(void 0!==c.errors){var e=c.errors;j(Ember.keys(e),function(a){d[Ember.String.camelize(a)]=e[a]})}return new h(d)}return b}});f["default"]=m}),b("activemodel-adapter/lib/system/active_model_serializer",["../../../ember-inflector/lib/main","../../../ember-data/lib/serializers/rest_serializer","exports"],function(a,b,c){"use strict";var d=a.singularize,e=b["default"],f=Ember.get,g=Ember.EnumerableUtils.forEach,h=Ember.String.camelize,i=Ember.String.capitalize,j=Ember.String.decamelize,k=Ember.String.underscore,l=e.extend({keyForAttribute:function(a){return j(a)},keyForRelationship:function(a,b){return a=j(a),"belongsTo"===b?a+"_id":"hasMany"===b?d(a)+"_ids":a},serializeHasMany:Ember.K,serializeIntoHash:function(a,b,c,d){var e=k(j(b.typeKey));a[e]=this.serialize(c,d)},serializePolymorphicType:function(a,b,c){var d=c.key,e=f(a,d);e&&(d=this.keyForAttribute(d),b[d+"_type"]=i(e.constructor.typeKey))},normalize:function(a,b,c){return this.normalizeLinks(b),this._super(a,b,c)},normalizeLinks:function(a){if(a.links){var b=a.links;for(var c in b){var d=h(c);d!==c&&(b[d]=b[c],delete b[c])}}},normalizeRelationships:function(a,b){var c,d;this.keyForRelationship&&a.eachRelationship(function(a,e){if(e.options.polymorphic){if(c=this.keyForAttribute(a),d=b[c],d&&d.type)d.type=this.typeForRoot(d.type);else if(d&&"hasMany"===e.kind){var f=this;g(d,function(a){a.type=f.typeForRoot(a.type)})}}else c=this.keyForRelationship(a,e.kind),d=b[c];b[a]=d,a!==c&&delete b[c]},this)}});c["default"]=l}),b("activemodel-adapter/lib/system/embedded_records_mixin",["../../../ember-inflector/lib/main","exports"],function(a,b){"use strict";function c(a,b){var c=h(a,b);return c&&"always"===c.embedded}function d(a,b){var d=c(a,b),e=h(a,b);return d||e&&"records"===e.serialize}function e(a,b){var c=h(a,b);return c&&("ids"===c.serialize||"id"===c.serialize)}function f(a,b){{var c=h(a,b);d(a,b),e(a,b)}return!(c&&(c.serialize||c.embedded))}function g(a,b){var d=c(a,b),e=h(a,b),f=e&&(e.deserialize||e.serialize);return d||f}function h(a,b){return a&&(a[Ember.String.camelize(b)]||a[b])}function i(a,b,c,d,e){var f=l(a,"attrs");f&&c.eachRelationship(function(c,h){g(f,c)&&("hasMany"===h.kind&&j(a,b,c,h,d,e),"belongsTo"===h.kind&&k(a,b,c,h,d,e))})}function j(a,b,c,d,e,f){var g=b.serializerFor(d.type.typeKey),h=l(a,"primaryKey"),j=d.type.typeKey,k="_"+a.typeForRoot(d.type.typeKey),n=a.keyForRelationship(c,d.kind),o=a.keyForAttribute(c),p=[];f[o]&&(e[k]=e[k]||[],m(f[o],function(a){var c=b.modelFor(j);i(g,b,c,e,a),p.push(a[h]),e[k].push(a)}),f[n]=p,delete f[o])}function k(a,b,c,d,e,f){var h=a.get("attrs");if(h&&(g(h,Ember.String.camelize(c))||g(h,c))){var j=d.type.typeKey,k=b.serializerFor(d.type.typeKey),m=(l(k,"primaryKey"),Ember.String.pluralize(j)),n=k.keyForRelationship(c,d.kind),o=k.keyForAttribute(c);if(f[o]){e[m]=e[m]||[];var p=b.modelFor(d.type.typeKey);i(k,b,p,e,f[o]),f[n]=f[o].id,e[m].push(f[o]),f[o][d.parentType.typeKey+"_id"]=f.id,delete f[o]}}}var l=Ember.get,m=Ember.EnumerableUtils.forEach,n=(Ember.String.camelize,a.pluralize),o=Ember.Mixin.create({serializeBelongsTo:function(a,b,c){var g=c.key,h=this.get("attrs");if(f(h,g))return void this._super(a,b,c);var i=e(h,g),j=d(h,g),k=a.get(g);if(i)m=this.keyForRelationship(g,c.kind),b[m]=k?l(k,"id"):null;else if(j){var m=this.keyForRelationship(g);k?(b[m]=k.serialize({includeId:!0}),this.removeEmbeddedForeignKey(a,k,c,b[m])):b[m]=null}},serializeHasMany:function(a,b,c){var g=c.key,h=this.get("attrs");if(f(h,g))return void this._super(a,b,c);var i,j=e(h,g),k=d(h,g);j?(i=this.keyForRelationship(g,c.kind),b[i]=l(a,g).mapBy("id")):k&&(i=this.keyForAttribute(g),b[i]=l(a,g).map(function(b){var d=b.serialize({includeId:!0});return this.removeEmbeddedForeignKey(a,b,c,d),d},this))},removeEmbeddedForeignKey:function(a,b,c,d){if("hasMany"!==c.kind&&"belongsTo"===c.kind){var e=a.constructor.inverseFor(c.key);if(e){var f=e.name,g=this.store.serializerFor(b.constructor),h=g.keyForRelationship(f,e.kind);h&&delete d[h]}}},extractSingle:function(a,b,c,d){var e=this.keyForAttribute(b.typeKey),f=c[e];return i(this,a,b,c,f),this._super(a,b,c,d)},extractArray:function(a,b,c){var d=this.keyForAttribute(b.typeKey),e=c[n(d)];return m(e,function(d){i(this,a,b,c,d)},this),this._super(a,b,c)}});b["default"]=o}),b("ember-data/lib/adapters",["./adapters/fixture_adapter","./adapters/rest_adapter","exports"],function(a,b,c){"use strict";var d=a["default"],e=b["default"];c.RESTAdapter=e,c.FixtureAdapter=d}),b("ember-data/lib/adapters/fixture_adapter",["../system/adapter","exports"],function(a,b){"use strict";var c=Ember.get,d=Ember.String.fmt,e=Ember.EnumerableUtils.indexOf,f=0,g=a["default"],h=g.extend({serializer:null,simulateRemoteResponse:!0,latency:50,fixturesForType:function(a){if(a.FIXTURES){var b=Ember.A(a.FIXTURES);return b.map(function(a){var b=typeof a.id;if("number"!==b&&"string"!==b)throw new Error(d("the id property must be defined as a number or string for fixture %@",[a]));return a.id=a.id+"",a})}return null},queryFixtures:function(){},updateFixtures:function(a,b){a.FIXTURES||(a.FIXTURES=[]);var c=a.FIXTURES;this.deleteLoadedFixture(a,b),c.push(b)},mockJSON:function(a,b,c){return a.serializerFor(b).serialize(c,{includeId:!0})},generateIdForRecord:function(){return"fixture-"+f++},find:function(a,b,c){var d,e=this.fixturesForType(b);return e&&(d=Ember.A(e).findProperty("id",c)),d?this.simulateRemoteCall(function(){return d},this):void 0},findMany:function(a,b,c){var d=this.fixturesForType(b);return d&&(d=d.filter(function(a){return-1!==e(c,a.id)})),d?this.simulateRemoteCall(function(){return d},this):void 0},findAll:function(a,b){var c=this.fixturesForType(b);return this.simulateRemoteCall(function(){return c},this)},findQuery:function(a,b,c){var d=this.fixturesForType(b);return d=this.queryFixtures(d,c,b),d?this.simulateRemoteCall(function(){return d},this):void 0},createRecord:function(a,b,c){var d=this.mockJSON(a,b,c);return this.updateFixtures(b,d),this.simulateRemoteCall(function(){return d},this)},updateRecord:function(a,b,c){var d=this.mockJSON(a,b,c);return this.updateFixtures(b,d),this.simulateRemoteCall(function(){return d},this)},deleteRecord:function(a,b,c){var d=this.mockJSON(a,b,c);return this.deleteLoadedFixture(b,d),this.simulateRemoteCall(function(){return null})},deleteLoadedFixture:function(a,b){var c=this.findExistingFixture(a,b);if(c){var d=e(a.FIXTURES,c);return a.FIXTURES.splice(d,1),!0}},findExistingFixture:function(a,b){var d=this.fixturesForType(a),e=c(b,"id");return this.findFixtureById(d,e)},findFixtureById:function(a,b){return Ember.A(a).find(function(a){return""+c(a,"id")==""+b?!0:!1})},simulateRemoteCall:function(a,b){var d=this;return new Ember.RSVP.Promise(function(e){c(d,"simulateRemoteResponse")?Ember.run.later(function(){e(a.call(b))},c(d,"latency")):Ember.run.schedule("actions",null,function(){e(a.call(b))})},"DS: FixtureAdapter#simulateRemoteCall")}});b["default"]=h}),b("ember-data/lib/adapters/rest_adapter",["../system/adapter","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.get,e=(Ember.set,Ember.ArrayPolyfills.forEach),f=c.extend({defaultSerializer:"-rest",find:function(a,b,c){return this.ajax(this.buildURL(b.typeKey,c),"GET")},findAll:function(a,b,c){var d;return c&&(d={since:c}),this.ajax(this.buildURL(b.typeKey),"GET",{data:d})},findQuery:function(a,b,c){return this.ajax(this.buildURL(b.typeKey),"GET",{data:c})},findMany:function(a,b,c){return this.ajax(this.buildURL(b.typeKey),"GET",{data:{ids:c}})},findHasMany:function(a,b,c){var e=d(this,"host"),f=d(b,"id"),g=b.constructor.typeKey;return e&&"/"===c.charAt(0)&&"/"!==c.charAt(1)&&(c=e+c),this.ajax(this.urlPrefix(c,this.buildURL(g,f)),"GET")},findBelongsTo:function(a,b,c){var e=d(b,"id"),f=b.constructor.typeKey;return this.ajax(this.urlPrefix(c,this.buildURL(f,e)),"GET")},createRecord:function(a,b,c){var d={},e=a.serializerFor(b.typeKey);return e.serializeIntoHash(d,b,c,{includeId:!0}),this.ajax(this.buildURL(b.typeKey),"POST",{data:d})},updateRecord:function(a,b,c){var e={},f=a.serializerFor(b.typeKey);f.serializeIntoHash(e,b,c);var g=d(c,"id");return this.ajax(this.buildURL(b.typeKey,g),"PUT",{data:e})},deleteRecord:function(a,b,c){var e=d(c,"id");return this.ajax(this.buildURL(b.typeKey,e),"DELETE")},buildURL:function(a,b){var c=[],e=d(this,"host"),f=this.urlPrefix();return a&&c.push(this.pathForType(a)),b&&c.push(b),f&&c.unshift(f),c=c.join("/"),!e&&c&&(c="/"+c),c},urlPrefix:function(a,b){var c=d(this,"host"),e=d(this,"namespace"),f=[];return a?"/"===a.charAt(0)?c&&(a=a.slice(1),f.push(c)):/^http(s)?:\/\//.test(a)||f.push(b):(c&&f.push(c),e&&f.push(e)),a&&f.push(a),f.join("/")},pathForType:function(a){var b=Ember.String.camelize(a);return Ember.String.pluralize(b)},ajaxError:function(a){return a&&"object"==typeof a&&(a.then=null),a},ajax:function(a,b,c){var d=this;return new Ember.RSVP.Promise(function(e,f){c=d.ajaxOptions(a,b,c),c.success=function(a){Ember.run(null,e,a)},c.error=function(a){Ember.run(null,f,d.ajaxError(a))},Ember.$.ajax(c)},"DS: RestAdapter#ajax "+b+" to "+a)},ajaxOptions:function(a,b,c){c=c||{},c.url=a,c.type=b,c.dataType="json",c.context=this,c.data&&"GET"!==b&&(c.contentType="application/json; charset=utf-8",c.data=JSON.stringify(c.data));var f=d(this,"headers");return void 0!==f&&(c.beforeSend=function(a){e.call(Ember.keys(f),function(b){a.setRequestHeader(b,f[b])})}),c}});b["default"]=f}),b("ember-data/lib/core",["exports"],function(a){"use strict";var b;"undefined"==typeof b&&(b=Ember.Namespace.create({VERSION:"1.0.0-beta.8.2a68c63a"}),Ember.libraries&&Ember.libraries.registerCoreLibrary("Ember Data",b.VERSION)),a["default"]=b}),b("ember-data/lib/ember-initializer",["./setup-container"],function(a){"use strict";var b=a["default"],c=Ember.K;Ember.onLoad("Ember.Application",function(a){a.initializer({name:"ember-data",initialize:b}),a.initializer({name:"store",after:"ember-data",initialize:c}),a.initializer({name:"activeModelAdapter",before:"store",initialize:c}),a.initializer({name:"transforms",before:"store",initialize:c}),a.initializer({name:"data-adapter",before:"store",initialize:c}),a.initializer({name:"injectStore",before:"store",initialize:c})})}),b("ember-data/lib/ext/date",[],function(){"use strict";Ember.Date=Ember.Date||{};var a=Date.parse,b=[1,4,5,6,7,10,11];Ember.Date.parse=function(c){var d,e,f=0;if(e=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(c)){for(var g,h=0;g=b[h];++h)e[g]=+e[g]||0;e[2]=(+e[2]||1)-1,e[3]=+e[3]||1,"Z"!==e[8]&&void 0!==e[9]&&(f=60*e[10]+e[11],"+"===e[9]&&(f=0-f)),d=Date.UTC(e[1],e[2],e[3],e[4],e[5]+f,e[6],e[7])}else d=a?a(c):0/0;return d},(Ember.EXTEND_PROTOTYPES===!0||Ember.EXTEND_PROTOTYPES.Date)&&(Date.parse=Ember.Date.parse)}),b("ember-data/lib/initializers/data_adapter",["../system/debug/debug_adapter","exports"],function(a,b){"use strict";var c=a["default"];b["default"]=function(a){a.register("data-adapter:main",c)}}),b("ember-data/lib/initializers/store",["../serializers","../adapters","../system/container_proxy","../system/store","exports"],function(a,b,c,d,e){"use strict";var f=a.JSONSerializer,g=a.RESTSerializer,h=b.RESTAdapter,i=c["default"],j=d["default"];e["default"]=function(a,b){a.register("store:main",a.lookupFactory("store:application")||b&&b.Store||j);var c=new i(a);c.registerDeprecations([{deprecated:"serializer:_default",valid:"serializer:-default"},{deprecated:"serializer:_rest",valid:"serializer:-rest"},{deprecated:"adapter:_rest",valid:"adapter:-rest"}]),a.register("serializer:-default",f),a.register("serializer:-rest",g),a.register("adapter:-rest",h),a.lookup("store:main")}}),b("ember-data/lib/initializers/store_injections",["exports"],function(a){"use strict";a["default"]=function(a){a.injection("controller","store","store:main"),a.injection("route","store","store:main"),a.injection("serializer","store","store:main"),a.injection("data-adapter","store","store:main")}}),b("ember-data/lib/initializers/transforms",["../transforms","exports"],function(a,b){"use strict";var c=a.BooleanTransform,d=a.DateTransform,e=a.StringTransform,f=a.NumberTransform;b["default"]=function(a){a.register("transform:boolean",c),a.register("transform:date",d),a.register("transform:number",f),a.register("transform:string",e)}}),b("ember-data/lib/main",["./core","./ext/date","./system/store","./system/model","./system/changes","./system/adapter","./system/debug","./system/record_arrays","./system/record_array_manager","./adapters","./serializers/json_serializer","./serializers/rest_serializer","../../ember-inflector/lib/main","../../activemodel-adapter/lib/main","./transforms","./system/relationships","./ember-initializer","./setup-container","./system/container_proxy","exports"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){"use strict";Ember.RSVP.Promise.cast=Ember.RSVP.Promise.cast||Ember.RSVP.resolve;var u=a["default"],v=c.Store,w=c.PromiseArray,x=c.PromiseObject,y=d.Model,z=d.Errors,A=d.RootState,B=d.attr,C=e.AttributeChange,D=e.RelationshipChange,E=e.RelationshipChangeAdd,F=(e.RelationshipChangeRemove,e.OneToManyChange),G=(e.ManyToNoneChange,e.OneToOneChange),H=e.ManyToManyChange,I=f.InvalidError,J=f.Adapter,K=g["default"],L=h.RecordArray,M=h.FilteredRecordArray,N=h.AdapterPopulatedRecordArray,O=h.ManyArray,P=i["default"],Q=j.RESTAdapter,R=j.FixtureAdapter,S=k["default"],T=l["default"],U=n.ActiveModelAdapter,V=n.ActiveModelSerializer,W=n.EmbeddedRecordsMixin,X=o.Transform,Y=o.DateTransform,Z=o.NumberTransform,$=o.StringTransform,_=o.BooleanTransform,ab=p.hasMany,bb=p.belongsTo,cb=r["default"],db=s["default"];u.Store=v,u.PromiseArray=w,u.PromiseObject=x,u.Model=y,u.RootState=A,u.attr=B,u.Errors=z,u.AttributeChange=C,u.RelationshipChange=D,u.RelationshipChangeAdd=E,u.OneToManyChange=F,u.ManyToNoneChange=F,u.OneToOneChange=G,u.ManyToManyChange=H,u.Adapter=J,u.InvalidError=I,u.DebugAdapter=K,u.RecordArray=L,u.FilteredRecordArray=M,u.AdapterPopulatedRecordArray=N,u.ManyArray=O,u.RecordArrayManager=P,u.RESTAdapter=Q,u.FixtureAdapter=R,u.RESTSerializer=T,u.JSONSerializer=S,u.Transform=X,u.DateTransform=Y,u.StringTransform=$,u.NumberTransform=Z,u.BooleanTransform=_,u.ActiveModelAdapter=U,u.ActiveModelSerializer=V,u.EmbeddedRecordsMixin=W,u.belongsTo=bb,u.hasMany=ab,u.ContainerProxy=db,u._setupContainer=cb,Ember.lookup.DS=u,t["default"]=u}),b("ember-data/lib/serializers",["./serializers/json_serializer","./serializers/rest_serializer","exports"],function(a,b,c){"use strict";var d=a["default"],e=b["default"];c.JSONSerializer=d,c.RESTSerializer=e}),b("ember-data/lib/serializers/json_serializer",["../system/changes","exports"],function(a,b){"use strict";var c=a.RelationshipChange,d=Ember.get,e=(Ember.set,Ember.isNone),f=Ember.ArrayPolyfills.map,g=Ember.Object.extend({primaryKey:"id",applyTransforms:function(a,b){return a.eachTransformedAttribute(function(a,c){var d=this.transformFor(c);b[a]=d.deserialize(b[a])},this),b},normalize:function(a,b){return b?(this.normalizeId(b),this.normalizeUsingDeclaredMapping(a,b),this.applyTransforms(a,b),b):b},normalizeUsingDeclaredMapping:function(a,b){var c,e,f=d(this,"attrs");if(f)for(e in f)c=f[e],c&&c.key&&(c=c.key),"string"==typeof c&&(b[e]=b[c],delete b[c])},normalizeId:function(a){var b=d(this,"primaryKey");"id"!==b&&(a.id=a[b],delete a[b])},serialize:function(a,b){var c={};if(b&&b.includeId){var e=d(a,"id");e&&(c[d(this,"primaryKey")]=e)}return a.eachAttribute(function(b,d){this.serializeAttribute(a,c,b,d)},this),a.eachRelationship(function(b,d){"belongsTo"===d.kind?this.serializeBelongsTo(a,c,d):"hasMany"===d.kind&&this.serializeHasMany(a,c,d)},this),c},serializeAttribute:function(a,b,c,e){var f=d(this,"attrs"),g=d(a,c),h=e.type;if(h){var i=this.transformFor(h);g=i.serialize(g)}c=f&&f[c]||(this.keyForAttribute?this.keyForAttribute(c):c),b[c]=g},serializeBelongsTo:function(a,b,c){var f=c.key,g=d(a,f);f=this.keyForRelationship?this.keyForRelationship(f,"belongsTo"):f,b[f]=e(g)?g:d(g,"id"),c.options.polymorphic&&this.serializePolymorphicType(a,b,c)},serializeHasMany:function(a,b,e){var f=e.key,g=this.keyForRelationship?this.keyForRelationship(f,"hasMany"):f,h=c.determineRelationshipType(a.constructor,e);("manyToNone"===h||"manyToMany"===h)&&(b[g]=d(a,f).mapBy("id"))},serializePolymorphicType:Ember.K,extract:function(a,b,c,d,e){this.extractMeta(a,b,c);var f="extract"+e.charAt(0).toUpperCase()+e.substr(1);return this[f](a,b,c,d,e)},extractFindAll:function(a,b,c){return this.extractArray(a,b,c)},extractFindQuery:function(a,b,c){return this.extractArray(a,b,c)},extractFindMany:function(a,b,c){return this.extractArray(a,b,c)},extractFindHasMany:function(a,b,c){return this.extractArray(a,b,c)},extractCreateRecord:function(a,b,c){return this.extractSave(a,b,c)},extractUpdateRecord:function(a,b,c){return this.extractSave(a,b,c)},extractDeleteRecord:function(a,b,c){return this.extractSave(a,b,c)},extractFind:function(a,b,c){return this.extractSingle(a,b,c)},extractFindBelongsTo:function(a,b,c){return this.extractSingle(a,b,c)},extractSave:function(a,b,c){return this.extractSingle(a,b,c)},extractSingle:function(a,b,c){return this.normalize(b,c)},extractArray:function(a,b,c){var d=this;return f.call(c,function(a){return d.normalize(b,a)})},extractMeta:function(a,b,c){c&&c.meta&&(a.metaForType(b,c.meta),delete c.meta)},transformFor:function(a){var b=this.container.lookup("transform:"+a);return b}});b["default"]=g}),b("ember-data/lib/serializers/rest_serializer",["./json_serializer","ember-inflector/lib/system/string","exports"],function(a,b,c){"use strict";function d(a){return null==a?null:a+""}var e=a["default"],f=Ember.get,g=(Ember.set,Ember.ArrayPolyfills.forEach),h=Ember.ArrayPolyfills.map,i=b.singularize,j=Ember.String.camelize,k=e.extend({normalize:function(a,b,c){return this.normalizeId(b),this.normalizeAttributes(a,b),this.normalizeRelationships(a,b),this.normalizeUsingDeclaredMapping(a,b),this.normalizeHash&&this.normalizeHash[c]&&this.normalizeHash[c](b),this.applyTransforms(a,b),b},normalizePayload:function(a){return a},normalizeAttributes:function(a,b){var c;this.keyForAttribute&&a.eachAttribute(function(a){c=this.keyForAttribute(a),a!==c&&(b[a]=b[c],delete b[c])},this)},normalizeRelationships:function(a,b){var c;this.keyForRelationship&&a.eachRelationship(function(a,d){c=this.keyForRelationship(a,d.kind),a!==c&&(b[a]=b[c],delete b[c])},this)},extractSingle:function(a,b,c,e){c=this.normalizePayload(c);var f,h=b.typeKey;for(var i in c){var j=this.typeForRoot(i),k=a.modelFor(j),l=k.typeKey===h;l&&"array"!==Ember.typeOf(c[i])?f=this.normalize(b,c[i],i):g.call(c[i],function(b){var c=this.typeForRoot(i),g=a.modelFor(c),h=a.serializerFor(g);b=h.normalize(g,b,i);var j=l&&!e&&!f,k=l&&d(b.id)===e;j||k?f=b:a.push(c,b)},this)}return f},extractArray:function(a,b,c){c=this.normalizePayload(c);var d,e=b.typeKey;for(var f in c){var g=f,i=!1;"_"===f.charAt(0)&&(i=!0,g=f.substr(1));var j=this.typeForRoot(g),k=a.modelFor(j),l=a.serializerFor(k),m=!i&&k.typeKey===e,n=h.call(c[f],function(a){return l.normalize(k,a,f)},this);m?d=n:a.pushMany(j,n)}return d},pushPayload:function(a,b){b=this.normalizePayload(b);for(var c in b){var d=this.typeForRoot(c),e=a.modelFor(d),f=a.serializerFor(e),g=h.call(Ember.makeArray(b[c]),function(a){return f.normalize(e,a,c)},this);a.pushMany(d,g)}},typeForRoot:function(a){return j(i(a))},serialize:function(){return this._super.apply(this,arguments)},serializeIntoHash:function(a,b,c,d){a[b.typeKey]=this.serialize(c,d)},serializePolymorphicType:function(a,b,c){var d=c.key,e=f(a,d);d=this.keyForAttribute?this.keyForAttribute(d):d,b[d+"Type"]=e.constructor.typeKey}});c["default"]=k}),b("ember-data/lib/setup-container",["./initializers/store","./initializers/transforms","./initializers/store_injections","./initializers/data_adapter","../../../activemodel-adapter/lib/setup-container","exports"],function(a,b,c,d,e,f){"use strict";var g=a["default"],h=b["default"],i=c["default"],j=d["default"],k=e["default"];f["default"]=function(a,b){j(a,b),h(a,b),i(a,b),g(a,b),k(a,b)}}),b("ember-data/lib/system/adapter",["exports"],function(a){"use strict";var b=Ember.get,c=(Ember.set,Ember.ArrayPolyfills.map),d=["description","fileName","lineNumber","message","name","number","stack"],e=function(a){var b=Error.prototype.constructor.call(this,"The backend rejected the commit because it was invalid: "+Ember.inspect(a));this.errors=a;for(var c=0,e=d.length;e>c;c++)this[d[c]]=b[d[c]]};e.prototype=Ember.create(Error.prototype);var f=Ember.Object.extend({find:Ember.required(Function),findAll:null,findQuery:null,generateIdForRecord:null,serialize:function(a,c){return b(a,"store").serializerFor(a.constructor.typeKey).serialize(a,c)},createRecord:Ember.required(Function),updateRecord:Ember.required(Function),deleteRecord:Ember.required(Function),findMany:function(a,b,d){var e=c.call(d,function(c){return this.find(a,b,c)},this);return Ember.RSVP.all(e)}});a.InvalidError=e,a.Adapter=f,a["default"]=f}),b("ember-data/lib/system/changes",["./changes/relationship_change","exports"],function(a,b){"use strict";var c=a.RelationshipChange,d=a.RelationshipChangeAdd,e=a.RelationshipChangeRemove,f=a.OneToManyChange,g=a.ManyToNoneChange,h=a.OneToOneChange,i=a.ManyToManyChange;b.RelationshipChange=c,b.RelationshipChangeAdd=d,b.RelationshipChangeRemove=e,b.OneToManyChange=f,b.ManyToNoneChange=g,b.OneToOneChange=h,b.ManyToManyChange=i}),b("ember-data/lib/system/changes/relationship_change",["../model","exports"],function(a,b){"use strict";function c(a){return"object"==typeof a&&(!a.then||"function"!=typeof a.then)}var d=a.Model,e=Ember.get,f=Ember.set,g=Ember.EnumerableUtils.forEach,h=function(a){this.parentRecord=a.parentRecord,this.childRecord=a.childRecord,this.firstRecord=a.firstRecord,this.firstRecordKind=a.firstRecordKind,this.firstRecordName=a.firstRecordName,this.secondRecord=a.secondRecord,this.secondRecordKind=a.secondRecordKind,this.secondRecordName=a.secondRecordName,this.changeType=a.changeType,this.store=a.store,this.committed={}},i=function(a){h.call(this,a)},j=function(a){h.call(this,a)};h.create=function(a){return new h(a)},i.create=function(a){return new i(a)},j.create=function(a){return new j(a)};var k={},l={},m={},n={},o={};h._createChange=function(a){return"add"===a.changeType?i.create(a):"remove"===a.changeType?j.create(a):void 0},h.determineRelationshipType=function(a,b){var c,d,e=b.key,f=b.kind,g=a.inverseFor(e);return g&&(c=g.name,d=g.kind),g?"belongsTo"===d?"belongsTo"===f?"oneToOne":"manyToOne":"belongsTo"===f?"oneToMany":"manyToMany":"belongsTo"===f?"oneToNone":"manyToNone"},h.createChange=function(a,b,c,d){var e,f=a.constructor;return e=h.determineRelationshipType(f,d),"oneToMany"===e?k.createChange(a,b,c,d):"manyToOne"===e?k.createChange(b,a,c,d):"oneToNone"===e?l.createChange(a,b,c,d):"manyToNone"===e?m.createChange(a,b,c,d):"oneToOne"===e?n.createChange(a,b,c,d):"manyToMany"===e?o.createChange(a,b,c,d):void 0},l.createChange=function(a,b,c,d){var e=d.key,f=h._createChange({parentRecord:b,childRecord:a,firstRecord:a,store:c,changeType:d.changeType,firstRecordName:e,firstRecordKind:"belongsTo"});return c.addRelationshipChangeFor(a,e,b,null,f),f},m.createChange=function(a,b,c,d){var e=d.key,f=h._createChange({parentRecord:a,childRecord:b,secondRecord:a,store:c,changeType:d.changeType,secondRecordName:d.key,secondRecordKind:"hasMany"});return c.addRelationshipChangeFor(a,e,b,null,f),f},o.createChange=function(a,b,c,d){var e=d.key,f=h._createChange({parentRecord:b,childRecord:a,firstRecord:a,secondRecord:b,firstRecordKind:"hasMany",secondRecordKind:"hasMany",store:c,changeType:d.changeType,firstRecordName:e});return c.addRelationshipChangeFor(a,e,b,null,f),f},n.createChange=function(a,b,c,d){var e;d.parentType?e=d.parentType.inverseFor(d.key).name:d.key&&(e=d.key);var f=h._createChange({parentRecord:b,childRecord:a,firstRecord:a,secondRecord:b,firstRecordKind:"belongsTo",secondRecordKind:"belongsTo",store:c,changeType:d.changeType,firstRecordName:e});return c.addRelationshipChangeFor(a,e,b,null,f),f},n.maintainInvariant=function(a,b,c,d){if("add"===a.changeType&&b.recordIsMaterialized(c)){var f=e(c,d);if(f){var g=n.createChange(c,f,b,{parentType:a.parentType,hasManyName:a.hasManyName,changeType:"remove",key:a.key});b.addRelationshipChangeFor(c,d,a.parentRecord,null,g),g.sync()}}},k.createChange=function(a,b,c,d){var e;d.parentType?(e=d.parentType.inverseFor(d.key).name,k.maintainInvariant(d,c,a,e)):d.key&&(e=d.key);var f=h._createChange({parentRecord:b,childRecord:a,firstRecord:a,secondRecord:b,firstRecordKind:"belongsTo",secondRecordKind:"hasMany",store:c,changeType:d.changeType,firstRecordName:e});return c.addRelationshipChangeFor(a,e,b,f.getSecondRecordName(),f),f},k.maintainInvariant=function(a,b,c,d){if("add"===a.changeType&&c){var f=e(c,d);if(f){var g=k.createChange(c,f,b,{parentType:a.parentType,hasManyName:a.hasManyName,changeType:"remove",key:a.key});b.addRelationshipChangeFor(c,d,a.parentRecord,g.getSecondRecordName(),g),g.sync()}}},h.prototype={getSecondRecordName:function(){var a,b=this.secondRecordName;if(!b){if(a=this.secondRecord,!a)return;var c=this.firstRecord.constructor,d=c.inverseFor(this.firstRecordName);this.secondRecordName=d.name}return this.secondRecordName},getFirstRecordName:function(){var a=this.firstRecordName;return a},destroy:function(){var a=this.childRecord,b=this.getFirstRecordName(),c=this.getSecondRecordName(),d=this.store;d.removeRelationshipChangeFor(a,b,this.parentRecord,c,this.changeType)},getSecondRecord:function(){return this.secondRecord},getFirstRecord:function(){return this.firstRecord},coalesce:function(){var a=this.store.relationshipChangePairsFor(this.firstRecord);g(a,function(a){var b=a.add,c=a.remove;b&&c&&(b.destroy(),c.destroy())})}},i.prototype=Ember.create(h.create({})),j.prototype=Ember.create(h.create({})),i.prototype.changeType="add",i.prototype.sync=function(){var a=this.getSecondRecordName(),b=this.getFirstRecordName(),g=this.getFirstRecord(),h=this.getSecondRecord();h instanceof d&&g instanceof d&&("belongsTo"===this.secondRecordKind?h.suspendRelationshipObservers(function(){f(h,a,g)}):"hasMany"===this.secondRecordKind&&h.suspendRelationshipObservers(function(){var b=e(h,a);c(b)&&b.addObject(g)})),g instanceof d&&h instanceof d&&e(g,b)!==h&&("belongsTo"===this.firstRecordKind?g.suspendRelationshipObservers(function(){f(g,b,h)}):"hasMany"===this.firstRecordKind&&g.suspendRelationshipObservers(function(){var a=e(g,b);c(a)&&a.addObject(h)})),this.coalesce()},j.prototype.changeType="remove",j.prototype.sync=function(){var a=this.getSecondRecordName(),b=this.getFirstRecordName(),g=this.getFirstRecord(),h=this.getSecondRecord();h instanceof d&&g instanceof d&&("belongsTo"===this.secondRecordKind?h.suspendRelationshipObservers(function(){f(h,a,null)}):"hasMany"===this.secondRecordKind&&h.suspendRelationshipObservers(function(){var b=e(h,a);c(b)&&b.removeObject(g)})),g instanceof d&&e(g,b)&&("belongsTo"===this.firstRecordKind?g.suspendRelationshipObservers(function(){f(g,b,null)}):"hasMany"===this.firstRecordKind&&g.suspendRelationshipObservers(function(){var a=e(g,b);c(a)&&a.removeObject(h)})),this.coalesce()},b.RelationshipChange=h,b.RelationshipChangeAdd=i,b.RelationshipChangeRemove=j,b.OneToManyChange=k,b.ManyToNoneChange=m,b.OneToOneChange=n,b.ManyToManyChange=o}),b("ember-data/lib/system/container_proxy",["exports"],function(a){"use strict";var b=function(a){this.container=a};b.prototype.aliasedFactory=function(a,b){var c=this;return{create:function(){return b&&b(),c.container.lookup(a)}}},b.prototype.registerAlias=function(a,b,c){var d=this.aliasedFactory(b,c);return this.container.register(a,d)},b.prototype.registerDeprecation=function(a,b){var c=function(){};return this.registerAlias(a,b,c)},b.prototype.registerDeprecations=function(a){for(var b=a.length;b>0;b--){var c=a[b-1],d=c.deprecated,e=c.valid;this.registerDeprecation(d,e)}},a["default"]=b}),b("ember-data/lib/system/debug",["./debug/debug_info","./debug/debug_adapter","exports"],function(a,b,c){"use strict";var d=b["default"];c["default"]=d}),b("ember-data/lib/system/debug/debug_adapter",["../model","exports"],function(a,b){"use strict";var c=a.Model,d=Ember.get,e=Ember.String.capitalize,f=Ember.String.underscore,g=Ember.DataAdapter.extend({getFilters:function(){return[{name:"isNew",desc:"New"},{name:"isModified",desc:"Modified"},{name:"isClean",desc:"Clean"}]},detect:function(a){return a!==c&&c.detect(a)},columnsForType:function(a){var b=[{name:"id",desc:"Id"}],c=0,g=this;return d(a,"attributes").forEach(function(a){if(c++>g.attributeLimit)return!1;var d=e(f(a).replace("_"," "));b.push({name:a,desc:d})}),b},getRecords:function(a){return this.get("store").all(a)},getRecordColumnValues:function(a){var b=this,c=0,e={id:d(a,"id")};return a.eachAttribute(function(f){if(c++>b.attributeLimit)return!1;var g=d(a,f);e[f]=g}),e},getRecordKeywords:function(a){var b=[],c=Ember.A(["id"]);return a.eachAttribute(function(a){c.push(a)}),c.forEach(function(c){b.push(d(a,c))}),b},getRecordFilterValues:function(a){return{isNew:a.get("isNew"),isModified:a.get("isDirty")&&!a.get("isNew"),isClean:!a.get("isDirty")}},getRecordColor:function(a){var b="black";return a.get("isNew")?b="green":a.get("isDirty")&&(b="blue"),b},observeRecord:function(a,b){var c=Ember.A(),d=this,e=Ember.A(["id","isNew","isDirty"]);a.eachAttribute(function(a){e.push(a)}),e.forEach(function(e){var f=function(){b(d.wrapRecord(a))};Ember.addObserver(a,e,f),c.push(function(){Ember.removeObserver(a,e,f)})});var f=function(){c.forEach(function(a){a()})};return f}});b["default"]=g}),b("ember-data/lib/system/debug/debug_info",["../model","exports"],function(a,b){"use strict";var c=a.Model;c.reopen({_debugInfo:function(){var a=["id"],b={belongsTo:[],hasMany:[]},c=[];
9
+ this.eachAttribute(function(b){a.push(b)},this),this.eachRelationship(function(a,d){b[d.kind].push(a),c.push(a)});var d=[{name:"Attributes",properties:a,expand:!0},{name:"Belongs To",properties:b.belongsTo,expand:!0},{name:"Has Many",properties:b.hasMany,expand:!0},{name:"Flags",properties:["isLoaded","isDirty","isSaving","isDeleted","isError","isNew","isValid"]}];return{propertyInfo:{includeOtherProperties:!0,groups:d,expensiveProperties:c}}}}),b["default"]=c}),b("ember-data/lib/system/model",["./model/model","./model/attributes","./model/states","./model/errors","exports"],function(a,b,c,d,e){"use strict";var f=a["default"],g=b["default"],h=c["default"],i=d["default"];e.Model=f,e.RootState=h,e.attr=g,e.Errors=i}),b("ember-data/lib/system/model/attributes",["./model","exports"],function(a,b){"use strict";function c(a,b){return"function"==typeof b.defaultValue?b.defaultValue.apply(null,arguments):b.defaultValue}function d(a,b){return a._attributes.hasOwnProperty(b)||a._inFlightAttributes.hasOwnProperty(b)||a._data.hasOwnProperty(b)}function e(a,b){return a._attributes.hasOwnProperty(b)?a._attributes[b]:a._inFlightAttributes.hasOwnProperty(b)?a._inFlightAttributes[b]:a._data[b]}function f(a,b){b=b||{};var f={type:a,isAttribute:!0,options:b};return Ember.computed("data",function(a,f){if(arguments.length>1){var g=e(this,a);return f!==g&&(this._attributes[a]=f,this.send("didSetProperty",{name:a,oldValue:g,originalValue:this._data[a],value:f})),f}return d(this,a)?e(this,a):c(this,b,a)}).meta(f)}var g=a["default"],h=Ember.get;g.reopenClass({attributes:Ember.computed(function(){var a=Ember.Map.create();return this.eachComputedProperty(function(b,c){c.isAttribute&&(c.name=b,a.set(b,c))}),a}),transformedAttributes:Ember.computed(function(){var a=Ember.Map.create();return this.eachAttribute(function(b,c){c.type&&a.set(b,c.type)}),a}),eachAttribute:function(a,b){h(this,"attributes").forEach(function(c,d){a.call(b,c,d)},b)},eachTransformedAttribute:function(a,b){h(this,"transformedAttributes").forEach(function(c,d){a.call(b,c,d)})}}),g.reopen({eachAttribute:function(a,b){this.constructor.eachAttribute(a,b)}}),b["default"]=f}),b("ember-data/lib/system/model/errors",["exports"],function(a){"use strict";var b=Ember.get,c=Ember.isEmpty,d=Ember.EnumerableUtils.map,e=Ember.Object.extend(Ember.Enumerable,Ember.Evented,{registerHandlers:function(a,b,c){this.on("becameInvalid",a,b),this.on("becameValid",a,c)},errorsByAttributeName:Ember.reduceComputed("content",{initialValue:function(){return Ember.MapWithDefault.create({defaultValue:function(){return Ember.A()}})},addedItem:function(a,b){return a.get(b.attribute).pushObject(b),a},removedItem:function(a,b){return a.get(b.attribute).removeObject(b),a}}),errorsFor:function(a){return b(this,"errorsByAttributeName").get(a)},messages:Ember.computed.mapBy("content","message"),content:Ember.computed(function(){return Ember.A()}),unknownProperty:function(a){var b=this.errorsFor(a);return c(b)?null:b},nextObject:function(a){return b(this,"content").objectAt(a)},length:Ember.computed.oneWay("content.length").readOnly(),isEmpty:Ember.computed.not("length").readOnly(),add:function(a,c){var d=b(this,"isEmpty");c=this._findOrCreateMessages(a,c),b(this,"content").addObjects(c),this.notifyPropertyChange(a),this.enumerableContentDidChange(),d&&!b(this,"isEmpty")&&this.trigger("becameInvalid")},_findOrCreateMessages:function(a,b){var c=this.errorsFor(a);return d(Ember.makeArray(b),function(b){return c.findBy("message",b)||{attribute:a,message:b}})},remove:function(a){if(!b(this,"isEmpty")){var c=b(this,"content").rejectBy("attribute",a);b(this,"content").setObjects(c),this.notifyPropertyChange(a),this.enumerableContentDidChange(),b(this,"isEmpty")&&this.trigger("becameValid")}},clear:function(){b(this,"isEmpty")||(b(this,"content").clear(),this.enumerableContentDidChange(),this.trigger("becameValid"))},has:function(a){return!c(this.errorsFor(a))}});a["default"]=e}),b("ember-data/lib/system/model/model",["./states","./errors","../store","exports"],function(a,b,d,e){"use strict";var f,g=a["default"],h=b["default"],i=d.PromiseObject,j=Ember.get,k=Ember.set,l=Ember.merge,m=Ember.RSVP.Promise,n=Ember.computed("currentState",function(a){return j(j(this,"currentState"),a)}).readOnly(),o=Ember.Object.extend(Ember.Evented,{_recordArrays:void 0,_relationships:void 0,_loadingRecordArrays:void 0,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,currentState:g.empty,errors:Ember.computed(function(){var a=h.create();return a.registerHandlers(this,function(){this.send("becameInvalid")},function(){this.send("becameValid")}),a}).readOnly(),serialize:function(a){var b=j(this,"store");return b.serialize(this,a)},toJSON:function(a){f||(f=c("ember-data/lib/serializers/json_serializer")["default"]);var b=f.create({container:this.container});return b.serialize(this,a)},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}).readOnly(),_data:null,init:function(){this._super(),this._setup()},_setup:function(){this._changesToSync={},this._deferredTriggers=[],this._data={},this._attributes={},this._inFlightAttributes={},this._relationships={}},send:function(a,b){var c=j(this,"currentState");return c[a]||this._unhandledEvent(c,a,b),c[a](this,b)},transitionTo:function(a){var b=a.split(".",1),c=j(this,"currentState"),d=c;do d.exit&&d.exit(this),d=d.parentState;while(!d.hasOwnProperty(b));var e,f,g=a.split("."),h=[],i=[];for(e=0,f=g.length;f>e;e++)d=d[g[e]],d.enter&&i.push(d),d.setup&&h.push(d);for(e=0,f=i.length;f>e;e++)i[e].enter(this);for(k(this,"currentState",d),e=0,f=h.length;f>e;e++)h[e].setup(this);this.updateRecordArraysLater()},_unhandledEvent:function(a,b,c){var d="Attempted to handle event `"+b+"` ";throw d+="on "+String(this)+" while in state ",d+=a.stateName+". ",void 0!==c&&(d+="Called with "+Ember.inspect(c)+"."),new Ember.Error(d)},withTransaction:function(a){var b=j(this,"transaction");b&&a(b)},loadingData:function(a){this.send("loadingData",a)},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.isDestroyed||this.send("unloadRecord")},clearRelationships:function(){this.eachRelationship(function(a,b){if("belongsTo"===b.kind)k(this,a,null);else if("hasMany"===b.kind){var c=this._relationships[a];c&&c.destroy()}},this)},updateRecordArrays:function(){this._updatingRecordArraysLater=!1,j(this,"store").dataWasUpdated(this.constructor,this)},changedAttributes:function(){var a,b=j(this,"_data"),c=j(this,"_attributes"),d={};for(a in c)d[a]=[b[a],c[a]];return d},adapterWillCommit:function(){this.send("willCommit")},adapterDidCommit:function(a){k(this,"isError",!1),a?this._data=a:Ember.mixin(this._data,this._inFlightAttributes),this._inFlightAttributes={},this.send("didCommit"),this.updateRecordArraysLater(),a&&this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},adapterDidDirty:function(){this.send("becomeDirty"),this.updateRecordArraysLater()},dataDidChange:Ember.observer(function(){this.reloadHasManys()},"data"),reloadHasManys:function(){var a=j(this.constructor,"relationshipsByName");this.updateRecordArraysLater(),a.forEach(function(a,b){this._data.links&&this._data.links[a]||"hasMany"===b.kind&&this.hasManyDidChange(b.key)},this)},hasManyDidChange:function(a){var b=this._relationships[a];if(b){var c=this._data[a]||[];k(b,"content",Ember.A(c)),k(b,"isLoaded",!0),b.trigger("didLoad")}},updateRecordArraysLater:function(){this._updatingRecordArraysLater||(this._updatingRecordArraysLater=!0,Ember.run.schedule("actions",this,this.updateRecordArrays))},setupData:function(a,b){b?Ember.merge(this._data,a):this._data=a;var c=this._relationships;this.eachRelationship(function(b,d){a.links&&a.links[b]||d.options.async&&(c[b]=null)}),a&&this.pushedData(),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},materializeId:function(a){k(this,"id",a)},materializeAttributes:function(a){l(this._data,a)},materializeAttribute:function(a,b){this._data[a]=b},updateHasMany:function(a,b){this._data[a]=b,this.hasManyDidChange(a)},updateBelongsTo:function(a,b){this._data[a]=b},rollback:function(){this._attributes={},j(this,"isError")&&(this._inFlightAttributes={},k(this,"isError",!1)),j(this,"isValid")||(this._inFlightAttributes={}),this.send("rolledBack"),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},toStringExtension:function(){return j(this,"id")},suspendRelationshipObservers:function(a,b){var c=j(this.constructor,"relationshipNames").belongsTo,d=this;try{this._suspendedRelationships=!0,Ember._suspendObservers(d,c,null,"belongsToDidChange",function(){Ember._suspendBeforeObservers(d,c,null,"belongsToWillChange",function(){a.call(b||d)})})}finally{this._suspendedRelationships=!1}},save:function(){var a="DS: Model#save "+this,b=Ember.RSVP.defer(a);return this.get("store").scheduleSave(this,b),this._inFlightAttributes=this._attributes,this._attributes={},i.create({promise:b.promise})},reload:function(){k(this,"isReloading",!0);var a=this,b="DS: Model#reload of "+this,c=new m(function(b){a.send("reloadRecord",b)},b).then(function(){return a.set("isReloading",!1),a.set("isError",!1),a},function(b){throw a.set("isError",!0),b},"DS: Model#reload complete, update flags");return i.create({promise:c})},adapterDidUpdateAttribute:function(a,b){void 0!==b?(this._data[a]=b,this.notifyPropertyChange(a)):this._data[a]=this._inFlightAttributes[a],this.updateRecordArraysLater()},adapterDidInvalidate:function(a){function b(b){a[b]&&c.add(b,a[b])}var c=j(this,"errors");this.eachAttribute(b),this.eachRelationship(b)},adapterDidError:function(){this.send("becameError"),k(this,"isError",!0)},trigger:function(a){Ember.tryInvoke(this,a,[].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 a=0,b=this._deferredTriggers.length;b>a;a++)this.trigger.apply(this,this._deferredTriggers[a]);this._deferredTriggers.length=0},willDestroy:function(){this._super(),this.clearRelationships()}});o.reopenClass({_create:o.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.")}}),e["default"]=o}),b("ember-data/lib/system/model/states",["exports"],function(a){"use strict";function b(a,b){b.value===b.originalValue?(delete a._attributes[b.name],a.send("propertyWasReset",b.name)):b.value!==b.oldValue&&a.send("becomeDirty"),a.updateRecordArraysLater()}function c(a){var b,d={};for(var e in a)b=a[e],d[e]=b&&"object"==typeof b?c(b):b;return d}function d(a,b){for(var c in b)a[c]=b[c];return a}function e(a){var b=c(j);return d(b,a)}function f(){}function g(a,b,c){a=d(b?Ember.create(b):{},a),a.parentState=b,a.stateName=c;for(var e in a)a.hasOwnProperty(e)&&"parentState"!==e&&"stateName"!==e&&"object"==typeof a[e]&&(a[e]=g(a[e],a,c+"."+e));return a}var h=Ember.get,i=Ember.set,j={initialState:"uncommitted",isDirty:!0,uncommitted:{didSetProperty:b,propertyWasReset:function(a){var b=!1;for(var c in a._attributes){b=!0;break}b||a.send("rolledBack")},pushedData:Ember.K,becomeDirty:Ember.K,willCommit:function(a){a.transitionTo("inFlight")},reloadRecord:function(a,b){b(h(a,"store").reloadRecord(a))},rolledBack:function(a){a.transitionTo("loaded.saved")},becameInvalid:function(a){a.transitionTo("invalid")},rollback:function(a){a.rollback()}},inFlight:{isSaving:!0,didSetProperty:b,becomeDirty:Ember.K,pushedData:Ember.K,unloadRecord:function(){},willCommit:Ember.K,didCommit:function(a){var b=h(this,"dirtyType");a.transitionTo("saved"),a.send("invokeLifecycleCallbacks",b)},becameInvalid:function(a){a.transitionTo("invalid"),a.send("invokeLifecycleCallbacks")},becameError:function(a){a.transitionTo("uncommitted"),a.triggerLater("becameError",a)}},invalid:{isValid:!1,deleteRecord:function(a){a.transitionTo("deleted.uncommitted"),a.clearRelationships()},didSetProperty:function(a,c){h(a,"errors").remove(c.name),b(a,c)},becomeDirty:Ember.K,willCommit:function(a){h(a,"errors").clear(),a.transitionTo("inFlight")},rolledBack:function(a){h(a,"errors").clear()},becameValid:function(a){a.transitionTo("uncommitted")},invokeLifecycleCallbacks:function(a){a.triggerLater("becameInvalid",a)},exit:function(a){a._inFlightAttributes={}}}},k=e({dirtyType:"created",isNew:!0});k.uncommitted.rolledBack=function(a){a.transitionTo("deleted.saved")};var l=e({dirtyType:"updated"});k.uncommitted.deleteRecord=function(a){a.clearRelationships(),a.transitionTo("deleted.saved")},k.uncommitted.rollback=function(a){j.uncommitted.rollback.apply(this,arguments),a.transitionTo("deleted.saved")},k.uncommitted.propertyWasReset=Ember.K,l.inFlight.unloadRecord=f,l.uncommitted.deleteRecord=function(a){a.transitionTo("deleted.uncommitted"),a.clearRelationships()};var m={isEmpty:!1,isLoading:!1,isLoaded:!1,isDirty:!1,isSaving:!1,isDeleted:!1,isNew:!1,isValid:!0,rolledBack:Ember.K,unloadRecord:function(a){a.clearRelationships(),a.transitionTo("deleted.saved")},propertyWasReset:Ember.K,empty:{isEmpty:!0,loadingData:function(a,b){a._loadingPromise=b,a.transitionTo("loading")},loadedData:function(a){a.transitionTo("loaded.created.uncommitted"),a.suspendRelationshipObservers(function(){a.notifyPropertyChange("data")})},pushedData:function(a){a.transitionTo("loaded.saved"),a.triggerLater("didLoad")}},loading:{isLoading:!0,exit:function(a){a._loadingPromise=null},pushedData:function(a){a.transitionTo("loaded.saved"),a.triggerLater("didLoad"),i(a,"isError",!1)},becameError:function(a){a.triggerLater("becameError",a)},notFound:function(a){a.transitionTo("empty")}},loaded:{initialState:"saved",isLoaded:!0,saved:{setup:function(a){var b=a._attributes,c=!1;for(var d in b)if(b.hasOwnProperty(d)){c=!0;break}c&&a.adapterDidDirty()},didSetProperty:b,pushedData:Ember.K,becomeDirty:function(a){a.transitionTo("updated.uncommitted")},willCommit:function(a){a.transitionTo("updated.inFlight")},reloadRecord:function(a,b){b(h(a,"store").reloadRecord(a))},deleteRecord:function(a){a.transitionTo("deleted.uncommitted"),a.clearRelationships()},unloadRecord:function(a){a.clearRelationships(),a.transitionTo("deleted.saved")},didCommit:function(a){a.send("invokeLifecycleCallbacks",h(a,"lastDirtyType"))},notFound:Ember.K},created:k,updated:l},deleted:{initialState:"uncommitted",dirtyType:"deleted",isDeleted:!0,isLoaded:!0,isDirty:!0,setup:function(a){a.updateRecordArrays()},uncommitted:{willCommit:function(a){a.transitionTo("inFlight")},rollback:function(a){a.rollback()},becomeDirty:Ember.K,deleteRecord:Ember.K,rolledBack:function(a){a.transitionTo("loaded.saved")}},inFlight:{isSaving:!0,unloadRecord:f,willCommit:Ember.K,didCommit:function(a){a.transitionTo("saved"),a.send("invokeLifecycleCallbacks")},becameError:function(a){a.transitionTo("uncommitted"),a.triggerLater("becameError",a)}},saved:{isDirty:!1,setup:function(a){var b=h(a,"store");b.dematerializeRecord(a)},invokeLifecycleCallbacks:function(a){a.triggerLater("didDelete",a),a.triggerLater("didCommit",a)},willCommit:Ember.K,didCommit:Ember.K}},invokeLifecycleCallbacks:function(a,b){"created"===b?a.triggerLater("didCreate",a):a.triggerLater("didUpdate",a),a.triggerLater("didCommit",a)}};m=g(m,null,"root"),a["default"]=m}),b("ember-data/lib/system/record_array_manager",["./record_arrays","exports"],function(a,b){"use strict";function c(a){for(var b=[],c=Ember.keys(a),d=0;d<c.length;d++)b.push(a[c[d]]);return b}function d(a){a.destroy()}function e(a){for(var b=a.length,c=Ember.A(),d=0;b>d;d++)c=c.concat(a[d]);return c}var f=a.RecordArray,g=a.FilteredRecordArray,h=a.AdapterPopulatedRecordArray,i=a.ManyArray,j=Ember.get,k=(Ember.set,Ember.EnumerableUtils.forEach),l=Ember.Object.extend({init:function(){this.filteredRecordArrays=Ember.MapWithDefault.create({defaultValue:function(){return[]}}),this.changedRecords=[],this._adapterPopulatedRecordArrays=[]},recordDidChange:function(a){1===this.changedRecords.push(a)&&Ember.run.schedule("actions",this,this.updateRecordArrays)},recordArraysForRecord:function(a){return a._recordArrays=a._recordArrays||Ember.OrderedSet.create(),a._recordArrays},updateRecordArrays:function(){k(this.changedRecords,function(a){j(a,"isDeleted")?this._recordWasDeleted(a):this._recordWasChanged(a)},this),this.changedRecords.length=0},_recordWasDeleted:function(a){var b=a._recordArrays;b&&k(b,function(b){b.removeRecord(a)})},_recordWasChanged:function(a){var b,c=a.constructor,d=this.filteredRecordArrays.get(c);k(d,function(d){b=j(d,"filterFunction"),this.updateRecordArray(d,b,c,a)},this);var e=a._loadingRecordArrays;if(e){for(var f=0,g=e.length;g>f;f++)e[f].loadedRecord();a._loadingRecordArrays=[]}},updateRecordArray:function(a,b,c,d){var e;e=b?b(d):!0;var f=this.recordArraysForRecord(d);e?(f.add(a),a.addRecord(d)):e||(f.remove(a),a.removeRecord(d))},updateFilter:function(a,b,c){for(var d,e=this.store.typeMapFor(b),f=e.records,g=0,h=f.length;h>g;g++)d=f[g],j(d,"isDeleted")||j(d,"isEmpty")||this.updateRecordArray(a,c,b,d)},createManyArray:function(a,b){var c=i.create({type:a,content:b,store:this.store});return k(b,function(a){var b=this.recordArraysForRecord(a);b.add(c)},this),c},createRecordArray:function(a){var b=f.create({type:a,content:Ember.A(),store:this.store,isLoaded:!0});return this.registerFilteredRecordArray(b,a),b},createFilteredRecordArray:function(a,b,c){var d=g.create({query:c,type:a,content:Ember.A(),store:this.store,manager:this,filterFunction:b});return this.registerFilteredRecordArray(d,a,b),d},createAdapterPopulatedRecordArray:function(a,b){var c=h.create({type:a,query:b,content:Ember.A(),store:this.store,manager:this});return this._adapterPopulatedRecordArrays.push(c),c},registerFilteredRecordArray:function(a,b,c){var d=this.filteredRecordArrays.get(b);d.push(a),this.updateFilter(a,b,c)},registerWaitingRecordArray:function(a,b){var c=a._loadingRecordArrays||[];c.push(b),a._loadingRecordArrays=c},willDestroy:function(){this._super(),k(e(c(this.filteredRecordArrays.values)),d),k(this._adapterPopulatedRecordArrays,d)}});b["default"]=l}),b("ember-data/lib/system/record_arrays",["./record_arrays/record_array","./record_arrays/filtered_record_array","./record_arrays/adapter_populated_record_array","./record_arrays/many_array","exports"],function(a,b,c,d,e){"use strict";var f=a["default"],g=b["default"],h=c["default"],i=d["default"];e.RecordArray=f,e.FilteredRecordArray=g,e.AdapterPopulatedRecordArray=h,e.ManyArray=i}),b("ember-data/lib/system/record_arrays/adapter_populated_record_array",["./record_array","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.get,e=(Ember.set,c.extend({query:null,replace:function(){var a=d(this,"type").toString();throw new Error("The result of a server query (on "+a+") is immutable.")},load:function(a){var b=d(this,"store"),c=d(this,"type"),e=b.pushMany(c,a),f=b.metadataFor(c);this.setProperties({content:Ember.A(e),isLoaded:!0,meta:Ember.copy(f)}),e.forEach(function(a){this.manager.recordArraysForRecord(a).add(this)},this),Ember.run.once(this,"trigger","didLoad")}}));b["default"]=e}),b("ember-data/lib/system/record_arrays/filtered_record_array",["./record_array","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.get,e=c.extend({filterFunction:null,isLoaded:!0,replace:function(){var a=d(this,"type").toString();throw new Error("The result of a client-side filter (on "+a+") is immutable.")},_updateFilter:function(){var a=d(this,"manager");a.updateFilter(this,d(this,"type"),d(this,"filterFunction"))},updateFilter:Ember.observer(function(){Ember.run.once(this,this._updateFilter)},"filterFunction")});b["default"]=e}),b("ember-data/lib/system/record_arrays/many_array",["./record_array","../changes","exports"],function(a,b,c){"use strict";function d(a){a.sync()}var e=a["default"],f=b.RelationshipChange,g=Ember.get,h=Ember.set,i=Ember.EnumerableUtils.map,j=e.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(a){this.loadingRecordsCount=a},loadedRecord:function(){this.loadingRecordsCount--,0===this.loadingRecordsCount&&(h(this,"isLoaded",!0),this.trigger("didLoad"))},fetch:function(){var a=g(this,"content"),b=g(this,"store"),c=g(this,"owner"),d=a.filterProperty("isEmpty",!0);b.fetchMany(d,c)},replaceContent:function(a,b,c){c=i(c,function(a){return a},this),this._super(a,b,c)},arrangedContentDidChange:function(){Ember.run.once(this,"fetch")},arrayContentWillChange:function(a,b){var c=g(this,"owner"),d=g(this,"name");if(!c._suspendedRelationships)for(var e=a;a+b>e;e++){var h=g(this,"content").objectAt(e),i=f.createChange(c,h,g(this,"store"),{parentType:c.constructor,changeType:"remove",kind:"hasMany",key:d});this._changesToSync.add(i)}return this._super.apply(this,arguments)},arrayContentDidChange:function(a,b,c){this._super.apply(this,arguments);var e=g(this,"owner"),h=g(this,"name"),i=g(this,"store");if(!e._suspendedRelationships){for(var j=a;a+c>j;j++){var k=g(this,"content").objectAt(j),l=f.createChange(e,k,i,{parentType:e.constructor,changeType:"add",kind:"hasMany",key:h});l.hasManyName=h,this._changesToSync.add(l)}this._changesToSync.forEach(d),this._changesToSync.clear()}},createRecord:function(a){var b,c=g(this,"owner"),d=g(c,"store"),e=g(this,"type");return b=d.createRecord.call(d,e,a),this.pushObject(b),b}});c["default"]=j}),b("ember-data/lib/system/record_arrays/record_array",["../store","exports"],function(a,b){"use strict";var c=a.PromiseArray,d=Ember.get,e=(Ember.set,Ember.ArrayProxy.extend(Ember.Evented,{type:null,content:null,isLoaded:!1,isUpdating:!1,store:null,objectAtContent:function(a){var b=d(this,"content");return b.objectAt(a)},update:function(){if(!d(this,"isUpdating")){var a=d(this,"store"),b=d(this,"type");return a.fetchAll(b,this)}},addRecord:function(a){d(this,"content").addObject(a)},removeRecord:function(a){d(this,"content").removeObject(a)},save:function(){var a="DS: RecordArray#save "+d(this,"type"),b=Ember.RSVP.all(this.invoke("save"),a).then(function(a){return Ember.A(a)},null,"DS: RecordArray#save apply Ember.NativeArray");return c.create({promise:b})},_dissociateFromOwnRecords:function(){var a=this;this.forEach(function(b){var c=b._recordArrays;c&&c.remove(a)})},willDestroy:function(){this._dissociateFromOwnRecords(),this._super()}}));b["default"]=e}),b("ember-data/lib/system/relationship-meta",["../../../ember-inflector/lib/system","exports"],function(a,b){"use strict";function c(a,b){var c,d;return c=b.type||b.key,"string"==typeof c?("hasMany"===b.kind&&(c=e(c)),d=a.modelFor(c)):d=b.type,d}function d(a,b){return{key:b.key,kind:b.kind,type:c(a,b),options:b.options,parentType:b.parentType,isRelationship:!0}}var e=a.singularize;b.typeForRelationshipMeta=c,b.relationshipFromMeta=d}),b("ember-data/lib/system/relationships",["./relationships/belongs_to","./relationships/has_many","../system/relationships/ext","exports"],function(a,b,c,d){"use strict";var e=a["default"],f=b["default"];d.belongsTo=e,d.hasMany=f}),b("ember-data/lib/system/relationships/belongs_to",["../model","../store","../changes","../relationship-meta","exports"],function(a,b,c,d,e){"use strict";function f(a,b,c){return Ember.computed("data",function(a,b){var d,e=h(this,"data"),f=h(this,"store"),g="DS: Async belongsTo "+this+" : "+a;if(c.key=a,2===arguments.length)return void 0===b?null:l.create({promise:j.cast(b,g)});var k=e.links&&e.links[a],m=e[a];return i(m)?k?(d=f.findBelongsTo(this,k,n(f,c)),l.create({promise:d})):null:(d=f.fetchRecord(m)||j.cast(m,g),l.create({promise:d}))}).meta(c)}function g(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c={type:a,isRelationship:!0,options:b,kind:"belongsTo",key:null};return b.async?f(a,b,c):Ember.computed("data",function(b,c){var d,e,f=h(this,"data"),g=h(this,"store");return e="string"==typeof a?g.modelFor(a):a,2===arguments.length?void 0===c?null:c:(d=f[b],i(d)?null:(g.fetchRecord(d),d))}).meta(c)}{var h=Ember.get,i=(Ember.set,Ember.isNone),j=Ember.RSVP.Promise,k=a.Model,l=b.PromiseObject,m=c.RelationshipChange,n=d.relationshipFromMeta;d.typeForRelationshipMeta}k.reopen({belongsToWillChange:Ember.beforeObserver(function(a,b){if(h(a,"isLoaded")){var c=h(a,b);if(c){var d=h(a,"store"),e=m.createChange(a,c,d,{key:b,kind:"belongsTo",changeType:"remove"});e.sync(),this._changesToSync[b]=e}}}),belongsToDidChange:Ember.immediateObserver(function(a,b){if(h(a,"isLoaded")){var c=h(a,b);if(c){var d=h(a,"store"),e=m.createChange(a,c,d,{key:b,kind:"belongsTo",changeType:"add"});e.sync()}}delete this._changesToSync[b]})}),e["default"]=g}),b("ember-data/lib/system/relationships/ext",["../../../../ember-inflector/lib/system","../relationship-meta","../model"],function(a,b,c){"use strict";{var d=(a.singularize,b.typeForRelationshipMeta),e=b.relationshipFromMeta,f=c.Model,g=Ember.get;Ember.set}f.reopen({didDefineProperty:function(a,b,c){if(c instanceof Ember.Descriptor){var d=c.meta();d.isRelationship&&"belongsTo"===d.kind&&(Ember.addObserver(a,b,null,"belongsToDidChange"),Ember.addBeforeObserver(a,b,null,"belongsToWillChange")),d.parentType=a.constructor}}}),f.reopenClass({typeForRelationship:function(a){var b=g(this,"relationshipsByName").get(a);return b&&b.type},inverseFor:function(a){function b(a,c,d){d=d||[];var e=g(c,"relationships");if(e){var f=e.get(a);return f&&d.push.apply(d,e.get(a)),a.superclass&&b(a.superclass,c,d),d}}var c=this.typeForRelationship(a);if(!c)return null;var d=this.metaForProperty(a).options;if(null===d.inverse)return null;var e,f;if(d.inverse)e=d.inverse,f=Ember.get(c,"relationshipsByName").get(e).kind;else{var h=b(this,c);if(0===h.length)return null;e=h[0].name,f=h[0].kind}return{type:c,name:e,kind:f}},relationships:Ember.computed(function(){var a=new Ember.MapWithDefault({defaultValue:function(){return[]}});return this.eachComputedProperty(function(b,c){if(c.isRelationship){c.key=b;var e=a.get(d(this.store,c));e.push({name:b,kind:c.kind})}}),a}).cacheable(!1),relationshipNames:Ember.computed(function(){var a={hasMany:[],belongsTo:[]};return this.eachComputedProperty(function(b,c){c.isRelationship&&a[c.kind].push(b)}),a}),relatedTypes:Ember.computed(function(){var a,b=Ember.A();return this.eachComputedProperty(function(c,e){e.isRelationship&&(e.key=c,a=d(this.store,e),b.contains(a)||b.push(a))}),b}).cacheable(!1),relationshipsByName:Ember.computed(function(){var a=Ember.Map.create();return this.eachComputedProperty(function(b,c){if(c.isRelationship){c.key=b;var f=e(this.store,c);f.type=d(this.store,c),a.set(b,f)}}),a}).cacheable(!1),fields:Ember.computed(function(){var a=Ember.Map.create();return this.eachComputedProperty(function(b,c){c.isRelationship?a.set(b,c.kind):c.isAttribute&&a.set(b,"attribute")}),a}),eachRelationship:function(a,b){g(this,"relationshipsByName").forEach(function(c,d){a.call(b,c,d)})},eachRelatedType:function(a,b){g(this,"relatedTypes").forEach(function(c){a.call(b,c)})}}),f.reopen({eachRelationship:function(a,b){this.constructor.eachRelationship(a,b)}})}),b("ember-data/lib/system/relationships/has_many",["../store","../relationship-meta","exports"],function(a,b,c){"use strict";function d(a,b,c){return Ember.computed("data",function(a){var d=this._relationships[a],f="DS: Async hasMany "+this+" : "+a;if(c.key=a,!d){var g=Ember.RSVP.defer(f);d=e(this,a,b,function(b,d){var e,f=d.links&&d.links[a];return e=f?b.findHasMany(this,f,l(b,c),g):b.findMany(this,d[a],m(b,c),g),j(e,"promise",g.promise),e})}var i=d.get("promise").then(function(){return d},null,"DS: Async hasMany records received");return h.create({promise:i})}).meta(c).readOnly()}function e(a,b,c,d){var e=a._relationships;if(e[b])return e[b];var f=i(a,"data"),g=i(a,"store"),h=e[b]=d.call(a,g,f);return k(h,{owner:a,name:b,isPolymorphic:c.polymorphic})}function f(a,b){b=b||{};var c={type:a,isRelationship:!0,options:b,kind:"hasMany",key:null};return b.async?d(a,b,c):Ember.computed("data",function(a){return e(this,a,b,function(b,d){d[a];return b.findMany(this,d[a],m(b,c))})}).meta(c).readOnly()}function g(a,b){return"object"==typeof a&&(b=a,a=void 0),f(a,b)}var h=a.PromiseArray,i=Ember.get,j=Ember.set,k=Ember.setProperties,l=b.relationshipFromMeta,m=b.typeForRelationshipMeta;c["default"]=g}),b("ember-data/lib/system/store",["./adapter","ember-inflector/lib/system/string","exports"],function(a,b,d){"use strict";function e(a){return null==a?null:a+""}function f(a,b,c,d){return b.eachRelationship(function(b,e){if(c.links&&c.links[b])return void(d&&e.options.async&&(d._relationships[b]=null));var f=e.kind,h=c[b];null!=h&&("belongsTo"===f?g(a,c,b,e,h):"hasMany"===f&&(i(a,c,b,e,h),j(d,b,h)))}),c}function g(a,b,d,e,f){if(A||(A=c("ember-data/lib/system/model").Model),!(G(f)||f instanceof A)){var g;"number"==typeof f||"string"==typeof f?(g=h(e,d,b),b[d]=a.recordForId(g,f)):"object"==typeof f&&(b[d]=a.recordForId(f.type,f.id))}}function h(a,b,c){return a.options.polymorphic?c[b+"Type"]:a.type}function i(a,b,c,d,e){for(var f=0,h=e.length;h>f;f++)g(a,e,f,d,e[f])}function j(a,b,c){a&&Ember.A(c).pushObjects(a.get(b).filterBy("isNew"))}function k(a,b){return x.create({promise:K.cast(a,b)})}function l(a,b){return y.create({promise:K.cast(a,b)})}function m(a,b,c){return a.lookup("serializer:"+b)||a.lookup("serializer:application")||a.lookup("serializer:"+c)||a.lookup("serializer:-default")}function n(a){return a.lookup("serializer:application")||a.lookup("serializer:-default")}function o(a,b){var c=a.serializer,d=a.defaultSerializer,e=a.container;return e&&void 0===c&&(c=m(e,b.typeKey,d)),(null===c||void 0===c)&&(c={extract:function(a,b,c){return c}}),c}function p(a,b,c,d){var e=a.find(b,c,d),f=o(a,c),g="DS: Handle Adapter#find of "+c+" with id: "+d;return K.cast(e,g).then(function(a){var e=f.extract(b,c,a,d,"find");return b.push(c,e)},function(a){var e=b.getById(c,d);throw e.notFound(),a},"DS: Extract payload of '"+c+"'")}function q(a,b,c,d,e){var f=a.findMany(b,c,d,e),g=o(a,c),h="DS: Handle Adapter#findMany of "+c;return K.cast(f,h).then(function(a){var d=g.extract(b,c,a,null,"findMany");b.pushMany(c,d)},null,"DS: Extract payload of "+c)}function r(a,b,c,d,e){var f=a.findHasMany(b,c,d,e),g=o(a,e.type),h="DS: Handle Adapter#findHasMany of "+c+" : "+e.type;return K.cast(f,h).then(function(a){var d=g.extract(b,e.type,a,null,"findHasMany"),f=b.pushMany(e.type,d);c.updateHasMany(e.key,f)},null,"DS: Extract payload of "+c+" : hasMany "+e.type)}function s(a,b,c,d,e){var f=a.findBelongsTo(b,c,d,e),g=o(a,e.type),h="DS: Handle Adapter#findBelongsTo of "+c+" : "+e.type;return K.cast(f,h).then(function(a){var c=g.extract(b,e.type,a,null,"findBelongsTo"),d=b.push(e.type,c);return d.updateBelongsTo(e.key,d),d},null,"DS: Extract payload of "+c+" : "+e.type)}function t(a,b,c,d){var e=a.findAll(b,c,d),f=o(a,c),g="DS: Handle Adapter#findAll of "+c;return K.cast(e,g).then(function(a){var d=f.extract(b,c,a,null,"findAll");return b.pushMany(c,d),b.didUpdateAll(c),b.all(c)},null,"DS: Extract payload of findAll "+c)}function u(a,b,c,d,e){var f=a.findQuery(b,c,d,e),g=o(a,c),h="DS: Handle Adapter#findQuery of "+c;return K.cast(f,h).then(function(a){var d=g.extract(b,c,a,null,"findQuery");return e.load(d),e},null,"DS: Extract payload of findQuery "+c)}function v(a,b,c,d){var e=d.constructor,f=a[c](b,e,d),g=o(a,e),h="DS: Extract and notify about "+c+" completion of "+d;return f.then(function(a){var f;return f=a?g.extract(b,e,a,D(d,"id"),c):a,b.didSaveRecord(d,f),d},function(a){throw a instanceof B?b.recordWasInvalid(d,a.errors):b.recordWasError(d,a),a},h)}var w,x,y,z,A,B=a.InvalidError,C=(a.Adapter,b.singularize),D=Ember.get,E=Ember.set,F=Ember.run.once,G=Ember.isNone,H=Ember.EnumerableUtils.forEach,I=Ember.EnumerableUtils.indexOf,J=Ember.EnumerableUtils.map,K=Ember.RSVP.Promise,L=Ember.copy,M=Ember.String.camelize;
10
+ w=Ember.Object.extend({init:function(){z||(z=c("ember-data/lib/system/record_array_manager")["default"]),this.typeMaps={},this.recordArrayManager=z.create({store:this}),this._relationshipChanges={},this._pendingSave=[]},adapter:"-rest",serialize:function(a,b){return this.serializerFor(a.constructor.typeKey).serialize(a,b)},defaultAdapter:Ember.computed("adapter",function(){var a=D(this,"adapter");return"string"==typeof a&&(a=this.container.lookup("adapter:"+a)||this.container.lookup("adapter:application")||this.container.lookup("adapter:-rest")),DS.Adapter.detect(a)&&(a=a.create({container:this.container})),a}),createRecord:function(a,b){a=this.modelFor(a),b=L(b)||{},G(b.id)&&(b.id=this._generateId(a)),b.id=e(b.id);var c=this.buildRecord(a,b.id);return c.loadedData(),c.setProperties(b),c},_generateId:function(a){var b=this.adapterFor(a);return b&&b.generateIdForRecord?b.generateIdForRecord(this):null},deleteRecord:function(a){a.deleteRecord()},unloadRecord:function(a){a.unloadRecord()},find:function(a,b){return 1===arguments.length?this.findAll(a):"object"===Ember.typeOf(b)?this.findQuery(a,b):this.findById(a,e(b))},findById:function(a,b){a=this.modelFor(a);var c=this.recordForId(a,b),d=this.fetchRecord(c);return k(d||c,"DS: Store#findById "+a+" with id: "+b)},findByIds:function(a,b){var c=this;return l(Ember.RSVP.all(J(b,function(b){return c.findById(a,b)})).then(Ember.A,null,"DS: Store#findByIds of "+a+" complete"))},fetchRecord:function(a){if(G(a))return null;if(a._loadingPromise)return a._loadingPromise;if(!D(a,"isEmpty"))return null;var b=a.constructor,c=D(a,"id"),d=this.adapterFor(b),e=p(d,this,b,c);return a.loadingData(e),e},getById:function(a,b){return this.hasRecordForId(a,b)?this.recordForId(a,b):null},reloadRecord:function(a){var b=a.constructor,c=this.adapterFor(b),d=D(a,"id");return p(c,this,b,d)},fetchMany:function(a,b){if(!a.length)return Ember.RSVP.resolve(a);var c=Ember.MapWithDefault.create({defaultValue:function(){return Ember.A()}});H(a,function(a){c.get(a.constructor).push(a)});var d=[];return H(c,function(a,c){var e=c.mapProperty("id"),f=this.adapterFor(a);d.push(q(f,this,a,e,b))},this),Ember.RSVP.all(d)},hasRecordForId:function(a,b){return b=e(b),a=this.modelFor(a),!!this.typeMapFor(a).idToRecord[b]},recordForId:function(a,b){a=this.modelFor(a),b=e(b);var c=this.typeMapFor(a).idToRecord[b];return c||(c=this.buildRecord(a,b)),c},findMany:function(a,b,c,d){c=this.modelFor(c),b=Ember.A(b);var e=b.filterProperty("isEmpty",!0),f=this.recordArrayManager.createManyArray(c,b);return H(e,function(a){a.loadingData()}),f.loadingRecordsCount=e.length,e.length?(H(e,function(a){this.recordArrayManager.registerWaitingRecordArray(a,f)},this),d.resolve(this.fetchMany(e,a))):(d&&d.resolve(),f.set("isLoaded",!0),F(f,"trigger","didLoad")),f},findHasMany:function(a,b,c,d){var e=this.adapterFor(a.constructor),f=this.recordArrayManager.createManyArray(c.type,Ember.A([]));return d.resolve(r(e,this,a,b,c)),f},findBelongsTo:function(a,b,c){var d=this.adapterFor(a.constructor);return s(d,this,a,b,c)},findQuery:function(a,b){a=this.modelFor(a);var c=this.recordArrayManager.createAdapterPopulatedRecordArray(a,b),d=this.adapterFor(a);return l(u(d,this,a,b,c))},findAll:function(a){return a=this.modelFor(a),this.fetchAll(a,this.all(a))},fetchAll:function(a,b){var c=this.adapterFor(a),d=this.typeMapFor(a).metadata.since;return E(b,"isUpdating",!0),l(t(c,this,a,d))},didUpdateAll:function(a){var b=this.typeMapFor(a).findAllCache;E(b,"isUpdating",!1)},all:function(a){a=this.modelFor(a);var b=this.typeMapFor(a),c=b.findAllCache;if(c)return c;var d=this.recordArrayManager.createRecordArray(a);return b.findAllCache=d,d},unloadAll:function(a){for(var b,c=this.modelFor(a),d=this.typeMapFor(c),e=d.records.slice(),f=0;f<e.length;f++)b=e[f],b.unloadRecord(),b.destroy();d.findAllCache=null},filter:function(a,b,c){var d,e,f=arguments.length,g=3===f;return g?d=this.findQuery(a,b):2===arguments.length&&(c=b),a=this.modelFor(a),e=g?this.recordArrayManager.createFilteredRecordArray(a,c,b):this.recordArrayManager.createFilteredRecordArray(a,c),d=d||K.cast(e),l(d.then(function(){return e},null,"DS: Store#filter of "+a))},recordIsLoaded:function(a,b){return this.hasRecordForId(a,b)?!D(this.recordForId(a,b),"isEmpty"):!1},metadataFor:function(a){return a=this.modelFor(a),this.typeMapFor(a).metadata},dataWasUpdated:function(a,b){this.recordArrayManager.recordDidChange(b)},scheduleSave:function(a,b){a.adapterWillCommit(),this._pendingSave.push([a,b]),F(this,"flushPendingSave")},flushPendingSave:function(){var a=this._pendingSave.slice();this._pendingSave=[],H(a,function(a){var b,c=a[0],d=a[1],e=this.adapterFor(c.constructor);return"root.deleted.saved"===D(c,"currentState.stateName")?d.resolve(c):(b=D(c,"isNew")?"createRecord":D(c,"isDeleted")?"deleteRecord":"updateRecord",void d.resolve(v(e,this,b,c)))},this)},didSaveRecord:function(a,b){b&&(b=f(this,a.constructor,b,a),this.updateId(a,b)),a.adapterDidCommit(b)},recordWasInvalid:function(a,b){a.adapterDidInvalidate(b)},recordWasError:function(a){a.adapterDidError()},updateId:function(a,b){var c=(D(a,"id"),e(b.id));this.typeMapFor(a.constructor).idToRecord[c]=a,E(a,"id",c)},typeMapFor:function(a){var b,c=D(this,"typeMaps"),d=Ember.guidFor(a);return(b=c[d])?b:(b={idToRecord:{},records:[],metadata:{},type:a},c[d]=b,b)},_load:function(a,b,c){var d=e(b.id),f=this.recordForId(a,d);return f.setupData(b,c),this.recordArrayManager.recordDidChange(f),f},modelFor:function(a){var b;if("string"==typeof a){var c=this.container.normalize("model:"+a);if(b=this.container.lookupFactory(c),!b)throw new Ember.Error("No model was found for '"+a+"'");b.typeKey=this._normalizeTypeKey(c.split(":",2)[1])}else b=a,b.typeKey&&(b.typeKey=this._normalizeTypeKey(b.typeKey));return b.store=this,b},push:function(a,b,c){return a=this.modelFor(a),b=f(this,a,b),this._load(a,b,c),this.recordForId(a,b.id)},pushPayload:function(a,b){var c;b?c=this.serializerFor(a):(b=a,c=n(this.container)),c.pushPayload(this,b)},update:function(a,b){return this.push(a,b,!0)},pushMany:function(a,b){return J(b,function(b){return this.push(a,b)},this)},metaForType:function(a,b){a=this.modelFor(a),Ember.merge(this.typeMapFor(a).metadata,b)},buildRecord:function(a,b,c){var d=this.typeMapFor(a),e=d.idToRecord,f=a._create({id:b,store:this,container:this.container});return c&&f.setupData(c),b&&(e[b]=f),d.records.push(f),f},dematerializeRecord:function(a){var b=a.constructor,c=this.typeMapFor(b),d=D(a,"id");a.updateRecordArrays(),d&&delete c.idToRecord[d];var e=I(c.records,a);c.records.splice(e,1)},addRelationshipChangeFor:function(a,b,c,d,e){var f=a.clientId,g=c?c:c,h=b+d,i=this._relationshipChanges;f in i||(i[f]={}),g in i[f]||(i[f][g]={}),h in i[f][g]||(i[f][g][h]={}),i[f][g][h][e.changeType]=e},removeRelationshipChangeFor:function(a,b,c,d,e){var f=a.clientId,g=c?c.clientId:c,h=this._relationshipChanges,i=b+d;f in h&&g in h[f]&&i in h[f][g]&&delete h[f][g][i][e]},relationshipChangePairsFor:function(a){var b=[];if(!a)return b;var c=this._relationshipChanges[a.clientId];for(var d in c)if(c.hasOwnProperty(d))for(var e in c[d])c[d].hasOwnProperty(e)&&b.push(c[d][e]);return b},adapterFor:function(a){var b,c=this.container;return c&&(b=c.lookup("adapter:"+a.typeKey)||c.lookup("adapter:application")),b||D(this,"defaultAdapter")},serializerFor:function(a){a=this.modelFor(a);var b=this.adapterFor(a);return m(this.container,a.typeKey,b&&b.defaultSerializer)},willDestroy:function(){function a(a){return b[a].type}var b=this.typeMaps,c=Ember.keys(b),d=J(c,a);this.recordArrayManager.destroy(),H(d,this.unloadAll,this)},_normalizeTypeKey:function(a){return M(C(a))}}),y=Ember.ArrayProxy.extend(Ember.PromiseProxyMixin),x=Ember.ObjectProxy.extend(Ember.PromiseProxyMixin),d.Store=w,d.PromiseArray=y,d.PromiseObject=x,d["default"]=w}),b("ember-data/lib/transforms",["./transforms/base","./transforms/number","./transforms/date","./transforms/string","./transforms/boolean","exports"],function(a,b,c,d,e,f){"use strict";var g=a["default"],h=b["default"],i=c["default"],j=d["default"],k=e["default"];f.Transform=g,f.NumberTransform=h,f.DateTransform=i,f.StringTransform=j,f.BooleanTransform=k}),b("ember-data/lib/transforms/base",["exports"],function(a){"use strict";var b=Ember.Object.extend({serialize:Ember.required(),deserialize:Ember.required()});a["default"]=b}),b("ember-data/lib/transforms/boolean",["./base","exports"],function(a,b){"use strict";var c=a["default"],d=c.extend({deserialize:function(a){var b=typeof a;return"boolean"===b?a:"string"===b?null!==a.match(/^true$|^t$|^1$/i):"number"===b?1===a:!1},serialize:function(a){return Boolean(a)}});b["default"]=d}),b("ember-data/lib/transforms/date",["./base","exports"],function(a,b){"use strict";var c=a["default"],d=c.extend({deserialize:function(a){var b=typeof a;return"string"===b?new Date(Ember.Date.parse(a)):"number"===b?new Date(a):null===a||void 0===a?a:null},serialize:function(a){if(a instanceof Date){var b=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],d=function(a){return 10>a?"0"+a:""+a},e=a.getUTCFullYear(),f=a.getUTCMonth(),g=a.getUTCDate(),h=a.getUTCDay(),i=a.getUTCHours(),j=a.getUTCMinutes(),k=a.getUTCSeconds(),l=b[h],m=d(g),n=c[f];return l+", "+m+" "+n+" "+e+" "+d(i)+":"+d(j)+":"+d(k)+" GMT"}return null}});b["default"]=d}),b("ember-data/lib/transforms/number",["./base","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.isEmpty,e=c.extend({deserialize:function(a){return d(a)?null:Number(a)},serialize:function(a){return d(a)?null:Number(a)}});b["default"]=e}),b("ember-data/lib/transforms/string",["./base","exports"],function(a,b){"use strict";var c=a["default"],d=Ember.isNone,e=c.extend({deserialize:function(a){return d(a)?null:String(a)},serialize:function(a){return d(a)?null:String(a)}});b["default"]=e}),b("ember-inflector/lib/ext/string",["../system/string"],function(a){"use strict";var b=a.pluralize,c=a.singularize;(Ember.EXTEND_PROTOTYPES===!0||Ember.EXTEND_PROTOTYPES.String)&&(String.prototype.pluralize=function(){return b(this)},String.prototype.singularize=function(){return c(this)})}),b("ember-inflector/lib/main",["./system","./ext/string","exports"],function(a,b,c){"use strict";var d=a.Inflector,e=a.defaultRules,f=a.pluralize,g=a.singularize;d.defaultRules=e,Ember.Inflector=d,Ember.String.pluralize=f,Ember.String.singularize=g,c["default"]=d,c.pluralize=f,c.singularize=g}),b("ember-inflector/lib/system",["./system/inflector","./system/string","./system/inflections","exports"],function(a,b,c,d){"use strict";var e=a["default"],f=b.pluralize,g=b.singularize,h=c["default"];e.inflector=new e(h),d.Inflector=e,d.singularize=g,d.pluralize=f,d.defaultRules=h}),b("ember-inflector/lib/system/inflections",["exports"],function(a){"use strict";var b={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"]};a["default"]=b}),b("ember-inflector/lib/system/inflector",["exports"],function(a){"use strict";function b(a,b){for(var c=0,d=b.length;d>c;c++)a.uncountable[b[c].toLowerCase()]=!0}function c(a,b){for(var c,d=0,e=b.length;e>d;d++)c=b[d],a.irregular[c[0].toLowerCase()]=c[1],a.irregularInverse[c[1].toLowerCase()]=c[0]}function d(a){a=a||{},a.uncountable=a.uncountable||{},a.irregularPairs=a.irregularPairs||{};var d=this.rules={plurals:a.plurals||[],singular:a.singular||[],irregular:{},irregularInverse:{},uncountable:{}};b(d,a.uncountable),c(d,a.irregularPairs)}var e=/^\s*$/;d.prototype={plural:function(a,b){this.rules.plurals.push([a,b.toLowerCase()])},singular:function(a,b){this.rules.singular.push([a,b.toLowerCase()])},uncountable:function(a){b(this.rules,[a.toLowerCase()])},irregular:function(a,b){c(this.rules,[[a,b]])},pluralize:function(a){return this.inflect(a,this.rules.plurals,this.rules.irregular)},singularize:function(a){return this.inflect(a,this.rules.singular,this.rules.irregularInverse)},inflect:function(a,b,c){var d,f,g,h,i,j,k,l;if(i=e.test(a))return a;if(h=a.toLowerCase(),j=this.rules.uncountable[h])return a;if(k=c&&c[h])return k;for(var m=b.length,n=0;m>n&&(d=b[m-1],l=d[0],!l.test(a));m--);return d=d||[],l=d[0],f=d[1],g=a.replace(l,f)}},a["default"]=d}),b("ember-inflector/lib/system/string",["./inflector","exports"],function(a,b){"use strict";var c=a["default"],d=function(a){return c.inflector.pluralize(a)},e=function(a){return c.inflector.singularize(a)};b.pluralize=d,b.singularize=e}),a.DS=c("ember-data/lib/main")["default"]}(Ember.lookup);
@@ -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.7+canary.f482da04
6
+ * @version 1.0.0-beta.8.2a68c63a
7
7
  */
8
8
  (function(global) {
9
9
  var define, requireModule, require, requirejs;
@@ -60,44 +60,37 @@ var define, requireModule, require, requirejs;
60
60
  };
61
61
  })();
62
62
 
63
- define("activemodel-adapter/lib/initializers",
64
- ["../../ember-data/lib/system/container_proxy","./system/active_model_serializer","./system/active_model_adapter"],
65
- function(__dependency1__, __dependency2__, __dependency3__) {
66
- "use strict";
67
- var ContainerProxy = __dependency1__["default"];
68
- var ActiveModelSerializer = __dependency2__["default"];
69
- var ActiveModelAdapter = __dependency3__["default"];
70
-
71
- Ember.onLoad('Ember.Application', function(Application) {
72
- Application.initializer({
73
- name: "activeModelAdapter",
74
-
75
- initialize: function(container, application) {
76
- var proxy = new ContainerProxy(container);
77
- proxy.registerDeprecations([
78
- {deprecated: 'serializer:_ams', valid: 'serializer:-active-model'},
79
- {deprecated: 'adapter:_ams', valid: 'adapter:-active-model'}
80
- ]);
81
-
82
- application.register('serializer:-active-model', ActiveModelSerializer);
83
- application.register('adapter:-active-model', ActiveModelAdapter);
84
- }
85
- });
86
- });
87
- });
88
63
  define("activemodel-adapter/lib/main",
89
- ["./system","./initializers","exports"],
90
- function(__dependency1__, __dependency2__, __exports__) {
64
+ ["./system","exports"],
65
+ function(__dependency1__, __exports__) {
91
66
  "use strict";
92
67
  var ActiveModelAdapter = __dependency1__.ActiveModelAdapter;
93
68
  var ActiveModelSerializer = __dependency1__.ActiveModelSerializer;
94
69
  var EmbeddedRecordsMixin = __dependency1__.EmbeddedRecordsMixin;
95
70
 
96
-
97
71
  __exports__.ActiveModelAdapter = ActiveModelAdapter;
98
72
  __exports__.ActiveModelSerializer = ActiveModelSerializer;
99
73
  __exports__.EmbeddedRecordsMixin = EmbeddedRecordsMixin;
100
74
  });
75
+ define("activemodel-adapter/lib/setup-container",
76
+ ["../../ember-data/lib/system/container_proxy","./system/active_model_serializer","./system/active_model_adapter","exports"],
77
+ function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
78
+ "use strict";
79
+ var ContainerProxy = __dependency1__["default"];
80
+ var ActiveModelSerializer = __dependency2__["default"];
81
+ var ActiveModelAdapter = __dependency3__["default"];
82
+
83
+ __exports__["default"] = function setupActiveModelAdapter(container, application){
84
+ var proxy = new ContainerProxy(container);
85
+ proxy.registerDeprecations([
86
+ {deprecated: 'serializer:_ams', valid: 'serializer:-active-model'},
87
+ {deprecated: 'adapter:_ams', valid: 'adapter:-active-model'}
88
+ ]);
89
+
90
+ container.register('serializer:-active-model', ActiveModelSerializer);
91
+ container.register('adapter:-active-model', ActiveModelAdapter);
92
+ };
93
+ });
101
94
  define("activemodel-adapter/lib/system",
102
95
  ["./system/embedded_records_mixin","./system/active_model_adapter","./system/active_model_serializer","exports"],
103
96
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
@@ -130,10 +123,11 @@ define("activemodel-adapter/lib/system/active_model_adapter",
130
123
 
131
124
  /**
132
125
  The ActiveModelAdapter is a subclass of the RESTAdapter designed to integrate
133
- with a JSON API that uses an underscored naming convention instead of camelcasing.
126
+ with a JSON API that uses an underscored naming convention instead of camelCasing.
134
127
  It has been designed to work out of the box with the
135
128
  [active_model_serializers](http://github.com/rails-api/active_model_serializers)
136
- Ruby gem.
129
+ Ruby gem. This Adapter expects specific settings using ActiveModel::Serializers,
130
+ `embed :ids, include: true` which sideloads the records.
137
131
 
138
132
  This adapter extends the DS.RESTAdapter by making consistent use of the camelization,
139
133
  decamelization and pluralization methods to normalize the serialized JSON into a
@@ -174,7 +168,7 @@ define("activemodel-adapter/lib/system/active_model_adapter",
174
168
  @class ActiveModelAdapter
175
169
  @constructor
176
170
  @namespace DS
177
- @extends DS.Adapter
171
+ @extends DS.RESTAdapter
178
172
  **/
179
173
 
180
174
  var ActiveModelAdapter = RESTAdapter.extend({
@@ -190,7 +184,7 @@ define("activemodel-adapter/lib/system/active_model_adapter",
190
184
 
191
185
  @method pathForType
192
186
  @param {String} type
193
- @returns String
187
+ @return String
194
188
  */
195
189
  pathForType: function(type) {
196
190
  var decamelized = decamelize(type);
@@ -212,7 +206,7 @@ define("activemodel-adapter/lib/system/active_model_adapter",
212
206
 
213
207
  @method ajaxError
214
208
  @param jqXHR
215
- @returns error
209
+ @return error
216
210
  */
217
211
  ajaxError: function(jqXHR) {
218
212
  var error = this._super(jqXHR);
@@ -254,16 +248,65 @@ define("activemodel-adapter/lib/system/active_model_serializer",
254
248
  capitalize = Ember.String.capitalize,
255
249
  decamelize = Ember.String.decamelize,
256
250
  underscore = Ember.String.underscore;
251
+ /**
252
+ The ActiveModelSerializer is a subclass of the RESTSerializer designed to integrate
253
+ with a JSON API that uses an underscored naming convention instead of camelCasing.
254
+ It has been designed to work out of the box with the
255
+ [active_model_serializers](http://github.com/rails-api/active_model_serializers)
256
+ Ruby gem. This Serializer expects specific settings using ActiveModel::Serializers,
257
+ `embed :ids, include: true` which sideloads the records.
258
+
259
+ This serializer extends the DS.RESTSerializer by making consistent
260
+ use of the camelization, decamelization and pluralization methods to
261
+ normalize the serialized JSON into a format that is compatible with
262
+ a conventional Rails backend and Ember Data.
263
+
264
+ ## JSON Structure
265
+
266
+ The ActiveModelSerializer expects the JSON returned from your server
267
+ to follow the REST adapter conventions substituting underscored keys
268
+ for camelcased ones.
269
+
270
+ ### Conventional Names
271
+
272
+ Attribute names in your JSON payload should be the underscored versions of
273
+ the attributes in your Ember.js models.
257
274
 
275
+ For example, if you have a `Person` model:
276
+
277
+ ```js
278
+ App.FamousPerson = DS.Model.extend({
279
+ firstName: DS.attr('string'),
280
+ lastName: DS.attr('string'),
281
+ occupation: DS.attr('string')
282
+ });
283
+ ```
284
+
285
+ The JSON returned should look like this:
286
+
287
+ ```js
288
+ {
289
+ "famous_person": {
290
+ "first_name": "Barack",
291
+ "last_name": "Obama",
292
+ "occupation": "President"
293
+ }
294
+ }
295
+ ```
296
+
297
+ @class ActiveModelSerializer
298
+ @namespace DS
299
+ @extends DS.RESTSerializer
300
+ */
258
301
  var ActiveModelSerializer = RESTSerializer.extend({
259
302
  // SERIALIZE
260
303
 
261
304
  /**
262
- Converts camelcased attributes to underscored when serializing.
305
+ Converts camelCased attributes to underscored when serializing.
263
306
 
264
307
  @method keyForAttribute
265
308
  @param {String} attribute
266
- @returns String
309
+ @return String
267
310
  */
268
311
  keyForAttribute: function(attr) {
269
312
  return decamelize(attr);
@@ -276,7 +319,7 @@ define("activemodel-adapter/lib/system/active_model_serializer",
276
319
  @method keyForRelationship
277
320
  @param {String} key
278
321
  @param {String} kind
279
- @returns String
322
+ @return String
280
323
  */
281
324
  keyForRelationship: function(key, kind) {
282
325
  key = decamelize(key);
@@ -289,7 +332,7 @@ define("activemodel-adapter/lib/system/active_model_serializer",
289
332
  }
290
333
  },
291
334
 
292
- /**
335
+ /*
293
336
  Does not serialize hasMany relationships by default.
294
337
  */
295
338
  serializeHasMany: Ember.K,
@@ -319,29 +362,19 @@ define("activemodel-adapter/lib/system/active_model_serializer",
319
362
  serializePolymorphicType: function(record, json, relationship) {
320
363
  var key = relationship.key,
321
364
  belongsTo = get(record, key);
322
- key = this.keyForAttribute(key);
323
- json[key + "_type"] = capitalize(camelize(belongsTo.constructor.typeKey));
365
+
366
+ if (belongsTo) {
367
+ key = this.keyForAttribute(key);
368
+ json[key + "_type"] = capitalize(belongsTo.constructor.typeKey);
369
+ }
324
370
  },
325
371
 
326
372
  // EXTRACT
327
373
 
328
374
  /**
329
- Extracts the model typeKey from underscored root objects.
375
+ Add extra step to `DS.RESTSerializer.normalize` so links are normalized.
330
376
 
331
- @method typeForRoot
332
- @param {String} root
333
- @returns String the model's typeKey
334
- */
335
- typeForRoot: function(root) {
336
- var camelized = camelize(root);
337
- return singularize(camelized);
338
- },
339
-
340
- /**
341
- Add extra step to `DS.RESTSerializer.normalize` so links are
342
- normalized.
343
-
344
- If your payload looks like this
377
+ If your payload looks like:
345
378
 
346
379
  ```js
347
380
  {
@@ -352,6 +385,7 @@ define("activemodel-adapter/lib/system/active_model_serializer",
352
385
  }
353
386
  }
354
387
  ```
388
+
355
389
  The normalized version would look like this
356
390
 
357
391
  ```js
@@ -368,7 +402,7 @@ define("activemodel-adapter/lib/system/active_model_serializer",
368
402
  @param {subclass of DS.Model} type
369
403
  @param {Object} hash
370
404
  @param {String} prop
371
- @returns Object
405
+ @return Object
372
406
  */
373
407
 
374
408
  normalize: function(type, hash, prop) {
@@ -381,7 +415,7 @@ define("activemodel-adapter/lib/system/active_model_serializer",
381
415
  Convert `snake_cased` links to `camelCase`
382
416
 
383
417
  @method normalizeLinks
384
- @param {Object} hash
418
+ @param {Object} data
385
419
  */
386
420
 
387
421
  normalizeLinks: function(data){
@@ -460,24 +494,83 @@ define("activemodel-adapter/lib/system/embedded_records_mixin",
460
494
  "use strict";
461
495
  var get = Ember.get;
462
496
  var forEach = Ember.EnumerableUtils.forEach;
497
+ var camelize = Ember.String.camelize;
463
498
 
464
499
  var pluralize = __dependency1__.pluralize;
465
500
 
466
501
  /**
467
- The EmbeddedRecordsMixin allows you to add embedded record support to your
468
- serializers.
469
- To set up embedded records, you include the mixin into the serializer and then
470
- define your embedded relations.
502
+ ## Using Embedded Records
503
+
504
+ `DS.EmbeddedRecordsMixin` supports serializing embedded records.
505
+
506
+ To set up embedded records, include the mixin when extending a serializer
507
+ then define and configure embedded (model) relationships.
508
+
509
+ Below is an example of a per-type serializer ('post' type).
471
510
 
472
511
  ```js
473
512
  App.PostSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
474
513
  attrs: {
475
- comments: {embedded: 'always'}
514
+ author: {embedded: 'always'},
515
+ comments: {serialize: 'ids'}
476
516
  }
477
517
  })
478
518
  ```
479
519
 
480
- Currently only `{embedded: 'always'}` records are supported.
520
+ The `attrs` option for a resource `{embedded: 'always'}` is shorthand for:
521
+
522
+ ```js
523
+ {serialize: 'records', deserialize: 'records'}
524
+ ```
525
+
526
+ ### Configuring Attrs
527
+
528
+ A resource's `attrs` option may be set to use `ids`, `records` or `no` for the
529
+ `serialize` and `deserialize` settings.
530
+
531
+ The `attrs` property can be set on the ApplicationSerializer or a per-type
532
+ serializer.
533
+
534
+ In the case where embedded JSON is expected while extracting a payoad (reading)
535
+ the setting is `deserialize: 'records'`, there is no need to use `ids` when
536
+ extracting as that is the default behavior without this mixin if you are using
537
+ the vanilla ActiveModelAdapter. Likewise, to embed JSON in the payload while
538
+ serializing `serialize: 'records'` is the setting to use. There is an option of
539
+ not embedding JSON in the serialized payload by using `serialize: 'ids'`. If you
540
+ do not want the relationship sent at all, you can use `serialize: 'no'`.
541
+
542
+
543
+ ### ActiveModelSerializer defaults
544
+ If you do not overwrite `attrs` for a specific relationship, the `ActiveModelSerializer`
545
+ will behave in the following way:
546
+
547
+ BelongsTo: `{serialize:'id', deserialize:'id'}`
548
+ HasMany: `{serialize:no, deserialize:'ids'}`
549
+
550
+ ### Model Relationships
551
+
552
+ Embedded records must have a model defined to be extracted and serialized.
553
+
554
+ To successfully extract and serialize embedded records the model relationships
555
+ must be setup correcty See the
556
+ [defining relationships](/guides/models/defining-models/#toc_defining-relationships)
557
+ section of the **Defining Models** guide page.
558
+
559
+ Records without an `id` property are not considered embedded records, model
560
+ instances must have an `id` property to be used with Ember Data.
561
+
562
+ ### Example JSON payloads, Models and Serializers
563
+
564
+ **When customizing a serializer it is imporant to grok what the cusomizations
565
+ are, please read the docs for the methods this mixin provides, in case you need
566
+ to modify to fit your specific needs.**
567
+
568
+ For example review the docs for each method of this mixin:
569
+
570
+ * [extractArray](/api/data/classes/DS.EmbeddedRecordsMixin.html#method_extractArray)
571
+ * [extractSingle](/api/data/classes/DS.EmbeddedRecordsMixin.html#method_extractSingle)
572
+ * [serializeBelongsTo](/api/data/classes/DS.EmbeddedRecordsMixin.html#method_serializeBelongsTo)
573
+ * [serializeHasMany](/api/data/classes/DS.EmbeddedRecordsMixin.html#method_serializeHasMany)
481
574
 
482
575
  @class EmbeddedRecordsMixin
483
576
  @namespace DS
@@ -485,102 +578,457 @@ define("activemodel-adapter/lib/system/embedded_records_mixin",
485
578
  var EmbeddedRecordsMixin = Ember.Mixin.create({
486
579
 
487
580
  /**
488
- Serialize has-may relationship when it is configured as embedded objects.
581
+ Serialize `belongsTo` relationship when it is configured as an embedded object.
582
+
583
+ This example of an author model belongs to a post model:
584
+
585
+ ```js
586
+ Post = DS.Model.extend({
587
+ title: DS.attr('string'),
588
+ body: DS.attr('string'),
589
+ author: DS.belongsTo('author')
590
+ });
591
+
592
+ Author = DS.Model.extend({
593
+ name: DS.attr('string'),
594
+ post: DS.belongsTo('post')
595
+ });
596
+ ```
597
+
598
+ Use a custom (type) serializer for the post model to configure embedded author
599
+
600
+ ```js
601
+ App.PostSerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
602
+ attrs: {
603
+ author: {embedded: 'always'}
604
+ }
605
+ })
606
+ ```
607
+
608
+ A payload with an attribute configured for embedded records can serialize
609
+ the records together under the root attribute's payload:
610
+
611
+ ```js
612
+ {
613
+ "post": {
614
+ "id": "1"
615
+ "title": "Rails is omakase",
616
+ "author": {
617
+ "id": "2"
618
+ "name": "dhh"
619
+ }
620
+ }
621
+ }
622
+ ```
623
+
624
+ @method serializeBelongsTo
625
+ @param {DS.Model} record
626
+ @param {Object} json
627
+ @param {Object} relationship
628
+ */
629
+ serializeBelongsTo: function(record, json, relationship) {
630
+ var attr = relationship.key;
631
+ var attrs = this.get('attrs');
632
+ if (noSerializeOptionSpecified(attrs, attr)) {
633
+ this._super(record, json, relationship);
634
+ return;
635
+ }
636
+ var includeIds = hasSerializeIdsOption(attrs, attr);
637
+ var includeRecords = hasSerializeRecordsOption(attrs, attr);
638
+ var embeddedRecord = record.get(attr);
639
+ if (includeIds) {
640
+ key = this.keyForRelationship(attr, relationship.kind);
641
+ if (!embeddedRecord) {
642
+ json[key] = null;
643
+ } else {
644
+ json[key] = get(embeddedRecord, 'id');
645
+ }
646
+ } else if (includeRecords) {
647
+ var key = this.keyForRelationship(attr);
648
+ if (!embeddedRecord) {
649
+ json[key] = null;
650
+ } else {
651
+ json[key] = embeddedRecord.serialize({includeId: true});
652
+ this.removeEmbeddedForeignKey(record, embeddedRecord, relationship, json[key]);
653
+ }
654
+ }
655
+ },
656
+
657
+ /**
658
+ Serialize `hasMany` relationship when it is configured as embedded objects.
659
+
660
+ This example of a post model has many comments:
661
+
662
+ ```js
663
+ Post = DS.Model.extend({
664
+ title: DS.attr('string'),
665
+ body: DS.attr('string'),
666
+ comments: DS.hasMany('comment')
667
+ });
668
+
669
+ Comment = DS.Model.extend({
670
+ body: DS.attr('string'),
671
+ post: DS.belongsTo('post')
672
+ });
673
+ ```
674
+
675
+ Use a custom (type) serializer for the post model to configure embedded comments
676
+
677
+ ```js
678
+ App.PostSerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
679
+ attrs: {
680
+ comments: {embedded: 'always'}
681
+ }
682
+ })
683
+ ```
684
+
685
+ A payload with an attribute configured for embedded records can serialize
686
+ the records together under the root attribute's payload:
687
+
688
+ ```js
689
+ {
690
+ "post": {
691
+ "id": "1"
692
+ "title": "Rails is omakase",
693
+ "body": "I want this for my ORM, I want that for my template language..."
694
+ "comments": [{
695
+ "id": "1",
696
+ "body": "Rails is unagi"
697
+ }, {
698
+ "id": "2",
699
+ "body": "Omakase O_o"
700
+ }]
701
+ }
702
+ }
703
+ ```
704
+
705
+ The attrs options object can use more specific instruction for extracting and
706
+ serializing. When serializing, an option to embed `ids` or `records` can be set.
707
+ When extracting the only option is `records`.
708
+
709
+ So `{embedded: 'always'}` is shorthand for:
710
+ `{serialize: 'records', deserialize: 'records'}`
711
+
712
+ To embed the `ids` for a related object (using a hasMany relationship):
713
+
714
+ ```js
715
+ App.PostSerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
716
+ attrs: {
717
+ comments: {serialize: 'ids', deserialize: 'records'}
718
+ }
719
+ })
720
+ ```
721
+
722
+ ```js
723
+ {
724
+ "post": {
725
+ "id": "1"
726
+ "title": "Rails is omakase",
727
+ "body": "I want this for my ORM, I want that for my template language..."
728
+ "comments": ["1", "2"]
729
+ }
730
+ }
731
+ ```
489
732
 
490
733
  @method serializeHasMany
734
+ @param {DS.Model} record
735
+ @param {Object} json
736
+ @param {Object} relationship
491
737
  */
492
738
  serializeHasMany: function(record, json, relationship) {
493
- var key = relationship.key,
494
- attrs = get(this, 'attrs'),
495
- embed = attrs && attrs[key] && attrs[key].embedded === 'always';
739
+ var attr = relationship.key;
740
+ var attrs = this.get('attrs');
741
+ if (noSerializeOptionSpecified(attrs, attr)) {
742
+ this._super(record, json, relationship);
743
+ return;
744
+ }
745
+ var includeIds = hasSerializeIdsOption(attrs, attr);
746
+ var includeRecords = hasSerializeRecordsOption(attrs, attr);
747
+ var key;
748
+ if (includeIds) {
749
+ key = this.keyForRelationship(attr, relationship.kind);
750
+ json[key] = get(record, attr).mapBy('id');
751
+ } else if (includeRecords) {
752
+ key = this.keyForAttribute(attr);
753
+ json[key] = get(record, attr).map(function(embeddedRecord) {
754
+ var serializedEmbeddedRecord = embeddedRecord.serialize({includeId: true});
755
+ this.removeEmbeddedForeignKey(record, embeddedRecord, relationship, serializedEmbeddedRecord);
756
+ return serializedEmbeddedRecord;
757
+ }, this);
758
+ }
759
+ },
496
760
 
497
- if (embed) {
498
- json[this.keyForAttribute(key)] = get(record, key).map(function(relation) {
499
- var data = relation.serialize(),
500
- primaryKey = get(this, 'primaryKey');
761
+ /**
762
+ When serializing an embedded record, modify the property (in the json payload)
763
+ that refers to the parent record (foreign key for relationship).
501
764
 
502
- data[primaryKey] = get(relation, primaryKey);
765
+ Serializing a `belongsTo` relationship removes the property that refers to the
766
+ parent record
503
767
 
504
- return data;
505
- }, this);
768
+ Serializing a `hasMany` relationship does not remove the property that refers to
769
+ the parent record.
770
+
771
+ @method removeEmbeddedForeignKey
772
+ @param {DS.Model} record
773
+ @param {DS.Model} embeddedRecord
774
+ @param {Object} relationship
775
+ @param {Object} json
776
+ */
777
+ removeEmbeddedForeignKey: function (record, embeddedRecord, relationship, json) {
778
+ if (relationship.kind === 'hasMany') {
779
+ return;
780
+ } else if (relationship.kind === 'belongsTo') {
781
+ var parentRecord = record.constructor.inverseFor(relationship.key);
782
+ if (parentRecord) {
783
+ var name = parentRecord.name;
784
+ var embeddedSerializer = this.store.serializerFor(embeddedRecord.constructor);
785
+ var parentKey = embeddedSerializer.keyForRelationship(name, parentRecord.kind);
786
+ if (parentKey) {
787
+ delete json[parentKey];
788
+ }
789
+ }
506
790
  }
507
791
  },
508
792
 
509
793
  /**
510
- Extract embedded objects out of the payload for a single object
511
- and add them as sideloaded objects instead.
794
+ Extract an embedded object from the payload for a single object
795
+ and add the object in the compound document (side-loaded) format instead.
796
+
797
+ A payload with an attribute configured for embedded records needs to be extracted:
798
+
799
+ ```js
800
+ {
801
+ "post": {
802
+ "id": 1
803
+ "title": "Rails is omakase",
804
+ "author": {
805
+ "id": 2
806
+ "name": "dhh"
807
+ }
808
+ "comments": []
809
+ }
810
+ }
811
+ ```
812
+
813
+ Ember Data is expecting a payload with a compound document (side-loaded) like:
814
+
815
+ ```js
816
+ {
817
+ "post": {
818
+ "id": "1"
819
+ "title": "Rails is omakase",
820
+ "author": "2"
821
+ "comments": []
822
+ },
823
+ "authors": [{
824
+ "id": "2"
825
+ "post": "1"
826
+ "name": "dhh"
827
+ }]
828
+ "comments": []
829
+ }
830
+ ```
831
+
832
+ The payload's `author` attribute represents an object with a `belongsTo` relationship.
833
+ The `post` attribute under `author` is the foreign key with the id for the post
512
834
 
513
835
  @method extractSingle
836
+ @param {DS.Store} store
837
+ @param {subclass of DS.Model} primaryType
838
+ @param {Object} payload
839
+ @param {String} recordId
840
+ @return Object the primary response to the original request
514
841
  */
515
- extractSingle: function(store, primaryType, payload, recordId, requestType) {
842
+ extractSingle: function(store, primaryType, payload, recordId) {
516
843
  var root = this.keyForAttribute(primaryType.typeKey),
517
844
  partial = payload[root];
518
845
 
519
- updatePayloadWithEmbedded(store, this, primaryType, partial, payload);
846
+ updatePayloadWithEmbedded(this, store, primaryType, payload, partial);
520
847
 
521
- return this._super(store, primaryType, payload, recordId, requestType);
848
+ return this._super(store, primaryType, payload, recordId);
522
849
  },
523
850
 
524
851
  /**
525
- Extract embedded objects out of a standard payload
526
- and add them as sideloaded objects instead.
852
+ Extract embedded objects in an array when an attr is configured for embedded,
853
+ and add them as side-loaded objects instead.
854
+
855
+ A payload with an attr configured for embedded records needs to be extracted:
856
+
857
+ ```js
858
+ {
859
+ "post": {
860
+ "id": "1"
861
+ "title": "Rails is omakase",
862
+ "comments": [{
863
+ "id": "1",
864
+ "body": "Rails is unagi"
865
+ }, {
866
+ "id": "2",
867
+ "body": "Omakase O_o"
868
+ }]
869
+ }
870
+ }
871
+ ```
872
+
873
+ Ember Data is expecting a payload with compound document (side-loaded) like:
874
+
875
+ ```js
876
+ {
877
+ "post": {
878
+ "id": "1"
879
+ "title": "Rails is omakase",
880
+ "comments": ["1", "2"]
881
+ },
882
+ "comments": [{
883
+ "id": "1",
884
+ "body": "Rails is unagi"
885
+ }, {
886
+ "id": "2",
887
+ "body": "Omakase O_o"
888
+ }]
889
+ }
890
+ ```
891
+
892
+ The payload's `comments` attribute represents records in a `hasMany` relationship
527
893
 
528
894
  @method extractArray
895
+ @param {DS.Store} store
896
+ @param {subclass of DS.Model} primaryType
897
+ @param {Object} payload
898
+ @return {Array<Object>} The primary array that was returned in response
899
+ to the original query.
529
900
  */
530
- extractArray: function(store, type, payload) {
531
- var root = this.keyForAttribute(type.typeKey),
901
+ extractArray: function(store, primaryType, payload) {
902
+ var root = this.keyForAttribute(primaryType.typeKey),
532
903
  partials = payload[pluralize(root)];
533
904
 
534
905
  forEach(partials, function(partial) {
535
- updatePayloadWithEmbedded(store, this, type, partial, payload);
906
+ updatePayloadWithEmbedded(this, store, primaryType, payload, partial);
536
907
  }, this);
537
908
 
538
- return this._super(store, type, payload);
909
+ return this._super(store, primaryType, payload);
539
910
  }
540
911
  });
541
912
 
542
- function updatePayloadWithEmbedded(store, serializer, type, partial, payload) {
913
+ // checks config for attrs option to embedded (always) - serialize and deserialize
914
+ function hasEmbeddedAlwaysOption(attrs, attr) {
915
+ var option = attrsOption(attrs, attr);
916
+ return option && option.embedded === 'always';
917
+ }
918
+
919
+ // checks config for attrs option to serialize ids
920
+ function hasSerializeRecordsOption(attrs, attr) {
921
+ var alwaysEmbed = hasEmbeddedAlwaysOption(attrs, attr);
922
+ var option = attrsOption(attrs, attr);
923
+ return alwaysEmbed || (option && (option.serialize === 'records'));
924
+ }
925
+
926
+ // checks config for attrs option to serialize records
927
+ function hasSerializeIdsOption(attrs, attr) {
928
+ var option = attrsOption(attrs, attr);
929
+ return option && (option.serialize === 'ids' || option.serialize === 'id');
930
+ }
931
+
932
+ // checks config for attrs option to serialize records
933
+ function noSerializeOptionSpecified(attrs, attr) {
934
+ var option = attrsOption(attrs, attr);
935
+ var serializeRecords = hasSerializeRecordsOption(attrs, attr);
936
+ var serializeIds = hasSerializeIdsOption(attrs, attr);
937
+ return !(option && (option.serialize || option.embedded));
938
+ }
939
+
940
+ // checks config for attrs option to deserialize records
941
+ // a defined option object for a resource is treated the same as
942
+ // `deserialize: 'records'`
943
+ function hasDeserializeRecordsOption(attrs, attr) {
944
+ var alwaysEmbed = hasEmbeddedAlwaysOption(attrs, attr);
945
+ var option = attrsOption(attrs, attr);
946
+ var hasSerializingOption = option && (option.deserialize || option.serialize);
947
+ return alwaysEmbed || hasSerializingOption /* option.deserialize === 'records' */;
948
+ }
949
+
950
+ function attrsOption(attrs, attr) {
951
+ return attrs && (attrs[Ember.String.camelize(attr)] || attrs[attr]);
952
+ }
953
+
954
+ // chooses a relationship kind to branch which function is used to update payload
955
+ // does not change payload if attr is not embedded
956
+ function updatePayloadWithEmbedded(serializer, store, type, payload, partial) {
543
957
  var attrs = get(serializer, 'attrs');
544
958
 
545
959
  if (!attrs) {
546
960
  return;
547
961
  }
548
-
549
962
  type.eachRelationship(function(key, relationship) {
550
- var expandedKey, embeddedTypeKey, attribute, ids,
551
- config = attrs[key],
552
- serializer = store.serializerFor(relationship.type.typeKey),
553
- primaryKey = get(serializer, "primaryKey");
554
-
555
- if (relationship.kind !== "hasMany") {
556
- return;
963
+ if (hasDeserializeRecordsOption(attrs, key)) {
964
+ if (relationship.kind === "hasMany") {
965
+ updatePayloadWithEmbeddedHasMany(serializer, store, key, relationship, payload, partial);
966
+ }
967
+ if (relationship.kind === "belongsTo") {
968
+ updatePayloadWithEmbeddedBelongsTo(serializer, store, key, relationship, payload, partial);
969
+ }
557
970
  }
971
+ });
972
+ }
558
973
 
559
- if (config && (config.embedded === 'always' || config.embedded === 'load')) {
560
- // underscore forces the embedded records to be side loaded.
561
- // it is needed when main type === relationship.type
562
- embeddedTypeKey = '_' + Ember.String.pluralize(relationship.type.typeKey);
563
- expandedKey = this.keyForRelationship(key, relationship.kind);
564
- attribute = this.keyForAttribute(key);
565
- ids = [];
974
+ // handles embedding for `hasMany` relationship
975
+ function updatePayloadWithEmbeddedHasMany(serializer, store, primaryType, relationship, payload, partial) {
976
+ var embeddedSerializer = store.serializerFor(relationship.type.typeKey);
977
+ var primaryKey = get(serializer, 'primaryKey');
978
+ var attr = relationship.type.typeKey;
979
+ // underscore forces the embedded records to be side loaded.
980
+ // it is needed when main type === relationship.type
981
+ var embeddedTypeKey = '_' + serializer.typeForRoot(relationship.type.typeKey);
982
+ var expandedKey = serializer.keyForRelationship(primaryType, relationship.kind);
983
+ var attribute = serializer.keyForAttribute(primaryType);
984
+ var ids = [];
985
+
986
+ if (!partial[attribute]) {
987
+ return;
988
+ }
566
989
 
567
- if (!partial[attribute]) {
568
- return;
569
- }
990
+ payload[embeddedTypeKey] = payload[embeddedTypeKey] || [];
570
991
 
571
- payload[embeddedTypeKey] = payload[embeddedTypeKey] || [];
992
+ forEach(partial[attribute], function(data) {
993
+ var embeddedType = store.modelFor(attr);
994
+ updatePayloadWithEmbedded(embeddedSerializer, store, embeddedType, payload, data);
995
+ ids.push(data[primaryKey]);
996
+ payload[embeddedTypeKey].push(data);
997
+ });
572
998
 
573
- forEach(partial[attribute], function(data) {
574
- var embeddedType = store.modelFor(relationship.type.typeKey);
575
- updatePayloadWithEmbedded(store, serializer, embeddedType, data, payload);
576
- ids.push(data[primaryKey]);
577
- payload[embeddedTypeKey].push(data);
578
- });
999
+ partial[expandedKey] = ids;
1000
+ delete partial[attribute];
1001
+ }
579
1002
 
580
- partial[expandedKey] = ids;
581
- delete partial[attribute];
582
- }
583
- }, serializer);
1003
+ // handles embedding for `belongsTo` relationship
1004
+ function updatePayloadWithEmbeddedBelongsTo(serializer, store, primaryType, relationship, payload, partial) {
1005
+ var attrs = serializer.get('attrs');
1006
+
1007
+ if (!attrs ||
1008
+ !(hasDeserializeRecordsOption(attrs, Ember.String.camelize(primaryType)) ||
1009
+ hasDeserializeRecordsOption(attrs, primaryType))) {
1010
+ return;
1011
+ }
1012
+ var attr = relationship.type.typeKey;
1013
+ var _serializer = store.serializerFor(relationship.type.typeKey);
1014
+ var primaryKey = get(_serializer, 'primaryKey');
1015
+ var embeddedTypeKey = Ember.String.pluralize(attr); // TODO don't use pluralize
1016
+ var expandedKey = _serializer.keyForRelationship(primaryType, relationship.kind);
1017
+ var attribute = _serializer.keyForAttribute(primaryType);
1018
+
1019
+ if (!partial[attribute]) {
1020
+ return;
1021
+ }
1022
+ payload[embeddedTypeKey] = payload[embeddedTypeKey] || [];
1023
+ var embeddedType = store.modelFor(relationship.type.typeKey);
1024
+ // Recursive call for nested record
1025
+ updatePayloadWithEmbedded(_serializer, store, embeddedType, payload, partial[attribute]);
1026
+ partial[expandedKey] = partial[attribute].id;
1027
+ // Need to move an embedded `belongsTo` object into a pluralized collection
1028
+ payload[embeddedTypeKey].push(partial[attribute]);
1029
+ // Need a reference to the parent so relationship works between both `belongsTo` records
1030
+ partial[attribute][relationship.parentType.typeKey + '_id'] = partial.id;
1031
+ delete partial[attribute];
584
1032
  }
585
1033
 
586
1034
  __exports__["default"] = EmbeddedRecordsMixin;
@@ -616,11 +1064,11 @@ define("ember-data/lib/adapters/fixture_adapter",
616
1064
 
617
1065
  /**
618
1066
  `DS.FixtureAdapter` is an adapter that loads records from memory.
619
- Its primarily used for development and testing. You can also use
1067
+ It's primarily used for development and testing. You can also use
620
1068
  `DS.FixtureAdapter` while working on the API but are not ready to
621
1069
  integrate yet. It is a fully functioning adapter. All CRUD methods
622
1070
  are implemented. You can also implement query logic that a remote
623
- system would do. Its possible to do develop your entire application
1071
+ system would do. It's possible to develop your entire application
624
1072
  with `DS.FixtureAdapter`.
625
1073
 
626
1074
  For information on how to use the `FixtureAdapter` in your
@@ -1034,11 +1482,13 @@ define("ember-data/lib/adapters/rest_adapter",
1034
1482
 
1035
1483
  ### Headers customization
1036
1484
 
1037
- Some APIs require HTTP headers, e.g. to provide an API key. An array of
1038
- headers can be added to the adapter which are passed with every request:
1485
+ Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary
1486
+ headers can be set as key/value pairs on the `RESTAdapter`'s `headers`
1487
+ object and Ember Data will send them along with each ajax request.
1488
+
1039
1489
 
1040
1490
  ```js
1041
- DS.RESTAdapter.reopen({
1491
+ App.ApplicationAdapter = DS.RESTAdapter.extend({
1042
1492
  headers: {
1043
1493
  "API_KEY": "secret key",
1044
1494
  "ANOTHER_HEADER": "Some header value"
@@ -1046,6 +1496,39 @@ define("ember-data/lib/adapters/rest_adapter",
1046
1496
  });
1047
1497
  ```
1048
1498
 
1499
+ `headers` can also be used as a computed property to support dynamic
1500
+ headers. In the example below, the `session` object has been
1501
+ injected into an adapter by Ember's container.
1502
+
1503
+ ```js
1504
+ App.ApplicationAdapter = DS.RESTAdapter.extend({
1505
+ headers: function() {
1506
+ return {
1507
+ "API_KEY": this.get("session.authToken"),
1508
+ "ANOTHER_HEADER": "Some header value"
1509
+ };
1510
+ }.property("session.authToken")
1511
+ });
1512
+ ```
1513
+
1514
+ In some cases, your dynamic headers may require data from some
1515
+ object outside of Ember's observer system (for example
1516
+ `document.cookie`). You can use the
1517
+ [volatile](/api/classes/Ember.ComputedProperty.html#method_volatile)
1518
+ function to set the property into a non-chached mode causing the headers to
1519
+ be recomputed with every request.
1520
+
1521
+ ```js
1522
+ App.ApplicationAdapter = DS.RESTAdapter.extend({
1523
+ headers: function() {
1524
+ return {
1525
+ "API_KEY": Ember.get(document.cookie.match(/apiKey\=([^;]*)/), "1"),
1526
+ "ANOTHER_HEADER": "Some header value"
1527
+ };
1528
+ }.property().volatile();
1529
+ });
1530
+ ```
1531
+
1049
1532
  @class RESTAdapter
1050
1533
  @constructor
1051
1534
  @namespace DS
@@ -1085,11 +1568,14 @@ define("ember-data/lib/adapters/rest_adapter",
1085
1568
  */
1086
1569
 
1087
1570
  /**
1088
- Some APIs require HTTP headers, e.g. to provide an API key. An array of
1089
- headers can be added to the adapter which are passed with every request:
1571
+ Some APIs require HTTP headers, e.g. to provide an API
1572
+ key. Arbitrary headers can be set as key/value pairs on the
1573
+ `RESTAdapter`'s `headers` object and Ember Data will send them
1574
+ along with each ajax request. For dynamic headers see [headers
1575
+ customization](/api/data/classes/DS.RESTAdapter.html#toc_headers-customization).
1090
1576
 
1091
1577
  ```javascript
1092
- DS.RESTAdapter.reopen({
1578
+ App.ApplicationAdapter = DS.RESTAdapter.extend({
1093
1579
  headers: {
1094
1580
  "API_KEY": "secret key",
1095
1581
  "ANOTHER_HEADER": "Some header value"
@@ -1114,7 +1600,7 @@ define("ember-data/lib/adapters/rest_adapter",
1114
1600
  @param {DS.Store} store
1115
1601
  @param {subclass of DS.Model} type
1116
1602
  @param {String} id
1117
- @returns {Promise} promise
1603
+ @return {Promise} promise
1118
1604
  */
1119
1605
  find: function(store, type, id) {
1120
1606
  return this.ajax(this.buildURL(type.typeKey, id), 'GET');
@@ -1132,7 +1618,7 @@ define("ember-data/lib/adapters/rest_adapter",
1132
1618
  @param {DS.Store} store
1133
1619
  @param {subclass of DS.Model} type
1134
1620
  @param {String} sinceToken
1135
- @returns {Promise} promise
1621
+ @return {Promise} promise
1136
1622
  */
1137
1623
  findAll: function(store, type, sinceToken) {
1138
1624
  var query;
@@ -1159,7 +1645,7 @@ define("ember-data/lib/adapters/rest_adapter",
1159
1645
  @param {DS.Store} store
1160
1646
  @param {subclass of DS.Model} type
1161
1647
  @param {Object} query
1162
- @returns {Promise} promise
1648
+ @return {Promise} promise
1163
1649
  */
1164
1650
  findQuery: function(store, type, query) {
1165
1651
  return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query });
@@ -1197,7 +1683,7 @@ define("ember-data/lib/adapters/rest_adapter",
1197
1683
  @param {DS.Store} store
1198
1684
  @param {subclass of DS.Model} type
1199
1685
  @param {Array} ids
1200
- @returns {Promise} promise
1686
+ @return {Promise} promise
1201
1687
  */
1202
1688
  findMany: function(store, type, ids) {
1203
1689
  return this.ajax(this.buildURL(type.typeKey), 'GET', { data: { ids: ids } });
@@ -1230,7 +1716,7 @@ define("ember-data/lib/adapters/rest_adapter",
1230
1716
  @param {DS.Store} store
1231
1717
  @param {DS.Model} record
1232
1718
  @param {String} url
1233
- @returns {Promise} promise
1719
+ @return {Promise} promise
1234
1720
  */
1235
1721
  findHasMany: function(store, record, url) {
1236
1722
  var host = get(this, 'host'),
@@ -1269,7 +1755,7 @@ define("ember-data/lib/adapters/rest_adapter",
1269
1755
  @param {DS.Store} store
1270
1756
  @param {DS.Model} record
1271
1757
  @param {String} url
1272
- @returns {Promise} promise
1758
+ @return {Promise} promise
1273
1759
  */
1274
1760
  findBelongsTo: function(store, record, url) {
1275
1761
  var id = get(record, 'id'),
@@ -1292,7 +1778,7 @@ define("ember-data/lib/adapters/rest_adapter",
1292
1778
  @param {DS.Store} store
1293
1779
  @param {subclass of DS.Model} type
1294
1780
  @param {DS.Model} record
1295
- @returns {Promise} promise
1781
+ @return {Promise} promise
1296
1782
  */
1297
1783
  createRecord: function(store, type, record) {
1298
1784
  var data = {};
@@ -1317,7 +1803,7 @@ define("ember-data/lib/adapters/rest_adapter",
1317
1803
  @param {DS.Store} store
1318
1804
  @param {subclass of DS.Model} type
1319
1805
  @param {DS.Model} record
1320
- @returns {Promise} promise
1806
+ @return {Promise} promise
1321
1807
  */
1322
1808
  updateRecord: function(store, type, record) {
1323
1809
  var data = {};
@@ -1339,7 +1825,7 @@ define("ember-data/lib/adapters/rest_adapter",
1339
1825
  @param {DS.Store} store
1340
1826
  @param {subclass of DS.Model} type
1341
1827
  @param {DS.Model} record
1342
- @returns {Promise} promise
1828
+ @return {Promise} promise
1343
1829
  */
1344
1830
  deleteRecord: function(store, type, record) {
1345
1831
  var id = get(record, 'id');
@@ -1360,7 +1846,7 @@ define("ember-data/lib/adapters/rest_adapter",
1360
1846
  @method buildURL
1361
1847
  @param {String} type
1362
1848
  @param {String} id
1363
- @returns {String} url
1849
+ @return {String} url
1364
1850
  */
1365
1851
  buildURL: function(type, id) {
1366
1852
  var url = [],
@@ -1425,17 +1911,17 @@ define("ember-data/lib/adapters/rest_adapter",
1425
1911
  endpoint of "/line_items/".
1426
1912
 
1427
1913
  ```js
1428
- DS.RESTAdapter.reopen({
1914
+ App.ApplicationAdapter = DS.RESTAdapter.extend({
1429
1915
  pathForType: function(type) {
1430
1916
  var decamelized = Ember.String.decamelize(type);
1431
1917
  return Ember.String.pluralize(decamelized);
1432
- };
1918
+ }
1433
1919
  });
1434
1920
  ```
1435
1921
 
1436
1922
  @method pathForType
1437
1923
  @param {String} type
1438
- @returns {String} path
1924
+ @return {String} path
1439
1925
  **/
1440
1926
  pathForType: function(type) {
1441
1927
  var camelized = Ember.String.camelize(type);
@@ -1477,7 +1963,7 @@ define("ember-data/lib/adapters/rest_adapter",
1477
1963
  @return {Object} jqXHR
1478
1964
  */
1479
1965
  ajaxError: function(jqXHR) {
1480
- if (jqXHR) {
1966
+ if (jqXHR && typeof jqXHR === 'object') {
1481
1967
  jqXHR.then = null;
1482
1968
  }
1483
1969
 
@@ -1546,8 +2032,8 @@ define("ember-data/lib/adapters/rest_adapter",
1546
2032
  hash.data = JSON.stringify(hash.data);
1547
2033
  }
1548
2034
 
1549
- if (this.headers !== undefined) {
1550
- var headers = this.headers;
2035
+ var headers = get(this, 'headers');
2036
+ if (headers !== undefined) {
1551
2037
  hash.beforeSend = function (xhr) {
1552
2038
  forEach.call(Ember.keys(headers), function(key) {
1553
2039
  xhr.setRequestHeader(key, headers[key]);
@@ -1582,17 +2068,13 @@ define("ember-data/lib/core",
1582
2068
  /**
1583
2069
  @property VERSION
1584
2070
  @type String
1585
- @default '1.0.0-beta.7+canary.f482da04'
2071
+ @default '1.0.0-beta.8.2a68c63a'
1586
2072
  @static
1587
2073
  */
1588
2074
  DS = Ember.Namespace.create({
1589
- VERSION: '1.0.0-beta.7+canary.f482da04'
2075
+ VERSION: '1.0.0-beta.8.2a68c63a'
1590
2076
  });
1591
2077
 
1592
- if ('undefined' !== typeof window) {
1593
- window.DS = DS;
1594
- }
1595
-
1596
2078
  if (Ember.libraries) {
1597
2079
  Ember.libraries.registerCoreLibrary('Ember Data', DS.VERSION);
1598
2080
  }
@@ -1600,6 +2082,90 @@ define("ember-data/lib/core",
1600
2082
 
1601
2083
  __exports__["default"] = DS;
1602
2084
  });
2085
+ define("ember-data/lib/ember-initializer",
2086
+ ["./setup-container"],
2087
+ function(__dependency1__) {
2088
+ "use strict";
2089
+ var setupContainer = __dependency1__["default"];
2090
+
2091
+ var K = Ember.K;
2092
+
2093
+ /**
2094
+ @module ember-data
2095
+ */
2096
+
2097
+ /**
2098
+
2099
+ This code initializes Ember-Data onto an Ember application.
2100
+
2101
+ If an Ember.js developer defines a subclass of DS.Store on their application,
2102
+ as `App.ApplicationStore` (or via a module system that resolves to `store:application`)
2103
+ this code will automatically instantiate it and make it available on the
2104
+ router.
2105
+
2106
+ Additionally, after an application's controllers have been injected, they will
2107
+ each have the store made available to them.
2108
+
2109
+ For example, imagine an Ember.js application with the following classes:
2110
+
2111
+ App.ApplicationStore = DS.Store.extend({
2112
+ adapter: 'custom'
2113
+ });
2114
+
2115
+ App.PostsController = Ember.ArrayController.extend({
2116
+ // ...
2117
+ });
2118
+
2119
+ When the application is initialized, `App.ApplicationStore` will automatically be
2120
+ instantiated, and the instance of `App.PostsController` will have its `store`
2121
+ property set to that instance.
2122
+
2123
+ Note that this code will only be run if the `ember-application` package is
2124
+ loaded. If Ember Data is being used in an environment other than a
2125
+ typical application (e.g., node.js where only `ember-runtime` is available),
2126
+ this code will be ignored.
2127
+ */
2128
+
2129
+ Ember.onLoad('Ember.Application', function(Application) {
2130
+
2131
+ Application.initializer({
2132
+ name: "ember-data",
2133
+ initialize: setupContainer
2134
+ });
2135
+
2136
+ // Deprecated initializers to satisfy old code that depended on them
2137
+
2138
+ Application.initializer({
2139
+ name: "store",
2140
+ after: "ember-data",
2141
+ initialize: K
2142
+ });
2143
+
2144
+ Application.initializer({
2145
+ name: "activeModelAdapter",
2146
+ before: "store",
2147
+ initialize: K
2148
+ });
2149
+
2150
+ Application.initializer({
2151
+ name: "transforms",
2152
+ before: "store",
2153
+ initialize: K
2154
+ });
2155
+
2156
+ Application.initializer({
2157
+ name: "data-adapter",
2158
+ before: "store",
2159
+ initialize: K
2160
+ });
2161
+
2162
+ Application.initializer({
2163
+ name: "injectStore",
2164
+ before: "store",
2165
+ initialize: K
2166
+ });
2167
+ });
2168
+ });
1603
2169
  define("ember-data/lib/ext/date",
1604
2170
  [],
1605
2171
  function() {
@@ -1665,122 +2231,108 @@ define("ember-data/lib/ext/date",
1665
2231
  Date.parse = Ember.Date.parse;
1666
2232
  }
1667
2233
  });
1668
- define("ember-data/lib/initializers",
1669
- ["./system/store","./serializers","./adapters","./system/debug/debug_adapter","./system/container_proxy","./transforms"],
1670
- function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {
2234
+ define("ember-data/lib/initializers/data_adapter",
2235
+ ["../system/debug/debug_adapter","exports"],
2236
+ function(__dependency1__, __exports__) {
1671
2237
  "use strict";
1672
- var Store = __dependency1__["default"];
1673
- var JSONSerializer = __dependency2__.JSONSerializer;
1674
- var RESTSerializer = __dependency2__.RESTSerializer;
1675
- var RESTAdapter = __dependency3__.RESTAdapter;
1676
- var DebugAdapter = __dependency4__["default"];
1677
- var ContainerProxy = __dependency5__["default"];
1678
- var BooleanTransform = __dependency6__.BooleanTransform;
1679
- var DateTransform = __dependency6__.DateTransform;
1680
- var StringTransform = __dependency6__.StringTransform;
1681
- var NumberTransform = __dependency6__.NumberTransform;
2238
+ var DebugAdapter = __dependency1__["default"];
1682
2239
 
1683
2240
  /**
1684
- @module ember-data
1685
- */
1686
-
1687
- var set = Ember.set;
1688
-
1689
- /*
1690
- This code registers an injection for Ember.Application.
1691
-
1692
- If an Ember.js developer defines a subclass of DS.Store on their application,
1693
- this code will automatically instantiate it and make it available on the
1694
- router.
1695
-
1696
- Additionally, after an application's controllers have been injected, they will
1697
- each have the store made available to them.
1698
-
1699
- For example, imagine an Ember.js application with the following classes:
1700
-
1701
- App.Store = DS.Store.extend({
1702
- adapter: 'custom'
1703
- });
2241
+ Configures a container with injections on Ember applications
2242
+ for the Ember-Data store. Accepts an optional namespace argument.
1704
2243
 
1705
- App.PostsController = Ember.ArrayController.extend({
1706
- // ...
1707
- });
1708
-
1709
- When the application is initialized, `App.Store` will automatically be
1710
- instantiated, and the instance of `App.PostsController` will have its `store`
1711
- property set to that instance.
1712
-
1713
- Note that this code will only be run if the `ember-application` package is
1714
- loaded. If Ember Data is being used in an environment other than a
1715
- typical application (e.g., node.js where only `ember-runtime` is available),
1716
- this code will be ignored.
2244
+ @method initializeStoreInjections
2245
+ @param {Ember.Container} container
1717
2246
  */
2247
+ __exports__["default"] = function initializeDebugAdapter(container){
2248
+ container.register('data-adapter:main', DebugAdapter);
2249
+ };
2250
+ });
2251
+ define("ember-data/lib/initializers/store",
2252
+ ["../serializers","../adapters","../system/container_proxy","../system/store","exports"],
2253
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
2254
+ "use strict";
2255
+ var JSONSerializer = __dependency1__.JSONSerializer;
2256
+ var RESTSerializer = __dependency1__.RESTSerializer;
2257
+ var RESTAdapter = __dependency2__.RESTAdapter;
2258
+ var ContainerProxy = __dependency3__["default"];
2259
+ var Store = __dependency4__["default"];
1718
2260
 
1719
- Ember.onLoad('Ember.Application', function(Application) {
1720
- Application.initializer({
1721
- name: "store",
1722
-
1723
- initialize: function(container, application) {
1724
- application.register('store:main', application.Store || Store);
1725
-
1726
- // allow older names to be looked up
1727
-
1728
- var proxy = new ContainerProxy(container);
1729
- proxy.registerDeprecations([
1730
- {deprecated: 'serializer:_default', valid: 'serializer:-default'},
1731
- {deprecated: 'serializer:_rest', valid: 'serializer:-rest'},
1732
- {deprecated: 'adapter:_rest', valid: 'adapter:-rest'}
1733
- ]);
1734
-
1735
- // new go forward paths
1736
- application.register('serializer:-default', JSONSerializer);
1737
- application.register('serializer:-rest', RESTSerializer);
1738
- application.register('adapter:-rest', RESTAdapter);
2261
+ /**
2262
+ Configures a container for use with an Ember-Data
2263
+ store. Accepts an optional namespace argument.
1739
2264
 
1740
- // Eagerly generate the store so defaultStore is populated.
1741
- // TODO: Do this in a finisher hook
1742
- container.lookup('store:main');
1743
- }
1744
- });
2265
+ @method initializeStore
2266
+ @param {Ember.Container} container
2267
+ @param {Object} [application] an application namespace
2268
+ */
2269
+ __exports__["default"] = function initializeStore(container, application){
2270
+
2271
+ container.register('store:main', container.lookupFactory('store:application') || (application && application.Store) || Store);
1745
2272
 
1746
- Application.initializer({
1747
- name: "transforms",
1748
- before: "store",
2273
+ // allow older names to be looked up
1749
2274
 
1750
- initialize: function(container, application) {
1751
- application.register('transform:boolean', BooleanTransform);
1752
- application.register('transform:date', DateTransform);
1753
- application.register('transform:number', NumberTransform);
1754
- application.register('transform:string', StringTransform);
1755
- }
1756
- });
2275
+ var proxy = new ContainerProxy(container);
2276
+ proxy.registerDeprecations([
2277
+ {deprecated: 'serializer:_default', valid: 'serializer:-default'},
2278
+ {deprecated: 'serializer:_rest', valid: 'serializer:-rest'},
2279
+ {deprecated: 'adapter:_rest', valid: 'adapter:-rest'}
2280
+ ]);
1757
2281
 
1758
- Application.initializer({
1759
- name: "data-adapter",
1760
- before: "store",
2282
+ // new go forward paths
2283
+ container.register('serializer:-default', JSONSerializer);
2284
+ container.register('serializer:-rest', RESTSerializer);
2285
+ container.register('adapter:-rest', RESTAdapter);
1761
2286
 
1762
- initialize: function(container, application) {
1763
- application.register('data-adapter:main', DebugAdapter);
1764
- }
1765
- });
2287
+ // Eagerly generate the store so defaultStore is populated.
2288
+ // TODO: Do this in a finisher hook
2289
+ container.lookup('store:main');
2290
+ };
2291
+ });
2292
+ define("ember-data/lib/initializers/store_injections",
2293
+ ["exports"],
2294
+ function(__exports__) {
2295
+ "use strict";
2296
+ /**
2297
+ Configures a container with injections on Ember applications
2298
+ for the Ember-Data store. Accepts an optional namespace argument.
1766
2299
 
1767
- Application.initializer({
1768
- name: "injectStore",
1769
- before: "store",
2300
+ @method initializeStoreInjections
2301
+ @param {Ember.Container} container
2302
+ */
2303
+ __exports__["default"] = function initializeStoreInjections(container){
2304
+ container.injection('controller', 'store', 'store:main');
2305
+ container.injection('route', 'store', 'store:main');
2306
+ container.injection('serializer', 'store', 'store:main');
2307
+ container.injection('data-adapter', 'store', 'store:main');
2308
+ };
2309
+ });
2310
+ define("ember-data/lib/initializers/transforms",
2311
+ ["../transforms","exports"],
2312
+ function(__dependency1__, __exports__) {
2313
+ "use strict";
2314
+ var BooleanTransform = __dependency1__.BooleanTransform;
2315
+ var DateTransform = __dependency1__.DateTransform;
2316
+ var StringTransform = __dependency1__.StringTransform;
2317
+ var NumberTransform = __dependency1__.NumberTransform;
1770
2318
 
1771
- initialize: function(container, application) {
1772
- application.inject('controller', 'store', 'store:main');
1773
- application.inject('route', 'store', 'store:main');
1774
- application.inject('serializer', 'store', 'store:main');
1775
- application.inject('data-adapter', 'store', 'store:main');
1776
- }
1777
- });
2319
+ /**
2320
+ Configures a container for use with Ember-Data
2321
+ transforms.
1778
2322
 
1779
- });
2323
+ @method initializeTransforms
2324
+ @param {Ember.Container} container
2325
+ */
2326
+ __exports__["default"] = function initializeTransforms(container){
2327
+ container.register('transform:boolean', BooleanTransform);
2328
+ container.register('transform:date', DateTransform);
2329
+ container.register('transform:number', NumberTransform);
2330
+ container.register('transform:string', StringTransform);
2331
+ };
1780
2332
  });
1781
2333
  define("ember-data/lib/main",
1782
- ["./core","./ext/date","./system/store","./system/model","./system/changes","./system/adapter","./system/debug","./system/record_arrays","./system/record_array_manager","./adapters","./serializers/json_serializer","./serializers/rest_serializer","../../ember-inflector/lib/main","../../activemodel-adapter/lib/main","./transforms","./system/relationships","./initializers","./system/container_proxy","exports"],
1783
- function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __exports__) {
2334
+ ["./core","./ext/date","./system/store","./system/model","./system/changes","./system/adapter","./system/debug","./system/record_arrays","./system/record_array_manager","./adapters","./serializers/json_serializer","./serializers/rest_serializer","../../ember-inflector/lib/main","../../activemodel-adapter/lib/main","./transforms","./system/relationships","./ember-initializer","./setup-container","./system/container_proxy","exports"],
2335
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __exports__) {
1784
2336
  "use strict";
1785
2337
  /**
1786
2338
  Ember Data
@@ -1833,8 +2385,9 @@ define("ember-data/lib/main",
1833
2385
 
1834
2386
  var hasMany = __dependency16__.hasMany;
1835
2387
  var belongsTo = __dependency16__.belongsTo;
2388
+ var setupContainer = __dependency18__["default"];
1836
2389
 
1837
- var ContainerProxy = __dependency18__["default"];
2390
+ var ContainerProxy = __dependency19__["default"];
1838
2391
 
1839
2392
  DS.Store = Store;
1840
2393
  DS.PromiseArray = PromiseArray;
@@ -1886,6 +2439,10 @@ define("ember-data/lib/main",
1886
2439
 
1887
2440
  DS.ContainerProxy = ContainerProxy;
1888
2441
 
2442
+ DS._setupContainer = setupContainer;
2443
+
2444
+ Ember.lookup.DS = DS;
2445
+
1889
2446
  __exports__["default"] = DS;
1890
2447
  });
1891
2448
  define("ember-data/lib/serializers",
@@ -1899,10 +2456,12 @@ define("ember-data/lib/serializers",
1899
2456
  __exports__.RESTSerializer = RESTSerializer;
1900
2457
  });
1901
2458
  define("ember-data/lib/serializers/json_serializer",
1902
- ["exports"],
1903
- function(__exports__) {
2459
+ ["../system/changes","exports"],
2460
+ function(__dependency1__, __exports__) {
1904
2461
  "use strict";
1905
- var get = Ember.get, set = Ember.set, isNone = Ember.isNone;
2462
+ var RelationshipChange = __dependency1__.RelationshipChange;
2463
+ var get = Ember.get, set = Ember.set, isNone = Ember.isNone,
2464
+ map = Ember.ArrayPolyfills.map;
1906
2465
 
1907
2466
  /**
1908
2467
  In Ember Data a Serializer is used to serialize and deserialize
@@ -1942,6 +2501,35 @@ define("ember-data/lib/serializers/json_serializer",
1942
2501
  */
1943
2502
  primaryKey: 'id',
1944
2503
 
2504
+ /**
2505
+ The `attrs` object can be used to declare a simple mapping between
2506
+ property names on `DS.Model` records and payload keys in the
2507
+ serialized JSON object representing the record. An object with the
2508
+ propery `key` can also be used to designate the attribute's key on
2509
+ the response payload.
2510
+
2511
+ Example
2512
+
2513
+ ```javascript
2514
+ App.Person = DS.Model.extend({
2515
+ firstName: DS.attr('string'),
2516
+ lastName: DS.attr('string'),
2517
+ occupation: DS.attr('string'),
2518
+ admin: DS.attr('boolean')
2519
+ });
2520
+
2521
+ App.PersonSerializer = DS.JSONSerializer.extend({
2522
+ attrs: {
2523
+ admin: 'is_admin',
2524
+ occupation: {key: 'career'}
2525
+ }
2526
+ });
2527
+ ```
2528
+
2529
+ @property attrs
2530
+ @type {Object}
2531
+ */
2532
+
1945
2533
  /**
1946
2534
  Given a subclass of `DS.Model` and a JSON object this method will
1947
2535
  iterate through each attribute of the `DS.Model` and invoke the
@@ -2002,10 +2590,45 @@ define("ember-data/lib/serializers/json_serializer",
2002
2590
  normalize: function(type, hash) {
2003
2591
  if (!hash) { return hash; }
2004
2592
 
2593
+ this.normalizeId(hash);
2594
+ this.normalizeUsingDeclaredMapping(type, hash);
2005
2595
  this.applyTransforms(type, hash);
2006
2596
  return hash;
2007
2597
  },
2008
2598
 
2599
+ /**
2600
+ @method normalizeUsingDeclaredMapping
2601
+ @private
2602
+ */
2603
+ normalizeUsingDeclaredMapping: function(type, hash) {
2604
+ var attrs = get(this, 'attrs'), payloadKey, key;
2605
+
2606
+ if (attrs) {
2607
+ for (key in attrs) {
2608
+ payloadKey = attrs[key];
2609
+ if (payloadKey && payloadKey.key) {
2610
+ payloadKey = payloadKey.key;
2611
+ }
2612
+ if (typeof payloadKey === 'string') {
2613
+ hash[key] = hash[payloadKey];
2614
+ delete hash[payloadKey];
2615
+ }
2616
+ }
2617
+ }
2618
+ },
2619
+ /**
2620
+ @method normalizeId
2621
+ @private
2622
+ */
2623
+ normalizeId: function(hash) {
2624
+ var primaryKey = get(this, 'primaryKey');
2625
+
2626
+ if (primaryKey === 'id') { return; }
2627
+
2628
+ hash.id = hash[primaryKey];
2629
+ delete hash[primaryKey];
2630
+ },
2631
+
2009
2632
  // SERIALIZE
2010
2633
  /**
2011
2634
  Called when a record is saved in order to convert the
@@ -2180,7 +2803,7 @@ define("ember-data/lib/serializers/json_serializer",
2180
2803
  `serializeAttribute` can be used to customize how `DS.attr`
2181
2804
  properties are serialized
2182
2805
 
2183
- For example if you wanted to ensure all you attributes were always
2806
+ For example if you wanted to ensure all your attributes were always
2184
2807
  serialized as properties on an `attributes` object you could
2185
2808
  write:
2186
2809
 
@@ -2284,11 +2907,11 @@ define("ember-data/lib/serializers/json_serializer",
2284
2907
  */
2285
2908
  serializeHasMany: function(record, json, relationship) {
2286
2909
  var key = relationship.key;
2287
-
2288
- var relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship);
2910
+ var payloadKey = this.keyForRelationship ? this.keyForRelationship(key, "hasMany") : key;
2911
+ var relationshipType = RelationshipChange.determineRelationshipType(record.constructor, relationship);
2289
2912
 
2290
2913
  if (relationshipType === 'manyToNone' || relationshipType === 'manyToMany') {
2291
- json[key] = get(record, key).mapBy('id');
2914
+ json[payloadKey] = get(record, key).mapBy('id');
2292
2915
  // TODO support for polymorphic manyToNone and manyToMany relationships
2293
2916
  }
2294
2917
  },
@@ -2552,8 +3175,11 @@ define("ember-data/lib/serializers/json_serializer",
2552
3175
  @param {Object} payload
2553
3176
  @return {Array} array An array of deserialized objects
2554
3177
  */
2555
- extractArray: function(store, type, payload) {
2556
- return this.normalize(type, payload);
3178
+ extractArray: function(store, type, arrayPayload) {
3179
+ var serializer = this;
3180
+ return map.call(arrayPayload, function(singlePayload) {
3181
+ return serializer.normalize(type, singlePayload);
3182
+ });
2557
3183
  },
2558
3184
 
2559
3185
  /**
@@ -2645,8 +3271,8 @@ define("ember-data/lib/serializers/json_serializer",
2645
3271
  __exports__["default"] = JSONSerializer;
2646
3272
  });
2647
3273
  define("ember-data/lib/serializers/rest_serializer",
2648
- ["./json_serializer","exports"],
2649
- function(__dependency1__, __exports__) {
3274
+ ["./json_serializer","ember-inflector/lib/system/string","exports"],
3275
+ function(__dependency1__, __dependency2__, __exports__) {
2650
3276
  "use strict";
2651
3277
  /**
2652
3278
  @module ember-data
@@ -2657,6 +3283,9 @@ define("ember-data/lib/serializers/rest_serializer",
2657
3283
  var forEach = Ember.ArrayPolyfills.forEach;
2658
3284
  var map = Ember.ArrayPolyfills.map;
2659
3285
 
3286
+ var singularize = __dependency2__.singularize;
3287
+ var camelize = Ember.String.camelize;
3288
+
2660
3289
  function coerceId(id) {
2661
3290
  return id == null ? null : id+'';
2662
3291
  }
@@ -2813,7 +3442,7 @@ define("ember-data/lib/serializers/rest_serializer",
2813
3442
  @param {subclass of DS.Model} type
2814
3443
  @param {Object} hash
2815
3444
  @param {String} prop
2816
- @returns {Object}
3445
+ @return {Object}
2817
3446
  */
2818
3447
  normalize: function(type, hash, prop) {
2819
3448
  this.normalizeId(hash);
@@ -2826,7 +3455,8 @@ define("ember-data/lib/serializers/rest_serializer",
2826
3455
  this.normalizeHash[prop](hash);
2827
3456
  }
2828
3457
 
2829
- return this._super(type, hash, prop);
3458
+ this.applyTransforms(type, hash);
3459
+ return hash;
2830
3460
  },
2831
3461
 
2832
3462
  /**
@@ -2837,7 +3467,7 @@ define("ember-data/lib/serializers/rest_serializer",
2837
3467
 
2838
3468
  ```js
2839
3469
  App.ApplicationSerializer = DS.RESTSerializer.extend({
2840
- normalizePayload: function(type, payload) {
3470
+ normalizePayload: function(payload) {
2841
3471
  delete payload.version;
2842
3472
  delete payload.status;
2843
3473
  return payload;
@@ -2846,48 +3476,13 @@ define("ember-data/lib/serializers/rest_serializer",
2846
3476
  ```
2847
3477
 
2848
3478
  @method normalizePayload
2849
- @param {subclass of DS.Model} type
2850
- @param {Object} hash
2851
- @returns {Object} the normalized payload
3479
+ @param {Object} payload
3480
+ @return {Object} the normalized payload
2852
3481
  */
2853
- normalizePayload: function(type, payload) {
3482
+ normalizePayload: function(payload) {
2854
3483
  return payload;
2855
3484
  },
2856
3485
 
2857
- /**
2858
- @method normalizeId
2859
- @private
2860
- */
2861
- normalizeId: function(hash) {
2862
- var primaryKey = get(this, 'primaryKey');
2863
-
2864
- if (primaryKey === 'id') { return; }
2865
-
2866
- hash.id = hash[primaryKey];
2867
- delete hash[primaryKey];
2868
- },
2869
-
2870
- /**
2871
- @method normalizeUsingDeclaredMapping
2872
- @private
2873
- */
2874
- normalizeUsingDeclaredMapping: function(type, hash) {
2875
- var attrs = get(this, 'attrs'), payloadKey, key;
2876
-
2877
- if (attrs) {
2878
- for (key in attrs) {
2879
- payloadKey = attrs[key];
2880
- if (payloadKey && payloadKey.key) {
2881
- payloadKey = payloadKey.key;
2882
- }
2883
- if (typeof payloadKey === 'string') {
2884
- hash[key] = hash[payloadKey];
2885
- delete hash[payloadKey];
2886
- }
2887
- }
2888
- }
2889
- },
2890
-
2891
3486
  /**
2892
3487
  @method normalizeAttributes
2893
3488
  @private
@@ -2960,12 +3555,12 @@ define("ember-data/lib/serializers/rest_serializer",
2960
3555
  ```js
2961
3556
  App.PostSerializer = DS.RESTSerializer.extend({
2962
3557
  // First, restructure the top-level so it's organized by type
2963
- extractSingle: function(store, type, payload, id, requestType) {
3558
+ extractSingle: function(store, type, payload, id) {
2964
3559
  var comments = payload._embedded.comment;
2965
3560
  delete payload._embedded;
2966
3561
 
2967
3562
  payload = { comments: comments, post: payload };
2968
- return this._super(store, type, payload, id, requestType);
3563
+ return this._super(store, type, payload, id);
2969
3564
  },
2970
3565
 
2971
3566
  normalizeHash: {
@@ -2995,15 +3590,13 @@ define("ember-data/lib/serializers/rest_serializer",
2995
3590
 
2996
3591
  @method extractSingle
2997
3592
  @param {DS.Store} store
2998
- @param {subclass of DS.Model} type
3593
+ @param {subclass of DS.Model} primaryType
2999
3594
  @param {Object} payload
3000
- @param {String} id
3001
- @param {'find'|'createRecord'|'updateRecord'|'deleteRecord'} requestType
3002
- @returns {Object} the primary response to the original request
3595
+ @param {String} recordId
3596
+ @return {Object} the primary response to the original request
3003
3597
  */
3004
- extractSingle: function(store, primaryType, payload, recordId, requestType) {
3005
- payload = this.normalizePayload(primaryType, payload);
3006
-
3598
+ extractSingle: function(store, primaryType, payload, recordId) {
3599
+ payload = this.normalizePayload(payload);
3007
3600
  var primaryTypeName = primaryType.typeKey,
3008
3601
  primaryRecord;
3009
3602
 
@@ -3089,7 +3682,7 @@ define("ember-data/lib/serializers/rest_serializer",
3089
3682
  App.PostSerializer = DS.RESTSerializer.extend({
3090
3683
  // First, restructure the top-level so it's organized by type
3091
3684
  // and the comments are listed under a post's `comments` key.
3092
- extractArray: function(store, type, payload, id, requestType) {
3685
+ extractArray: function(store, type, payload) {
3093
3686
  var posts = payload._embedded.post;
3094
3687
  var comments = [];
3095
3688
  var postCache = {};
@@ -3107,7 +3700,7 @@ define("ember-data/lib/serializers/rest_serializer",
3107
3700
 
3108
3701
  payload = { comments: comments, posts: payload };
3109
3702
 
3110
- return this._super(store, type, payload, id, requestType);
3703
+ return this._super(store, type, payload);
3111
3704
  },
3112
3705
 
3113
3706
  normalizeHash: {
@@ -3141,14 +3734,13 @@ define("ember-data/lib/serializers/rest_serializer",
3141
3734
 
3142
3735
  @method extractArray
3143
3736
  @param {DS.Store} store
3144
- @param {subclass of DS.Model} type
3737
+ @param {subclass of DS.Model} primaryType
3145
3738
  @param {Object} payload
3146
- @param {'findAll'|'findMany'|'findHasMany'|'findQuery'} requestType
3147
- @returns {Array} The primary array that was returned in response
3739
+ @return {Array} The primary array that was returned in response
3148
3740
  to the original query.
3149
3741
  */
3150
3742
  extractArray: function(store, primaryType, payload) {
3151
- payload = this.normalizePayload(primaryType, payload);
3743
+ payload = this.normalizePayload(payload);
3152
3744
 
3153
3745
  var primaryTypeName = primaryType.typeKey,
3154
3746
  primaryArray;
@@ -3214,15 +3806,16 @@ define("ember-data/lib/serializers/rest_serializer",
3214
3806
  @param {Object} payload
3215
3807
  */
3216
3808
  pushPayload: function(store, payload) {
3217
- payload = this.normalizePayload(null, payload);
3809
+ payload = this.normalizePayload(payload);
3218
3810
 
3219
3811
  for (var prop in payload) {
3220
3812
  var typeName = this.typeForRoot(prop),
3221
- type = store.modelFor(typeName);
3813
+ type = store.modelFor(typeName),
3814
+ typeSerializer = store.serializerFor(type);
3222
3815
 
3223
3816
  /*jshint loopfunc:true*/
3224
3817
  var normalizedArray = map.call(Ember.makeArray(payload[prop]), function(hash) {
3225
- return this.normalize(type, hash, prop);
3818
+ return typeSerializer.normalize(type, hash, prop);
3226
3819
  }, this);
3227
3820
 
3228
3821
  store.pushMany(typeName, normalizedArray);
@@ -3230,27 +3823,50 @@ define("ember-data/lib/serializers/rest_serializer",
3230
3823
  },
3231
3824
 
3232
3825
  /**
3233
- You can use this method to normalize the JSON root keys returned
3234
- into the model type expected by your store.
3826
+ This method is used to convert each JSON root key in the payload
3827
+ into a typeKey that it can use to look up the appropriate model for
3828
+ that part of the payload. By default the typeKey for a model is its
3829
+ name in camelCase, so if your JSON root key is 'fast-car' you would
3830
+ use typeForRoot to convert it to 'fastCar' so that Ember Data finds
3831
+ the `FastCar` model.
3832
+
3833
+ If you diverge from this norm you should also consider changes to
3834
+ store._normalizeTypeKey as well.
3835
+
3836
+ For example, your server may return prefixed root keys like so:
3837
+
3838
+ ```js
3839
+ {
3840
+ "response-fast-car": {
3841
+ "id": "1",
3842
+ "name": "corvette"
3843
+ }
3844
+ }
3845
+ ```
3235
3846
 
3236
- For example, your server may return underscored root keys rather than
3237
- the expected camelcased versions.
3847
+ In order for Ember Data to know that the model corresponding to
3848
+ the 'response-fast-car' hash is `FastCar` (typeKey: 'fastCar'),
3849
+ you can override typeForRoot to convert 'response-fast-car' to
3850
+ 'fastCar' like so:
3238
3851
 
3239
3852
  ```js
3240
3853
  App.ApplicationSerializer = DS.RESTSerializer.extend({
3241
3854
  typeForRoot: function(root) {
3242
- var camelized = Ember.String.camelize(root);
3243
- return Ember.String.singularize(camelized);
3855
+ // 'response-fast-car' should become 'fast-car'
3856
+ var subRoot = root.substring(9);
3857
+
3858
+ // _super normalizes 'fast-car' to 'fastCar'
3859
+ return this._super(subRoot);
3244
3860
  }
3245
3861
  });
3246
3862
  ```
3247
3863
 
3248
3864
  @method typeForRoot
3249
- @param {String} root
3250
- @returns {String} the model's typeKey
3865
+ @param {String} key
3866
+ @return {String} the model's typeKey
3251
3867
  */
3252
- typeForRoot: function(root) {
3253
- return Ember.String.singularize(root);
3868
+ typeForRoot: function(key) {
3869
+ return camelize(singularize(key));
3254
3870
  },
3255
3871
 
3256
3872
  // SERIALIZE
@@ -3403,7 +4019,9 @@ define("ember-data/lib/serializers/rest_serializer",
3403
4019
 
3404
4020
  /**
3405
4021
  You can use this method to customize the root keys serialized into the JSON.
3406
- By default the REST Serializer sends camelized root keys.
4022
+ By default the REST Serializer sends the typeKey of a model, whih is a camelized
4023
+ version of the name.
4024
+
3407
4025
  For example, your server may expect underscored root objects.
3408
4026
 
3409
4027
  ```js
@@ -3422,8 +4040,7 @@ define("ember-data/lib/serializers/rest_serializer",
3422
4040
  @param {Object} options
3423
4041
  */
3424
4042
  serializeIntoHash: function(hash, type, record, options) {
3425
- var root = Ember.String.camelize(type.typeKey);
3426
- hash[root] = this.serialize(record, options);
4043
+ hash[type.typeKey] = this.serialize(record, options);
3427
4044
  },
3428
4045
 
3429
4046
  /**
@@ -3440,12 +4057,34 @@ define("ember-data/lib/serializers/rest_serializer",
3440
4057
  var key = relationship.key,
3441
4058
  belongsTo = get(record, key);
3442
4059
  key = this.keyForAttribute ? this.keyForAttribute(key) : key;
3443
- json[key + "Type"] = Ember.String.camelize(belongsTo.constructor.typeKey);
4060
+ json[key + "Type"] = belongsTo.constructor.typeKey;
3444
4061
  }
3445
4062
  });
3446
4063
 
3447
4064
  __exports__["default"] = RESTSerializer;
3448
4065
  });
4066
+ define("ember-data/lib/setup-container",
4067
+ ["./initializers/store","./initializers/transforms","./initializers/store_injections","./initializers/data_adapter","../../../activemodel-adapter/lib/setup-container","exports"],
4068
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
4069
+ "use strict";
4070
+ var initializeStore = __dependency1__["default"];
4071
+ var initializeTransforms = __dependency2__["default"];
4072
+ var initializeStoreInjections = __dependency3__["default"];
4073
+ var initializeDataAdapter = __dependency4__["default"];
4074
+ var setupActiveModelContainer = __dependency5__["default"];
4075
+
4076
+ __exports__["default"] = function setupContainer(container, application){
4077
+ // application is not a required argument. This ensures
4078
+ // testing setups can setup a container without booting an
4079
+ // entire ember application.
4080
+
4081
+ initializeDataAdapter(container, application);
4082
+ initializeTransforms(container, application);
4083
+ initializeStoreInjections(container, application);
4084
+ initializeStore(container, application);
4085
+ setupActiveModelContainer(container, application);
4086
+ };
4087
+ });
3449
4088
  define("ember-data/lib/system/adapter",
3450
4089
  ["exports"],
3451
4090
  function(__exports__) {
@@ -3484,11 +4123,11 @@ define("ember-data/lib/system/adapter",
3484
4123
  }
3485
4124
  });
3486
4125
  ```
3487
-
4126
+
3488
4127
  The `DS.InvalidError` must be constructed with a single object whose
3489
4128
  keys are the invalid model properties, and whose values are the
3490
4129
  corresponding error messages. For example:
3491
-
4130
+
3492
4131
  ```javascript
3493
4132
  return new DS.InvalidError({
3494
4133
  length: 'Must be less than 15',
@@ -3519,20 +4158,26 @@ define("ember-data/lib/system/adapter",
3519
4158
 
3520
4159
  ### Creating an Adapter
3521
4160
 
3522
- First, create a new subclass of `DS.Adapter`:
4161
+ Create a new subclass of `DS.Adapter`, then assign
4162
+ it to the `ApplicationAdapter` property of the application.
3523
4163
 
3524
4164
  ```javascript
3525
- App.MyAdapter = DS.Adapter.extend({
4165
+ var MyAdapter = DS.Adapter.extend({
3526
4166
  // ...your code here
3527
4167
  });
4168
+
4169
+ App.ApplicationAdapter = MyAdapter;
3528
4170
  ```
3529
4171
 
3530
- To tell your store which adapter to use, set its `adapter` property:
4172
+ Model-specific adapters can be created by assigning your adapter
4173
+ class to the `ModelName` + `Adapter` property of the application.
3531
4174
 
3532
4175
  ```javascript
3533
- App.store = DS.Store.create({
3534
- adapter: 'MyAdapter'
4176
+ var MyPostAdapter = DS.Adapter.extend({
4177
+ // ...Post-specific adapter code goes here
3535
4178
  });
4179
+
4180
+ App.PostAdapter = MyPostAdapter;
3536
4181
  ```
3537
4182
 
3538
4183
  `DS.Adapter` is an abstract base class that you should override in your
@@ -3897,24 +4542,21 @@ define("ember-data/lib/system/adapter",
3897
4542
  __exports__["default"] = Adapter;
3898
4543
  });
3899
4544
  define("ember-data/lib/system/changes",
3900
- ["./changes/attribute_change","./changes/relationship_change","exports"],
3901
- function(__dependency1__, __dependency2__, __exports__) {
4545
+ ["./changes/relationship_change","exports"],
4546
+ function(__dependency1__, __exports__) {
3902
4547
  "use strict";
3903
4548
  /**
3904
4549
  @module ember-data
3905
4550
  */
3906
4551
 
3907
- var AttributeChange = __dependency1__["default"];
4552
+ var RelationshipChange = __dependency1__.RelationshipChange;
4553
+ var RelationshipChangeAdd = __dependency1__.RelationshipChangeAdd;
4554
+ var RelationshipChangeRemove = __dependency1__.RelationshipChangeRemove;
4555
+ var OneToManyChange = __dependency1__.OneToManyChange;
4556
+ var ManyToNoneChange = __dependency1__.ManyToNoneChange;
4557
+ var OneToOneChange = __dependency1__.OneToOneChange;
4558
+ var ManyToManyChange = __dependency1__.ManyToManyChange;
3908
4559
 
3909
- var RelationshipChange = __dependency2__.RelationshipChange;
3910
- var RelationshipChangeAdd = __dependency2__.RelationshipChangeAdd;
3911
- var RelationshipChangeRemove = __dependency2__.RelationshipChangeRemove;
3912
- var OneToManyChange = __dependency2__.OneToManyChange;
3913
- var ManyToNoneChange = __dependency2__.ManyToNoneChange;
3914
- var OneToOneChange = __dependency2__.OneToOneChange;
3915
- var ManyToManyChange = __dependency2__.ManyToManyChange;
3916
-
3917
- __exports__.AttributeChange = AttributeChange;
3918
4560
  __exports__.RelationshipChange = RelationshipChange;
3919
4561
  __exports__.RelationshipChangeAdd = RelationshipChangeAdd;
3920
4562
  __exports__.RelationshipChangeRemove = RelationshipChangeRemove;
@@ -3923,61 +4565,6 @@ define("ember-data/lib/system/changes",
3923
4565
  __exports__.OneToOneChange = OneToOneChange;
3924
4566
  __exports__.ManyToManyChange = ManyToManyChange;
3925
4567
  });
3926
- define("ember-data/lib/system/changes/attribute_change",
3927
- ["exports"],
3928
- function(__exports__) {
3929
- "use strict";
3930
- /**
3931
- @module ember-data
3932
- */
3933
-
3934
- /**
3935
- An AttributeChange object is created whenever a record's
3936
- attribute changes value. It is used to track changes to a
3937
- record between transaction commits.
3938
-
3939
- @class AttributeChange
3940
- @namespace DS
3941
- @private
3942
- @constructor
3943
- */
3944
- function AttributeChange(options) {
3945
- this.record = options.record;
3946
- this.store = options.store;
3947
- this.name = options.name;
3948
- this.value = options.value;
3949
- this.oldValue = options.oldValue;
3950
- }
3951
-
3952
- AttributeChange.createChange = function(options) {
3953
- return new AttributeChange(options);
3954
- };
3955
-
3956
- AttributeChange.prototype = {
3957
- sync: function() {
3958
- if (this.value !== this.oldValue) {
3959
- this.record.send('becomeDirty');
3960
- this.record.updateRecordArraysLater();
3961
- }
3962
-
3963
- // TODO: Use this object in the commit process
3964
- this.destroy();
3965
- },
3966
-
3967
- /**
3968
- If the AttributeChange is destroyed (either by being rolled back
3969
- or being committed), remove it from the list of pending changes
3970
- on the record.
3971
-
3972
- @method destroy
3973
- */
3974
- destroy: function() {
3975
- delete this.record._changesToSync[this.name];
3976
- }
3977
- };
3978
-
3979
- __exports__["default"] = AttributeChange;
3980
- });
3981
4568
  define("ember-data/lib/system/changes/relationship_change",
3982
4569
  ["../model","exports"],
3983
4570
  function(__dependency1__, __exports__) {
@@ -4948,6 +5535,8 @@ define("ember-data/lib/system/model/attributes",
4948
5535
  `boolean` and `date`. You can define your own transforms by subclassing
4949
5536
  [DS.Transform](/api/data/classes/DS.Transform.html).
4950
5537
 
5538
+ Note that you cannot use `attr` to define an attribute of `id`.
5539
+
4951
5540
  `DS.attr` takes an optional hash as a second parameter, currently
4952
5541
  supported options are:
4953
5542
 
@@ -5020,6 +5609,7 @@ define("ember-data/lib/system/model/errors",
5020
5609
  function(__exports__) {
5021
5610
  "use strict";
5022
5611
  var get = Ember.get, isEmpty = Ember.isEmpty;
5612
+ var map = Ember.EnumerableUtils.map;
5023
5613
 
5024
5614
  /**
5025
5615
  @module ember-data
@@ -5028,6 +5618,65 @@ define("ember-data/lib/system/model/errors",
5028
5618
  /**
5029
5619
  Holds validation errors for a given record organized by attribute names.
5030
5620
 
5621
+ Every DS.Model has an `errors` property that is an instance of
5622
+ `DS.Errors`. This can be used to display validation error
5623
+ messages returned from the server when a `record.save()` rejects.
5624
+
5625
+ For Example, if you had an `User` model that looked like this:
5626
+
5627
+ ```javascript
5628
+ App.User = DS.Model.extend({
5629
+ username: attr('string'),
5630
+ email: attr('string')
5631
+ });
5632
+ ```
5633
+ And you attempted to save a record that did not validate on the backend.
5634
+
5635
+ ```javascript
5636
+ var user = store.createRecord('user', {
5637
+ username: 'tomster',
5638
+ email: 'invalidEmail'
5639
+ });
5640
+ user.save();
5641
+ ```
5642
+
5643
+ Your backend data store might return a response that looks like
5644
+ this. This response will be used to populate the error object.
5645
+
5646
+ ```javascript
5647
+ {
5648
+ "errors": {
5649
+ "username": ["This username is already taken!"],
5650
+ "email": ["Doesn't look like a valid email."]
5651
+ }
5652
+ }
5653
+ ```
5654
+
5655
+ Errors can be displayed to the user by accessing their property name
5656
+ or using the `messages` property to get an array of all errors.
5657
+
5658
+ ```handlebars
5659
+ {{#each errors.messages}}
5660
+ <div class="error">
5661
+ {{message}}
5662
+ </div>
5663
+ {{/each}}
5664
+
5665
+ <label>Username: {{input value=username}} </label>
5666
+ {{#each errors.username}}
5667
+ <div class="error">
5668
+ {{message}}
5669
+ </div>
5670
+ {{/each}}
5671
+
5672
+ <label>Email: {{input value=email}} </label>
5673
+ {{#each errors.email}}
5674
+ <div class="error">
5675
+ {{message}}
5676
+ </div>
5677
+ {{/each}}
5678
+ ```
5679
+
5031
5680
  @class Errors
5032
5681
  @namespace DS
5033
5682
  @extends Ember.Object
@@ -5078,15 +5727,38 @@ define("ember-data/lib/system/model/errors",
5078
5727
  /**
5079
5728
  Returns errors for a given attribute
5080
5729
 
5730
+ ```javascript
5731
+ var user = store.createRecord('user', {
5732
+ username: 'tomster',
5733
+ email: 'invalidEmail'
5734
+ });
5735
+ user.save().catch(function(){
5736
+ user.get('errors').errorsFor('email'); // ["Doesn't look like a valid email."]
5737
+ });
5738
+ ```
5739
+
5081
5740
  @method errorsFor
5082
5741
  @param {String} attribute
5083
- @returns {Array}
5742
+ @return {Array}
5084
5743
  */
5085
5744
  errorsFor: function(attribute) {
5086
5745
  return get(this, 'errorsByAttributeName').get(attribute);
5087
5746
  },
5088
5747
 
5089
5748
  /**
5749
+ An array containing all of the error messages for this
5750
+ record. This is useful for displaying all errors to the user.
5751
+
5752
+ ```handlebars
5753
+ {{#each errors.messages}}
5754
+ <div class="error">
5755
+ {{message}}
5756
+ </div>
5757
+ {{/each}}
5758
+ ```
5759
+
5760
+ @property messages
5761
+ @type {Array}
5090
5762
  */
5091
5763
  messages: Ember.computed.mapBy('content', 'message'),
5092
5764
 
@@ -5137,6 +5809,14 @@ define("ember-data/lib/system/model/errors",
5137
5809
  Adds error messages to a given attribute and sends
5138
5810
  `becameInvalid` event to the record.
5139
5811
 
5812
+ Example:
5813
+
5814
+ ```javascript
5815
+ if (!user.get('username') {
5816
+ user.get('errors').add('username', 'This field is required');
5817
+ }
5818
+ ```
5819
+
5140
5820
  @method add
5141
5821
  @param {String} attribute
5142
5822
  @param {Array|String} messages
@@ -5162,7 +5842,7 @@ define("ember-data/lib/system/model/errors",
5162
5842
  _findOrCreateMessages: function(attribute, messages) {
5163
5843
  var errors = this.errorsFor(attribute);
5164
5844
 
5165
- return Ember.makeArray(messages).map(function(message) {
5845
+ return map(Ember.makeArray(messages), function(message) {
5166
5846
  return errors.findBy('message', message) || {
5167
5847
  attribute: attribute,
5168
5848
  message: message
@@ -5174,6 +5854,27 @@ define("ember-data/lib/system/model/errors",
5174
5854
  Removes all error messages from the given attribute and sends
5175
5855
  `becameValid` event to the record if there no more errors left.
5176
5856
 
5857
+ Example:
5858
+
5859
+ ```javascript
5860
+ App.User = DS.Model.extend({
5861
+ email: DS.attr('string'),
5862
+ twoFactorAuth: DS.attr('boolean'),
5863
+ phone: DS.attr('string')
5864
+ });
5865
+
5866
+ App.UserEditRoute = Ember.Route.extend({
5867
+ actions: {
5868
+ save: function(user) {
5869
+ if (!user.get('twoFactorAuth')) {
5870
+ user.get('errors').remove('phone');
5871
+ }
5872
+ user.save();
5873
+ }
5874
+ }
5875
+ });
5876
+ ```
5877
+
5177
5878
  @method remove
5178
5879
  @param {String} attribute
5179
5880
  */
@@ -5195,6 +5896,19 @@ define("ember-data/lib/system/model/errors",
5195
5896
  Removes all error messages and sends `becameValid` event
5196
5897
  to the record.
5197
5898
 
5899
+ Example:
5900
+
5901
+ ```javascript
5902
+ App.UserEditRoute = Ember.Route.extend({
5903
+ actions: {
5904
+ retrySave: function(user) {
5905
+ user.get('errors').clear();
5906
+ user.save();
5907
+ }
5908
+ }
5909
+ });
5910
+ ```
5911
+
5198
5912
  @method clear
5199
5913
  */
5200
5914
  clear: function() {
@@ -5209,9 +5923,22 @@ define("ember-data/lib/system/model/errors",
5209
5923
  /**
5210
5924
  Checks if there is error messages for the given attribute.
5211
5925
 
5926
+ ```javascript
5927
+ App.UserEditRoute = Ember.Route.extend({
5928
+ actions: {
5929
+ save: function(user) {
5930
+ if (user.get('errors').has('email')) {
5931
+ return alert('Please update your email before attempting to save.');
5932
+ }
5933
+ user.save();
5934
+ }
5935
+ }
5936
+ });
5937
+ ```
5938
+
5212
5939
  @method has
5213
5940
  @param {String} attribute
5214
- @returns {Boolean} true if there some errors on given attribute
5941
+ @return {Boolean} true if there some errors on given attribute
5215
5942
  */
5216
5943
  has: function(attribute) {
5217
5944
  return !isEmpty(this.errorsFor(attribute));
@@ -5221,11 +5948,12 @@ define("ember-data/lib/system/model/errors",
5221
5948
  __exports__["default"] = Errors;
5222
5949
  });
5223
5950
  define("ember-data/lib/system/model/model",
5224
- ["./states","./errors","exports"],
5225
- function(__dependency1__, __dependency2__, __exports__) {
5951
+ ["./states","./errors","../store","exports"],
5952
+ function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
5226
5953
  "use strict";
5227
5954
  var RootState = __dependency1__["default"];
5228
5955
  var Errors = __dependency2__["default"];
5956
+ var PromiseObject = __dependency3__.PromiseObject;
5229
5957
  /**
5230
5958
  @module ember-data
5231
5959
  */
@@ -5234,6 +5962,7 @@ define("ember-data/lib/system/model/model",
5234
5962
  merge = Ember.merge,
5235
5963
  Promise = Ember.RSVP.Promise;
5236
5964
 
5965
+ var JSONSerializer;
5237
5966
  var retrieveFromCurrentState = Ember.computed('currentState', function(key, value) {
5238
5967
  return get(get(this, 'currentState'), key);
5239
5968
  }).readOnly();
@@ -5285,7 +6014,7 @@ define("ember-data/lib/system/model/model",
5285
6014
  Example
5286
6015
 
5287
6016
  ```javascript
5288
- var record = store.createRecord(App.Model);
6017
+ var record = store.createRecord('model');
5289
6018
  record.get('isLoaded'); // true
5290
6019
 
5291
6020
  store.find('model', 1).then(function(model) {
@@ -5307,13 +6036,13 @@ define("ember-data/lib/system/model/model",
5307
6036
  Example
5308
6037
 
5309
6038
  ```javascript
5310
- var record = store.createRecord(App.Model);
6039
+ var record = store.createRecord('model');
5311
6040
  record.get('isDirty'); // true
5312
6041
 
5313
6042
  store.find('model', 1).then(function(model) {
5314
6043
  model.get('isDirty'); // false
5315
6044
  model.set('foo', 'some value');
5316
- model.set('isDirty'); // true
6045
+ model.get('isDirty'); // true
5317
6046
  });
5318
6047
  ```
5319
6048
 
@@ -5331,7 +6060,7 @@ define("ember-data/lib/system/model/model",
5331
6060
  Example
5332
6061
 
5333
6062
  ```javascript
5334
- var record = store.createRecord(App.Model);
6063
+ var record = store.createRecord('model');
5335
6064
  record.get('isSaving'); // false
5336
6065
  var promise = record.save();
5337
6066
  record.get('isSaving'); // true
@@ -5356,10 +6085,26 @@ define("ember-data/lib/system/model/model",
5356
6085
  Example
5357
6086
 
5358
6087
  ```javascript
5359
- var record = store.createRecord(App.Model);
5360
- record.get('isDeleted'); // false
6088
+ var record = store.createRecord('model');
6089
+ record.get('isDeleted'); // false
5361
6090
  record.deleteRecord();
5362
- record.get('isDeleted'); // true
6091
+
6092
+ // Locally deleted
6093
+ record.get('isDeleted'); // true
6094
+ record.get('isDirty'); // true
6095
+ record.get('isSaving'); // false
6096
+
6097
+ // Persisting the deletion
6098
+ var promise = record.save();
6099
+ record.get('isDeleted'); // true
6100
+ record.get('isSaving'); // true
6101
+
6102
+ // Deletion Persisted
6103
+ promise.then(function() {
6104
+ record.get('isDeleted'); // true
6105
+ record.get('isSaving'); // false
6106
+ record.get('isDirty'); // false
6107
+ });
5363
6108
  ```
5364
6109
 
5365
6110
  @property isDeleted
@@ -5376,7 +6121,7 @@ define("ember-data/lib/system/model/model",
5376
6121
  Example
5377
6122
 
5378
6123
  ```javascript
5379
- var record = store.createRecord(App.Model);
6124
+ var record = store.createRecord('model');
5380
6125
  record.get('isNew'); // true
5381
6126
 
5382
6127
  record.save().then(function(model) {
@@ -5390,9 +6135,9 @@ define("ember-data/lib/system/model/model",
5390
6135
  */
5391
6136
  isNew: retrieveFromCurrentState,
5392
6137
  /**
5393
- If this property is `true` the record is in the `valid` state. A
5394
- record will be in the `valid` state when no client-side
5395
- validations have failed and the adapter did not report any
6138
+ If this property is `true` the record is in the `valid` state.
6139
+
6140
+ A record will be in the `valid` state when the adapter did not report any
5396
6141
  server-side validation failures.
5397
6142
 
5398
6143
  @property isValid
@@ -5412,7 +6157,7 @@ define("ember-data/lib/system/model/model",
5412
6157
  Example
5413
6158
 
5414
6159
  ```javascript
5415
- var record = store.createRecord(App.Model);
6160
+ var record = store.createRecord('model');
5416
6161
  record.get('dirtyType'); // 'created'
5417
6162
  ```
5418
6163
 
@@ -5424,15 +6169,14 @@ define("ember-data/lib/system/model/model",
5424
6169
 
5425
6170
  /**
5426
6171
  If `true` the adapter reported that it was unable to save local
5427
- changes to the backend. This may also result in the record having
5428
- its `isValid` property become false if the adapter reported that
5429
- server-side validations failed.
6172
+ changes to the backend for any reason other than a server-side
6173
+ validation error.
5430
6174
 
5431
6175
  Example
5432
6176
 
5433
6177
  ```javascript
5434
6178
  record.get('isError'); // false
5435
- record.set('foo', 'invalid value');
6179
+ record.set('foo', 'valid value');
5436
6180
  record.save().then(null, function() {
5437
6181
  record.get('isError'); // true
5438
6182
  });
@@ -5479,7 +6223,7 @@ define("ember-data/lib/system/model/model",
5479
6223
  attribute.
5480
6224
 
5481
6225
  ```javascript
5482
- var record = store.createRecord(App.Model);
6226
+ var record = store.createRecord('model');
5483
6227
  record.get('id'); // null
5484
6228
 
5485
6229
  store.find('model', 1).then(function(model) {
@@ -5514,7 +6258,7 @@ define("ember-data/lib/system/model/model",
5514
6258
  ```
5515
6259
 
5516
6260
  @property errors
5517
- @type {Object}
6261
+ @type {DS.Errors}
5518
6262
  */
5519
6263
  errors: Ember.computed(function() {
5520
6264
  var errors = Errors.create();
@@ -5540,7 +6284,7 @@ define("ember-data/lib/system/model/model",
5540
6284
 
5541
6285
  @method serialize
5542
6286
  @param {Object} options
5543
- @returns {Object} an object whose values are primitive JSON values only
6287
+ @return {Object} an object whose values are primitive JSON values only
5544
6288
  */
5545
6289
  serialize: function(options) {
5546
6290
  var store = get(this, 'store');
@@ -5559,11 +6303,12 @@ define("ember-data/lib/system/model/model",
5559
6303
 
5560
6304
  @method toJSON
5561
6305
  @param {Object} options
5562
- @returns {Object} A JSON representation of the object.
6306
+ @return {Object} A JSON representation of the object.
5563
6307
  */
5564
6308
  toJSON: function(options) {
6309
+ if (!JSONSerializer) { JSONSerializer = requireModule("ember-data/lib/serializers/json_serializer")["default"]; }
5565
6310
  // container is for lazy transform lookups
5566
- var serializer = DS.JSONSerializer.create({ container: this.container });
6311
+ var serializer = JSONSerializer.create({ container: this.container });
5567
6312
  return serializer.serialize(this, options);
5568
6313
  },
5569
6314
 
@@ -6113,7 +6858,7 @@ define("ember-data/lib/system/model/model",
6113
6858
  this._inFlightAttributes = this._attributes;
6114
6859
  this._attributes = {};
6115
6860
 
6116
- return DS.PromiseObject.create({ promise: resolver.promise });
6861
+ return PromiseObject.create({ promise: resolver.promise });
6117
6862
  },
6118
6863
 
6119
6864
  /**
@@ -6157,7 +6902,7 @@ define("ember-data/lib/system/model/model",
6157
6902
  throw reason;
6158
6903
  }, "DS: Model#reload complete, update flags");
6159
6904
 
6160
- return DS.PromiseObject.create({ promise: promise });
6905
+ return PromiseObject.create({ promise: promise });
6161
6906
  },
6162
6907
 
6163
6908
  // FOR USE DURING COMMIT PROCESS
@@ -6492,8 +7237,8 @@ define("ember-data/lib/system/model/states",
6492
7237
  // adapter reported that server-side validations failed.
6493
7238
  // * isNew: The record was created on the client and the adapter
6494
7239
  // did not yet report that it was successfully saved.
6495
- // * isValid: No client-side validations have failed and the
6496
- // adapter did not report any server-side validation failures.
7240
+ // * isValid: The adapter did not report any server-side validation
7241
+ // failures.
6497
7242
 
6498
7243
  // The dirty state is a abstract state whose functionality is
6499
7244
  // shared between the `created` and `updated` states.
@@ -6597,8 +7342,7 @@ define("ember-data/lib/system/model/states",
6597
7342
  }
6598
7343
  },
6599
7344
 
6600
- // A record is in the `invalid` state when its client-side
6601
- // invalidations have failed, or if the adapter has indicated
7345
+ // A record is in the `invalid` if the adapter has indicated
6602
7346
  // the the record failed server-side invalidations.
6603
7347
  invalid: {
6604
7348
  // FLAGS
@@ -6618,6 +7362,11 @@ define("ember-data/lib/system/model/states",
6618
7362
 
6619
7363
  becomeDirty: Ember.K,
6620
7364
 
7365
+ willCommit: function(record) {
7366
+ get(record, 'errors').clear();
7367
+ record.transitionTo('inFlight');
7368
+ },
7369
+
6621
7370
  rolledBack: function(record) {
6622
7371
  get(record, 'errors').clear();
6623
7372
  },
@@ -6628,6 +7377,10 @@ define("ember-data/lib/system/model/states",
6628
7377
 
6629
7378
  invokeLifecycleCallbacks: function(record) {
6630
7379
  record.triggerLater('becameInvalid', record);
7380
+ },
7381
+
7382
+ exit: function(record) {
7383
+ record._inFlightAttributes = {};
6631
7384
  }
6632
7385
  }
6633
7386
  };
@@ -6949,7 +7702,11 @@ define("ember-data/lib/system/model/states",
6949
7702
  invokeLifecycleCallbacks: function(record) {
6950
7703
  record.triggerLater('didDelete', record);
6951
7704
  record.triggerLater('didCommit', record);
6952
- }
7705
+ },
7706
+
7707
+ willCommit: Ember.K,
7708
+
7709
+ didCommit: Ember.K
6953
7710
  }
6954
7711
  },
6955
7712
 
@@ -6993,6 +7750,9 @@ define("ember-data/lib/system/record_array_manager",
6993
7750
  @module ember-data
6994
7751
  */
6995
7752
 
7753
+ var RecordArray = __dependency1__.RecordArray;
7754
+ var FilteredRecordArray = __dependency1__.FilteredRecordArray;
7755
+ var AdapterPopulatedRecordArray = __dependency1__.AdapterPopulatedRecordArray;
6996
7756
  var ManyArray = __dependency1__.ManyArray;
6997
7757
  var get = Ember.get, set = Ember.set;
6998
7758
  var forEach = Ember.EnumerableUtils.forEach;
@@ -7168,7 +7928,7 @@ define("ember-data/lib/system/record_array_manager",
7168
7928
  @return {DS.RecordArray}
7169
7929
  */
7170
7930
  createRecordArray: function(type) {
7171
- var array = DS.RecordArray.create({
7931
+ var array = RecordArray.create({
7172
7932
  type: type,
7173
7933
  content: Ember.A(),
7174
7934
  store: this.store,
@@ -7186,10 +7946,12 @@ define("ember-data/lib/system/record_array_manager",
7186
7946
  @method createFilteredRecordArray
7187
7947
  @param {Class} type
7188
7948
  @param {Function} filter
7949
+ @param {Object} query (optional
7189
7950
  @return {DS.FilteredRecordArray}
7190
7951
  */
7191
- createFilteredRecordArray: function(type, filter) {
7192
- var array = DS.FilteredRecordArray.create({
7952
+ createFilteredRecordArray: function(type, filter, query) {
7953
+ var array = FilteredRecordArray.create({
7954
+ query: query,
7193
7955
  type: type,
7194
7956
  content: Ember.A(),
7195
7957
  store: this.store,
@@ -7211,11 +7973,12 @@ define("ember-data/lib/system/record_array_manager",
7211
7973
  @return {DS.AdapterPopulatedRecordArray}
7212
7974
  */
7213
7975
  createAdapterPopulatedRecordArray: function(type, query) {
7214
- var array = DS.AdapterPopulatedRecordArray.create({
7976
+ var array = AdapterPopulatedRecordArray.create({
7215
7977
  type: type,
7216
7978
  query: query,
7217
7979
  content: Ember.A(),
7218
- store: this.store
7980
+ store: this.store,
7981
+ manager: this
7219
7982
  });
7220
7983
 
7221
7984
  this._adapterPopulatedRecordArrays.push(array);
@@ -7255,8 +8018,8 @@ define("ember-data/lib/system/record_array_manager",
7255
8018
  willDestroy: function(){
7256
8019
  this._super();
7257
8020
 
7258
- flatten(values(this.filteredRecordArrays.values)).forEach(destroy);
7259
- this._adapterPopulatedRecordArrays.forEach(destroy);
8021
+ forEach(flatten(values(this.filteredRecordArrays.values)), destroy);
8022
+ forEach(this._adapterPopulatedRecordArrays, destroy);
7260
8023
  }
7261
8024
  });
7262
8025
 
@@ -7349,9 +8112,13 @@ define("ember-data/lib/system/record_arrays/adapter_populated_record_array",
7349
8112
  this.setProperties({
7350
8113
  content: Ember.A(records),
7351
8114
  isLoaded: true,
7352
- meta: meta
8115
+ meta: Ember.copy(meta)
7353
8116
  });
7354
8117
 
8118
+ records.forEach(function(record) {
8119
+ this.manager.recordArraysForRecord(record).add(this);
8120
+ }, this);
8121
+
7355
8122
  // TODO: should triggering didLoad event be the last action of the runLoop?
7356
8123
  Ember.run.once(this, 'trigger', 'didLoad');
7357
8124
  }
@@ -7420,9 +8187,13 @@ define("ember-data/lib/system/record_arrays/filtered_record_array",
7420
8187
  @method updateFilter
7421
8188
  @private
7422
8189
  */
7423
- updateFilter: Ember.observer(function() {
8190
+ _updateFilter: function() {
7424
8191
  var manager = get(this, 'manager');
7425
8192
  manager.updateFilter(this, get(this, 'type'), get(this, 'filterFunction'));
8193
+ },
8194
+
8195
+ updateFilter: Ember.observer(function() {
8196
+ Ember.run.once(this, this._updateFilter);
7426
8197
  }, 'filterFunction')
7427
8198
  });
7428
8199
 
@@ -7553,11 +8324,10 @@ define("ember-data/lib/system/record_arrays/many_array",
7553
8324
  fetch: function() {
7554
8325
  var records = get(this, 'content'),
7555
8326
  store = get(this, 'store'),
7556
- owner = get(this, 'owner'),
7557
- resolver = Ember.RSVP.defer("DS: ManyArray#fetch " + get(this, 'type'));
8327
+ owner = get(this, 'owner');
7558
8328
 
7559
8329
  var unloadedRecords = records.filterProperty('isEmpty', true);
7560
- store.fetchMany(unloadedRecords, owner, resolver);
8330
+ store.fetchMany(unloadedRecords, owner);
7561
8331
  },
7562
8332
 
7563
8333
  // Overrides Ember.Array's replace method to implement
@@ -7717,7 +8487,7 @@ define("ember-data/lib/system/record_arrays/record_array",
7717
8487
  Example
7718
8488
 
7719
8489
  ```javascript
7720
- var people = store.all(App.Person);
8490
+ var people = store.all('person');
7721
8491
  people.get('isLoaded'); // true
7722
8492
  ```
7723
8493
 
@@ -7731,7 +8501,7 @@ define("ember-data/lib/system/record_arrays/record_array",
7731
8501
  Example
7732
8502
 
7733
8503
  ```javascript
7734
- var people = store.all(App.Person);
8504
+ var people = store.all('person');
7735
8505
  people.get('isUpdating'); // false
7736
8506
  people.update();
7737
8507
  people.get('isUpdating'); // true
@@ -7772,7 +8542,7 @@ define("ember-data/lib/system/record_arrays/record_array",
7772
8542
  Example
7773
8543
 
7774
8544
  ```javascript
7775
- var people = store.all(App.Person);
8545
+ var people = store.all('person');
7776
8546
  people.get('isUpdating'); // false
7777
8547
  people.update();
7778
8548
  people.get('isUpdating'); // true
@@ -7817,7 +8587,7 @@ define("ember-data/lib/system/record_arrays/record_array",
7817
8587
  Example
7818
8588
 
7819
8589
  ```javascript
7820
- var messages = store.all(App.Message);
8590
+ var messages = store.all('message');
7821
8591
  messages.forEach(function(message) {
7822
8592
  message.set('hasBeenSeen', true);
7823
8593
  });
@@ -7856,6 +8626,41 @@ define("ember-data/lib/system/record_arrays/record_array",
7856
8626
 
7857
8627
  __exports__["default"] = RecordArray;
7858
8628
  });
8629
+ define("ember-data/lib/system/relationship-meta",
8630
+ ["../../../ember-inflector/lib/system","exports"],
8631
+ function(__dependency1__, __exports__) {
8632
+ "use strict";
8633
+ var singularize = __dependency1__.singularize;
8634
+
8635
+ function typeForRelationshipMeta(store, meta) {
8636
+ var typeKey, type;
8637
+
8638
+ typeKey = meta.type || meta.key;
8639
+ if (typeof typeKey === 'string') {
8640
+ if (meta.kind === 'hasMany') {
8641
+ typeKey = singularize(typeKey);
8642
+ }
8643
+ type = store.modelFor(typeKey);
8644
+ } else {
8645
+ type = meta.type;
8646
+ }
8647
+
8648
+ return type;
8649
+ }
8650
+
8651
+ __exports__.typeForRelationshipMeta = typeForRelationshipMeta;function relationshipFromMeta(store, meta) {
8652
+ return {
8653
+ key: meta.key,
8654
+ kind: meta.kind,
8655
+ type: typeForRelationshipMeta(store, meta),
8656
+ options: meta.options,
8657
+ parentType: meta.parentType,
8658
+ isRelationship: true
8659
+ };
8660
+ }
8661
+
8662
+ __exports__.relationshipFromMeta = relationshipFromMeta;
8663
+ });
7859
8664
  define("ember-data/lib/system/relationships",
7860
8665
  ["./relationships/belongs_to","./relationships/has_many","../system/relationships/ext","exports"],
7861
8666
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
@@ -7872,8 +8677,8 @@ define("ember-data/lib/system/relationships",
7872
8677
  __exports__.hasMany = hasMany;
7873
8678
  });
7874
8679
  define("ember-data/lib/system/relationships/belongs_to",
7875
- ["../model","exports"],
7876
- function(__dependency1__, __exports__) {
8680
+ ["../model","../store","../changes","../relationship-meta","exports"],
8681
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
7877
8682
  "use strict";
7878
8683
  var get = Ember.get, set = Ember.set,
7879
8684
  isNone = Ember.isNone;
@@ -7881,6 +8686,10 @@ define("ember-data/lib/system/relationships/belongs_to",
7881
8686
  var Promise = Ember.RSVP.Promise;
7882
8687
 
7883
8688
  var Model = __dependency1__.Model;
8689
+ var PromiseObject = __dependency2__.PromiseObject;
8690
+ var RelationshipChange = __dependency3__.RelationshipChange;
8691
+ var relationshipFromMeta = __dependency4__.relationshipFromMeta;
8692
+ var typeForRelationshipMeta = __dependency4__.typeForRelationshipMeta;
7884
8693
 
7885
8694
  /**
7886
8695
  @module ember-data
@@ -7893,8 +8702,10 @@ define("ember-data/lib/system/relationships/belongs_to",
7893
8702
  promiseLabel = "DS: Async belongsTo " + this + " : " + key,
7894
8703
  promise;
7895
8704
 
8705
+ meta.key = key;
8706
+
7896
8707
  if (arguments.length === 2) {
7897
- return value === undefined ? null : DS.PromiseObject.create({
8708
+ return value === undefined ? null : PromiseObject.create({
7898
8709
  promise: Promise.cast(value, promiseLabel)
7899
8710
  });
7900
8711
  }
@@ -7904,12 +8715,12 @@ define("ember-data/lib/system/relationships/belongs_to",
7904
8715
 
7905
8716
  if(!isNone(belongsTo)) {
7906
8717
  promise = store.fetchRecord(belongsTo) || Promise.cast(belongsTo, promiseLabel);
7907
- return DS.PromiseObject.create({
8718
+ return PromiseObject.create({
7908
8719
  promise: promise
7909
8720
  });
7910
8721
  } else if (link) {
7911
- promise = store.findBelongsTo(this, link, meta);
7912
- return DS.PromiseObject.create({
8722
+ promise = store.findBelongsTo(this, link, relationshipFromMeta(store, meta));
8723
+ return PromiseObject.create({
7913
8724
  promise: promise
7914
8725
  });
7915
8726
  } else {
@@ -7978,7 +8789,8 @@ define("ember-data/lib/system/relationships/belongs_to",
7978
8789
  type: type,
7979
8790
  isRelationship: true,
7980
8791
  options: options,
7981
- kind: 'belongsTo'
8792
+ kind: 'belongsTo',
8793
+ key: null
7982
8794
  };
7983
8795
 
7984
8796
  if (options.async) {
@@ -8031,7 +8843,7 @@ define("ember-data/lib/system/relationships/belongs_to",
8031
8843
 
8032
8844
  if (oldParent) {
8033
8845
  var store = get(record, 'store'),
8034
- change = DS.RelationshipChange.createChange(record, oldParent, store, { key: key, kind: "belongsTo", changeType: "remove" });
8846
+ change = RelationshipChange.createChange(record, oldParent, store, { key: key, kind: "belongsTo", changeType: "remove" });
8035
8847
 
8036
8848
  change.sync();
8037
8849
  this._changesToSync[key] = change;
@@ -8052,7 +8864,7 @@ define("ember-data/lib/system/relationships/belongs_to",
8052
8864
 
8053
8865
  if (newParent) {
8054
8866
  var store = get(record, 'store'),
8055
- change = DS.RelationshipChange.createChange(record, newParent, store, { key: key, kind: "belongsTo", changeType: "add" });
8867
+ change = RelationshipChange.createChange(record, newParent, store, { key: key, kind: "belongsTo", changeType: "add" });
8056
8868
 
8057
8869
  change.sync();
8058
8870
  }
@@ -8065,11 +8877,13 @@ define("ember-data/lib/system/relationships/belongs_to",
8065
8877
  __exports__["default"] = belongsTo;
8066
8878
  });
8067
8879
  define("ember-data/lib/system/relationships/ext",
8068
- ["../../../../ember-inflector/lib/system","../model"],
8069
- function(__dependency1__, __dependency2__) {
8880
+ ["../../../../ember-inflector/lib/system","../relationship-meta","../model"],
8881
+ function(__dependency1__, __dependency2__, __dependency3__) {
8070
8882
  "use strict";
8071
8883
  var singularize = __dependency1__.singularize;
8072
- var Model = __dependency2__.Model;
8884
+ var typeForRelationshipMeta = __dependency2__.typeForRelationshipMeta;
8885
+ var relationshipFromMeta = __dependency2__.relationshipFromMeta;
8886
+ var Model = __dependency3__.Model;
8073
8887
 
8074
8888
  var get = Ember.get, set = Ember.set;
8075
8889
 
@@ -8267,18 +9081,15 @@ define("ember-data/lib/system/relationships/ext",
8267
9081
  // If the computed property is a relationship, add
8268
9082
  // it to the map.
8269
9083
  if (meta.isRelationship) {
8270
- if (typeof meta.type === 'string') {
8271
- meta.type = this.store.modelFor(meta.type);
8272
- }
8273
-
8274
- var relationshipsForType = map.get(meta.type);
9084
+ meta.key = name;
9085
+ var relationshipsForType = map.get(typeForRelationshipMeta(this.store, meta));
8275
9086
 
8276
9087
  relationshipsForType.push({ name: name, kind: meta.kind });
8277
9088
  }
8278
9089
  });
8279
9090
 
8280
9091
  return map;
8281
- }),
9092
+ }).cacheable(false),
8282
9093
 
8283
9094
  /**
8284
9095
  A hash containing lists of the model's relationships, grouped
@@ -8358,11 +9169,8 @@ define("ember-data/lib/system/relationships/ext",
8358
9169
  // in relationships
8359
9170
  this.eachComputedProperty(function(name, meta) {
8360
9171
  if (meta.isRelationship) {
8361
- type = meta.type;
8362
-
8363
- if (typeof type === 'string') {
8364
- type = get(this, type, false) || this.store.modelFor(type);
8365
- }
9172
+ meta.key = name;
9173
+ type = typeForRelationshipMeta(this.store, meta);
8366
9174
 
8367
9175
 
8368
9176
  if (!types.contains(type)) {
@@ -8372,7 +9180,7 @@ define("ember-data/lib/system/relationships/ext",
8372
9180
  });
8373
9181
 
8374
9182
  return types;
8375
- }),
9183
+ }).cacheable(false),
8376
9184
 
8377
9185
  /**
8378
9186
  A map whose keys are the relationships of a model and whose values are
@@ -8406,29 +9214,19 @@ define("ember-data/lib/system/relationships/ext",
8406
9214
  @readOnly
8407
9215
  */
8408
9216
  relationshipsByName: Ember.computed(function() {
8409
- var map = Ember.Map.create(), type;
9217
+ var map = Ember.Map.create();
8410
9218
 
8411
9219
  this.eachComputedProperty(function(name, meta) {
8412
9220
  if (meta.isRelationship) {
8413
9221
  meta.key = name;
8414
- type = meta.type;
8415
-
8416
- if (!type && meta.kind === 'hasMany') {
8417
- type = singularize(name);
8418
- } else if (!type) {
8419
- type = name;
8420
- }
8421
-
8422
- if (typeof type === 'string') {
8423
- meta.type = this.store.modelFor(type);
8424
- }
8425
-
8426
- map.set(name, meta);
9222
+ var relationship = relationshipFromMeta(this.store, meta);
9223
+ relationship.type = typeForRelationshipMeta(this.store, meta);
9224
+ map.set(name, relationship);
8427
9225
  }
8428
9226
  });
8429
9227
 
8430
9228
  return map;
8431
- }),
9229
+ }).cacheable(false),
8432
9230
 
8433
9231
  /**
8434
9232
  A map whose keys are the fields of the model and whose values are strings
@@ -8529,29 +9327,34 @@ define("ember-data/lib/system/relationships/ext",
8529
9327
  });
8530
9328
  });
8531
9329
  define("ember-data/lib/system/relationships/has_many",
8532
- ["exports"],
8533
- function(__exports__) {
9330
+ ["../store","../relationship-meta","exports"],
9331
+ function(__dependency1__, __dependency2__, __exports__) {
8534
9332
  "use strict";
8535
9333
  /**
8536
9334
  @module ember-data
8537
9335
  */
8538
9336
 
9337
+ var PromiseArray = __dependency1__.PromiseArray;
8539
9338
  var get = Ember.get, set = Ember.set, setProperties = Ember.setProperties;
9339
+ var relationshipFromMeta = __dependency2__.relationshipFromMeta;
9340
+ var typeForRelationshipMeta = __dependency2__.typeForRelationshipMeta;
8540
9341
 
8541
9342
  function asyncHasMany(type, options, meta) {
8542
9343
  return Ember.computed('data', function(key) {
8543
9344
  var relationship = this._relationships[key],
8544
9345
  promiseLabel = "DS: Async hasMany " + this + " : " + key;
8545
9346
 
9347
+ meta.key = key;
9348
+
8546
9349
  if (!relationship) {
8547
9350
  var resolver = Ember.RSVP.defer(promiseLabel);
8548
9351
  relationship = buildRelationship(this, key, options, function(store, data) {
8549
9352
  var link = data.links && data.links[key];
8550
9353
  var rel;
8551
9354
  if (link) {
8552
- rel = store.findHasMany(this, link, meta, resolver);
9355
+ rel = store.findHasMany(this, link, relationshipFromMeta(store, meta), resolver);
8553
9356
  } else {
8554
- rel = store.findMany(this, data[key], meta.type, resolver);
9357
+ rel = store.findMany(this, data[key], typeForRelationshipMeta(store, meta), resolver);
8555
9358
  }
8556
9359
  // cache the promise so we can use it
8557
9360
  // when we come back and don't need to rebuild
@@ -8565,7 +9368,7 @@ define("ember-data/lib/system/relationships/has_many",
8565
9368
  return relationship;
8566
9369
  }, null, "DS: Async hasMany records received");
8567
9370
 
8568
- return DS.PromiseArray.create({
9371
+ return PromiseArray.create({
8569
9372
  promise: promise
8570
9373
  });
8571
9374
  }).meta(meta).readOnly();
@@ -8595,7 +9398,8 @@ define("ember-data/lib/system/relationships/has_many",
8595
9398
  type: type,
8596
9399
  isRelationship: true,
8597
9400
  options: options,
8598
- kind: 'hasMany'
9401
+ kind: 'hasMany',
9402
+ key: null
8599
9403
  };
8600
9404
 
8601
9405
  if (options.async) {
@@ -8605,7 +9409,7 @@ define("ember-data/lib/system/relationships/has_many",
8605
9409
  return Ember.computed('data', function(key) {
8606
9410
  return buildRelationship(this, key, options, function(store, data) {
8607
9411
  var records = data[key];
8608
- return store.findMany(this, data[key], meta.type);
9412
+ return store.findMany(this, data[key], typeForRelationshipMeta(store, meta));
8609
9413
  });
8610
9414
  }).meta(meta).readOnly();
8611
9415
  }
@@ -8699,8 +9503,8 @@ define("ember-data/lib/system/relationships/has_many",
8699
9503
  __exports__["default"] = hasMany;
8700
9504
  });
8701
9505
  define("ember-data/lib/system/store",
8702
- ["exports"],
8703
- function(__exports__) {
9506
+ ["./adapter","ember-inflector/lib/system/string","exports"],
9507
+ function(__dependency1__, __dependency2__, __exports__) {
8704
9508
  "use strict";
8705
9509
  /*globals Ember*/
8706
9510
  /*jshint eqnull:true*/
@@ -8709,6 +9513,9 @@ define("ember-data/lib/system/store",
8709
9513
  @module ember-data
8710
9514
  */
8711
9515
 
9516
+ var InvalidError = __dependency1__.InvalidError;
9517
+ var Adapter = __dependency1__.Adapter;
9518
+ var singularize = __dependency2__.singularize;
8712
9519
  var get = Ember.get, set = Ember.set;
8713
9520
  var once = Ember.run.once;
8714
9521
  var isNone = Ember.isNone;
@@ -8717,7 +9524,9 @@ define("ember-data/lib/system/store",
8717
9524
  var map = Ember.EnumerableUtils.map;
8718
9525
  var Promise = Ember.RSVP.Promise;
8719
9526
  var copy = Ember.copy;
8720
- var Store, PromiseObject, PromiseArray;
9527
+ var Store, PromiseObject, PromiseArray, RecordArrayManager, Model;
9528
+
9529
+ var camelize = Ember.String.camelize;
8721
9530
 
8722
9531
  // Implementors Note:
8723
9532
  //
@@ -8770,7 +9579,7 @@ define("ember-data/lib/system/store",
8770
9579
  specify which store should be used:
8771
9580
 
8772
9581
  ```javascript
8773
- var person = store.find(App.Person, 123);
9582
+ var person = store.find('person', 123);
8774
9583
  ```
8775
9584
 
8776
9585
  By default, the store will talk to your backend using a standard
@@ -8786,6 +9595,39 @@ define("ember-data/lib/system/store",
8786
9595
  You can learn more about writing a custom adapter by reading the `DS.Adapter`
8787
9596
  documentation.
8788
9597
 
9598
+ ### Store createRecord() vs. push() vs. pushPayload() vs. update()
9599
+
9600
+ The store provides multiple ways to create new records object. They have
9601
+ some subtle differences in their use which are detailed below:
9602
+
9603
+ [createRecord](#method_createRecord) is used for creating new
9604
+ records on the client side. This will return a new record in the
9605
+ `created.uncommitted` state. In order to persist this record to the
9606
+ backend you will need to call `record.save()`.
9607
+
9608
+ [push](#method_push) is used to notify Ember Data's store of new or
9609
+ updated records that exist in the backend. This will return a record
9610
+ in the `loaded.saved` state. The primary use-case for `store#push` is
9611
+ to notify Ember Data about record updates that happen
9612
+ outside of the normal adapter methods (for example
9613
+ [SSE](http://dev.w3.org/html5/eventsource/) or [Web
9614
+ Sockets](http://www.w3.org/TR/2009/WD-websockets-20091222/)).
9615
+
9616
+ [pushPayload](#method_pushPayload) is a convenience wrapper for
9617
+ `store#push` that will deserialize payloads if the
9618
+ Serializer implements a `pushPayload` method.
9619
+
9620
+ [update](#method_update) works like `push`, except it can handle
9621
+ partial attributes without overwriting the existing record
9622
+ properties.
9623
+
9624
+ Note: When creating a new record using any of the above methods
9625
+ Ember Data will update `DS.RecordArray`s such as those returned by
9626
+ `store#all()`, `store#findAll()` or `store#filter()`. This means any
9627
+ data bindings or computed properties that depend on the RecordArray
9628
+ will automatically be synced to include the new or updated record
9629
+ values.
9630
+
8789
9631
  @class Store
8790
9632
  @namespace DS
8791
9633
  @extends Ember.Object
@@ -8798,8 +9640,9 @@ define("ember-data/lib/system/store",
8798
9640
  */
8799
9641
  init: function() {
8800
9642
  // internal bookkeeping; not observable
9643
+ if (!RecordArrayManager) { RecordArrayManager = requireModule("ember-data/lib/system/record_array_manager")["default"]; }
8801
9644
  this.typeMaps = {};
8802
- this.recordArrayManager = DS.RecordArrayManager.create({
9645
+ this.recordArrayManager = RecordArrayManager.create({
8803
9646
  store: this
8804
9647
  });
8805
9648
  this._relationshipChanges = {};
@@ -8854,7 +9697,7 @@ define("ember-data/lib/system/store",
8854
9697
 
8855
9698
  @property defaultAdapter
8856
9699
  @private
8857
- @returns DS.Adapter
9700
+ @return DS.Adapter
8858
9701
  */
8859
9702
  defaultAdapter: Ember.computed('adapter', function() {
8860
9703
  var adapter = get(this, 'adapter');
@@ -8893,7 +9736,7 @@ define("ember-data/lib/system/store",
8893
9736
  @param {String} type
8894
9737
  @param {Object} properties a hash of properties to set on the
8895
9738
  newly created record.
8896
- @returns {DS.Model} record
9739
+ @return {DS.Model} record
8897
9740
  */
8898
9741
  createRecord: function(type, properties) {
8899
9742
  type = this.modelFor(type);
@@ -8931,7 +9774,7 @@ define("ember-data/lib/system/store",
8931
9774
  @method _generateId
8932
9775
  @private
8933
9776
  @param {String} type
8934
- @returns {String} if the adapter can generate one, an ID
9777
+ @return {String} if the adapter can generate one, an ID
8935
9778
  */
8936
9779
  _generateId: function(type) {
8937
9780
  var adapter = this.adapterFor(type);
@@ -9028,7 +9871,7 @@ define("ember-data/lib/system/store",
9028
9871
  parameter:
9029
9872
 
9030
9873
  ```javascript
9031
- store.find(App.Person, { page: 1 });
9874
+ store.find('person', { page: 1 });
9032
9875
  ```
9033
9876
 
9034
9877
  This will ask the adapter's `findQuery` method to find the records for
@@ -9080,7 +9923,7 @@ define("ember-data/lib/system/store",
9080
9923
  @method findByIds
9081
9924
  @param {String} type
9082
9925
  @param {Array} ids
9083
- @returns {Promise} promise
9926
+ @return {Promise} promise
9084
9927
  */
9085
9928
  findByIds: function(type, ids) {
9086
9929
  var store = this;
@@ -9098,7 +9941,7 @@ define("ember-data/lib/system/store",
9098
9941
  @method fetchRecord
9099
9942
  @private
9100
9943
  @param {DS.Model} record
9101
- @returns {Promise} promise
9944
+ @return {Promise} promise
9102
9945
  */
9103
9946
  fetchRecord: function(record) {
9104
9947
  if (isNone(record)) { return null; }
@@ -9179,7 +10022,9 @@ define("ember-data/lib/system/store",
9179
10022
  @return {Promise} promise
9180
10023
  */
9181
10024
  fetchMany: function(records, owner) {
9182
- if (!records.length) { return; }
10025
+ if (!records.length) {
10026
+ return Ember.RSVP.resolve(records);
10027
+ }
9183
10028
 
9184
10029
  // Group By Type
9185
10030
  var recordsByTypeMap = Ember.MapWithDefault.create({
@@ -9209,7 +10054,7 @@ define("ember-data/lib/system/store",
9209
10054
  @method hasRecordForId
9210
10055
  @param {String or subclass of DS.Model} type
9211
10056
  @param {String|Integer} id
9212
- @returns {Boolean}
10057
+ @return {Boolean}
9213
10058
  */
9214
10059
  hasRecordForId: function(type, id) {
9215
10060
  id = coerceId(id);
@@ -9225,7 +10070,7 @@ define("ember-data/lib/system/store",
9225
10070
  @private
9226
10071
  @param {String or subclass of DS.Model} type
9227
10072
  @param {String|Integer} id
9228
- @returns {DS.Model} record
10073
+ @return {DS.Model} record
9229
10074
  */
9230
10075
  recordForId: function(type, id) {
9231
10076
  type = this.modelFor(type);
@@ -9371,7 +10216,7 @@ define("ember-data/lib/system/store",
9371
10216
  @private
9372
10217
  @param {DS.Model} type
9373
10218
  @param {DS.RecordArray} array
9374
- @returns {Promise} promise
10219
+ @return {Promise} promise
9375
10220
  */
9376
10221
  fetchAll: function(type, array) {
9377
10222
  var adapter = this.adapterFor(type),
@@ -9405,7 +10250,7 @@ define("ember-data/lib/system/store",
9405
10250
  Example
9406
10251
 
9407
10252
  ```javascript
9408
- var local_posts = store.all(App.Post);
10253
+ var localPosts = store.all('post');
9409
10254
  ```
9410
10255
 
9411
10256
  @method all
@@ -9431,7 +10276,7 @@ define("ember-data/lib/system/store",
9431
10276
  This method unloads all of the known records for a given type.
9432
10277
 
9433
10278
  ```javascript
9434
- store.unloadAll(App.Post);
10279
+ store.unloadAll('post');
9435
10280
  ```
9436
10281
 
9437
10282
  @method unloadAll
@@ -9475,7 +10320,7 @@ define("ember-data/lib/system/store",
9475
10320
  Example
9476
10321
 
9477
10322
  ```javascript
9478
- store.filter(App.Post, {unread: true}, function(post) {
10323
+ store.filter('post', {unread: true}, function(post) {
9479
10324
  return post.get('unread');
9480
10325
  }).then(function(unreadPosts) {
9481
10326
  unreadPosts.get('length'); // 5
@@ -9493,9 +10338,12 @@ define("ember-data/lib/system/store",
9493
10338
  */
9494
10339
  filter: function(type, query, filter) {
9495
10340
  var promise;
10341
+ var length = arguments.length;
10342
+ var array;
10343
+ var hasQuery = length === 3;
9496
10344
 
9497
10345
  // allow an optional server query
9498
- if (arguments.length === 3) {
10346
+ if (hasQuery) {
9499
10347
  promise = this.findQuery(type, query);
9500
10348
  } else if (arguments.length === 2) {
9501
10349
  filter = query;
@@ -9503,10 +10351,15 @@ define("ember-data/lib/system/store",
9503
10351
 
9504
10352
  type = this.modelFor(type);
9505
10353
 
9506
- var array = this.recordArrayManager
9507
- .createFilteredRecordArray(type, filter);
10354
+ if (hasQuery) {
10355
+ array = this.recordArrayManager.createFilteredRecordArray(type, filter, query);
10356
+ } else {
10357
+ array = this.recordArrayManager.createFilteredRecordArray(type, filter);
10358
+ }
10359
+
9508
10360
  promise = promise || Promise.cast(array);
9509
10361
 
10362
+
9510
10363
  return promiseArray(promise.then(function() {
9511
10364
  return array;
9512
10365
  }, null, "DS: Store#filter of " + type));
@@ -9520,9 +10373,9 @@ define("ember-data/lib/system/store",
9520
10373
  Example
9521
10374
 
9522
10375
  ```javascript
9523
- store.recordIsLoaded(App.Post, 1); // false
9524
- store.find(App.Post, 1).then(function() {
9525
- store.recordIsLoaded(App.Post, 1); // true
10376
+ store.recordIsLoaded('post', 1); // false
10377
+ store.find('post', 1).then(function() {
10378
+ store.recordIsLoaded('post', 1); // true
9526
10379
  });
9527
10380
  ```
9528
10381
 
@@ -9606,7 +10459,9 @@ define("ember-data/lib/system/store",
9606
10459
  adapter = this.adapterFor(record.constructor),
9607
10460
  operation;
9608
10461
 
9609
- if (get(record, 'isNew')) {
10462
+ if (get(record, 'currentState.stateName') === 'root.deleted.saved') {
10463
+ return resolver.resolve(record);
10464
+ } else if (get(record, 'isNew')) {
9610
10465
  operation = 'createRecord';
9611
10466
  } else if (get(record, 'isDeleted')) {
9612
10467
  operation = 'deleteRecord';
@@ -9749,7 +10604,7 @@ define("ember-data/lib/system/store",
9749
10604
 
9750
10605
  @method modelFor
9751
10606
  @param {String or subclass of DS.Model} key
9752
- @returns {subclass of DS.Model}
10607
+ @return {subclass of DS.Model}
9753
10608
  */
9754
10609
  modelFor: function(key) {
9755
10610
  var factory;
@@ -9760,10 +10615,13 @@ define("ember-data/lib/system/store",
9760
10615
 
9761
10616
  factory = this.container.lookupFactory(normalizedKey);
9762
10617
  if (!factory) { throw new Ember.Error("No model was found for '" + key + "'"); }
9763
- factory.typeKey = normalizedKey.split(':', 2)[1];
10618
+ factory.typeKey = this._normalizeTypeKey(normalizedKey.split(':', 2)[1]);
9764
10619
  } else {
9765
- // A factory already supplied.
10620
+ // A factory already supplied. Ensure it has a normalized key.
9766
10621
  factory = key;
10622
+ if (factory.typeKey) {
10623
+ factory.typeKey = this._normalizeTypeKey(factory.typeKey);
10624
+ }
9767
10625
  }
9768
10626
 
9769
10627
  factory.store = this;
@@ -9828,7 +10686,7 @@ define("ember-data/lib/system/store",
9828
10686
  @method push
9829
10687
  @param {String or subclass of DS.Model} type
9830
10688
  @param {Object} data
9831
- @returns {DS.Model} the record that was created or
10689
+ @return {DS.Model} the record that was created or
9832
10690
  updated.
9833
10691
  */
9834
10692
  push: function(type, data, _partial) {
@@ -9850,13 +10708,9 @@ define("ember-data/lib/system/store",
9850
10708
  /**
9851
10709
  Push some raw data into the store.
9852
10710
 
9853
- The data will be automatically deserialized using the
9854
- serializer for the `type` param.
9855
-
9856
10711
  This method can be used both to push in brand new
9857
- records, as well as to update existing records.
9858
-
9859
- You can push in more than one type of object at once.
10712
+ records, as well as to update existing records. You
10713
+ can push in more than one type of object at once.
9860
10714
  All objects should be in the format expected by the
9861
10715
  serializer.
9862
10716
 
@@ -9872,11 +10726,27 @@ define("ember-data/lib/system/store",
9872
10726
  ]
9873
10727
  }
9874
10728
 
9875
- store.pushPayload('post', pushData);
10729
+ store.pushPayload(pushData);
10730
+ ```
10731
+
10732
+ By default, the data will be deserialized using a default
10733
+ serializer (the application serializer if it exists).
10734
+
10735
+ Alternativly, `pushPayload` will accept a model type which
10736
+ will determine which serializer will process the payload.
10737
+ However, the serializer itself (processing this data via
10738
+ `normalizePayload`) will not know which model it is
10739
+ deserializing.
10740
+
10741
+ ```js
10742
+ App.ApplicationSerializer = DS.ActiveModelSerializer;
10743
+ App.PostSerializer = DS.JSONSerializer;
10744
+ store.pushPayload('comment', pushData); // Will use the ApplicationSerializer
10745
+ store.pushPayload('post', pushData); // Will use the PostSerializer
9876
10746
  ```
9877
10747
 
9878
10748
  @method pushPayload
9879
- @param {String} type
10749
+ @param {String} type Optionally, a model used to determine which serializer will be used
9880
10750
  @param {Object} payload
9881
10751
  */
9882
10752
  pushPayload: function (type, payload) {
@@ -9890,6 +10760,38 @@ define("ember-data/lib/system/store",
9890
10760
  serializer.pushPayload(this, payload);
9891
10761
  },
9892
10762
 
10763
+ /**
10764
+ Update existing records in the store. Unlike [push](#method_push),
10765
+ update will merge the new data properties with the existing
10766
+ properties. This makes it safe to use with a subset of record
10767
+ attributes. This method expects normalized data.
10768
+
10769
+ `update` is useful if you app broadcasts partial updates to
10770
+ records.
10771
+
10772
+ ```js
10773
+ App.Person = DS.Model.extend({
10774
+ firstName: DS.attr('string'),
10775
+ lastName: DS.attr('string')
10776
+ });
10777
+
10778
+ store.get('person', 1).then(function(tom) {
10779
+ tom.get('firstName'); // Tom
10780
+ tom.get('lastName'); // Dale
10781
+
10782
+ var updateEvent = {id: 1, firstName: "TomHuda"};
10783
+ store.update('person', updateEvent);
10784
+
10785
+ tom.get('firstName'); // TomHuda
10786
+ tom.get('lastName'); // Dale
10787
+ });
10788
+ ```
10789
+
10790
+ @method update
10791
+ @param {String} type
10792
+ @param {Object} data
10793
+ @return {DS.Model} the record that was updated.
10794
+ */
9893
10795
  update: function(type, data) {
9894
10796
 
9895
10797
  return this.push(type, data, true);
@@ -9934,7 +10836,7 @@ define("ember-data/lib/system/store",
9934
10836
  @param {subclass of DS.Model} type
9935
10837
  @param {String} id
9936
10838
  @param {Object} data
9937
- @returns {DS.Model} record
10839
+ @return {DS.Model} record
9938
10840
  */
9939
10841
  buildRecord: function(type, id, data) {
9940
10842
  var typeMap = this.typeMapFor(type),
@@ -10052,7 +10954,7 @@ define("ember-data/lib/system/store",
10052
10954
  @method adapterFor
10053
10955
  @private
10054
10956
  @param {subclass of DS.Model} type
10055
- @returns DS.Adapter
10957
+ @return DS.Adapter
10056
10958
  */
10057
10959
  adapterFor: function(type) {
10058
10960
  var container = this.container, adapter;
@@ -10093,18 +10995,33 @@ define("ember-data/lib/system/store",
10093
10995
  },
10094
10996
 
10095
10997
  willDestroy: function() {
10096
- var map = this.typeMaps;
10097
- var keys = Ember.keys(map);
10998
+ var typeMaps = this.typeMaps;
10999
+ var keys = Ember.keys(typeMaps);
10098
11000
  var store = this;
10099
- var types = keys.map(byType);
11001
+
11002
+ var types = map(keys, byType);
10100
11003
 
10101
11004
  this.recordArrayManager.destroy();
10102
11005
 
10103
- types.forEach(this.unloadAll, this);
11006
+ forEach(types, this.unloadAll, this);
10104
11007
 
10105
11008
  function byType(entry) {
10106
- return map[entry].type;
11009
+ return typeMaps[entry]['type'];
10107
11010
  }
11011
+
11012
+ },
11013
+
11014
+ /**
11015
+ All typeKeys are camelCase internally. Changing this function may
11016
+ require changes to other normalization hooks (such as typeForRoot).
11017
+
11018
+ @method _normalizeTypeKey
11019
+ @private
11020
+ @param {String} type
11021
+ @return {String} if the adapter can generate one, an ID
11022
+ */
11023
+ _normalizeTypeKey: function(key) {
11024
+ return camelize(singularize(key));
10108
11025
  }
10109
11026
  });
10110
11027
 
@@ -10134,7 +11051,8 @@ define("ember-data/lib/system/store",
10134
11051
  }
10135
11052
 
10136
11053
  function deserializeRecordId(store, data, key, relationship, id) {
10137
- if (isNone(id) || id instanceof DS.Model) {
11054
+ if (!Model) { Model = requireModule("ember-data/lib/system/model")["Model"]; }
11055
+ if (isNone(id) || id instanceof Model) {
10138
11056
  return;
10139
11057
  }
10140
11058
 
@@ -10167,14 +11085,14 @@ define("ember-data/lib/system/store",
10167
11085
  // in the payload, so add them back in manually.
10168
11086
  function addUnsavedRecords(record, key, data) {
10169
11087
  if(record) {
10170
- data.pushObjects(record.get(key).filterBy('isNew'));
11088
+ Ember.A(data).pushObjects(record.get(key).filterBy('isNew'));
10171
11089
  }
10172
11090
  }
10173
11091
 
10174
11092
  // Delegation to the adapter and promise management
10175
11093
  /**
10176
11094
  A `PromiseArray` is an object that acts like both an `Ember.Array`
10177
- and a promise. When the promise is resolved the the resulting value
11095
+ and a promise. When the promise is resolved the resulting value
10178
11096
  will be set to the `PromiseArray`'s `content` property. This makes
10179
11097
  it easy to create data bindings with the `PromiseArray` that will be
10180
11098
  updated when the promise resolves.
@@ -10384,7 +11302,7 @@ define("ember-data/lib/system/store",
10384
11302
  store.didSaveRecord(record, payload);
10385
11303
  return record;
10386
11304
  }, function(reason) {
10387
- if (reason instanceof DS.InvalidError) {
11305
+ if (reason instanceof InvalidError) {
10388
11306
  store.recordWasInvalid(record, reason.errors);
10389
11307
  } else {
10390
11308
  store.recordWasError(record, reason);
@@ -10429,12 +11347,13 @@ define("ember-data/lib/transforms/base",
10429
11347
  Example
10430
11348
 
10431
11349
  ```javascript
10432
- App.RawTransform = DS.Transform.extend({
11350
+ // Converts centigrade in the JSON to fahrenheit in the app
11351
+ App.TemperatureTransform = DS.Transform.extend({
10433
11352
  deserialize: function(serialized) {
10434
- return serialized;
11353
+ return (serialized * 1.8) + 32;
10435
11354
  },
10436
11355
  serialize: function(deserialized) {
10437
- return deserialized;
11356
+ return (deserialized - 32) / 1.8;
10438
11357
  }
10439
11358
  });
10440
11359
  ```
@@ -10734,11 +11653,11 @@ define("ember-inflector/lib/main",
10734
11653
  function(__dependency1__, __dependency2__, __exports__) {
10735
11654
  "use strict";
10736
11655
  var Inflector = __dependency1__.Inflector;
10737
- var inflections = __dependency1__.inflections;
11656
+ var defaultRules = __dependency1__.defaultRules;
10738
11657
  var pluralize = __dependency1__.pluralize;
10739
11658
  var singularize = __dependency1__.singularize;
10740
11659
 
10741
- Inflector.defaultRules = inflections;
11660
+ Inflector.defaultRules = defaultRules;
10742
11661
  Ember.Inflector = Inflector;
10743
11662
 
10744
11663
  Ember.String.pluralize = pluralize;
@@ -10895,8 +11814,8 @@ define("ember-inflector/lib/system/inflector",
10895
11814
  ```js
10896
11815
  var inflector = new Ember.Inflector(Ember.Inflector.defaultRules);
10897
11816
 
10898
- inflector.pluralize('cow') //=> 'kine'
10899
- inflector.singularize('kine') //=> 'cow'
11817
+ inflector.pluralize('cow'); //=> 'kine'
11818
+ inflector.singularize('kine'); //=> 'cow'
10900
11819
  ```
10901
11820
 
10902
11821
  Creating an inflector and adding rules later.
@@ -10904,13 +11823,13 @@ define("ember-inflector/lib/system/inflector",
10904
11823
  ```javascript
10905
11824
  var inflector = Ember.Inflector.inflector;
10906
11825
 
10907
- inflector.pluralize('advice') // => 'advices'
11826
+ inflector.pluralize('advice'); // => 'advices'
10908
11827
  inflector.uncountable('advice');
10909
- inflector.pluralize('advice') // => 'advice'
11828
+ inflector.pluralize('advice'); // => 'advice'
10910
11829
 
10911
- inflector.pluralize('formula') // => 'formulas'
11830
+ inflector.pluralize('formula'); // => 'formulas'
10912
11831
  inflector.irregular('formula', 'formulae');
10913
- inflector.pluralize('formula') // => 'formulae'
11832
+ inflector.pluralize('formula'); // => 'formulae'
10914
11833
 
10915
11834
  // you would not need to add these as they are the default rules
10916
11835
  inflector.plural(/$/, 's');
@@ -11075,4 +11994,4 @@ define("ember-inflector/lib/system/string",
11075
11994
  __exports__.singularize = singularize;
11076
11995
  });
11077
11996
  global.DS = requireModule('ember-data/lib/main')['default'];
11078
- }(window));
11997
+ }(Ember.lookup));