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

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2d18a6b46c74a678b8ad472f134583fba6860ce
4
- data.tar.gz: 8ae17b5b6f4c41d7f1c9f5df951072422e52aaf3
3
+ metadata.gz: 0a906bfbb598d2bf2f3c6aa62f7f7ff61bdfb5e9
4
+ data.tar.gz: bc0c8336a35549e053eae512cdb53f42829f8e8d
5
5
  SHA512:
6
- metadata.gz: 721ca7f7997616b0caa170abb7c0b47d2b27dee1cc5d24b0f552e30934a839cfa9f47d03f3fbdc4720ae5de30134bd281e41644cb2c76011d722bed5db96f39e
7
- data.tar.gz: f9f5266c00ad6c7bd503ffaf0786b04fc2b7d76db873848e1e2918566befcd624178cf9bb5df21bd4bf6dd6997435ff98dc34c4d493be6638f358b0386623d70
6
+ metadata.gz: a8250a2041b0b784b64137378a04bef053b7f829fbbcc3a83a1467158dc5c16c4fd3fb9a1c7ab6813762cfa1718e5bb94e716bbd3e07fa43b0d79db6c5e44f7e
7
+ data.tar.gz: 0ab5b1e6106504e3af4c0a80530f0c8dbe8dc0ff2b1aef664b8d171bdc0a1c87f74e892ef3d8b1a8578840bd165ee5731fe8741944c9406dafca2cb14c1e9419
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0-beta.5
1
+ 1.0.0-beta.6
@@ -3,7 +3,7 @@
3
3
  * @copyright Copyright 2011-2014 Tilde Inc. and contributors.
4
4
  * Portions Copyright 2011 LivingSocial Inc.
5
5
  * @license Licensed under MIT license (see license.js)
6
- * @version 1.0.0-beta.5
6
+ * @version 1.0.0-beta.6
7
7
  */
8
8
 
9
9
 
@@ -45,4 +45,4 @@ var define, requireModule;
45
45
  return seen[name] = exports || value;
46
46
  };
47
47
  })();
48
- minispade.register('activemodel-adapter/initializers', "(function() {Ember.onLoad('Ember.Application', function(Application) {\n Application.initializer({\n name: \"activeModelAdapter\",\n\n initialize: function(container, application) {\n application.register('serializer:_ams', DS.ActiveModelSerializer);\n application.register('adapter:_ams', DS.ActiveModelAdapter);\n }\n });\n});\n\n})();\n//@ sourceURL=activemodel-adapter/initializers");minispade.register('activemodel-adapter', "(function() {minispade.require('activemodel-adapter/system');\nminispade.require('activemodel-adapter/initializers');\n\n})();\n//@ sourceURL=activemodel-adapter");minispade.register('activemodel-adapter/system', "(function() {minispade.require('activemodel-adapter/system/active_model_adapter');\n})();\n//@ sourceURL=activemodel-adapter/system");minispade.register('activemodel-adapter/system/active_model_adapter', "(function() {minispade.require('ember-data/adapters/rest_adapter');\nminispade.require('activemodel-adapter/system/active_model_serializer');\nminispade.require('activemodel-adapter/system/embedded_records_mixin');\n\n/**\n @module ember-data\n*/\n\nvar forEach = Ember.EnumerableUtils.forEach;\n\n/**\n The ActiveModelAdapter is a subclass of the RESTAdapter designed to integrate\n with a JSON API that uses an underscored naming convention instead of camelcasing.\n It has been designed to work out of the box with the\n [active_model_serializers](http://github.com/rails-api/active_model_serializers)\n Ruby gem.\n\n This adapter extends the DS.RESTAdapter by making consistent use of the camelization,\n decamelization and pluralization methods to normalize the serialized JSON into a\n format that is compatible with a conventional Rails backend and Ember Data.\n\n ## JSON Structure\n\n The ActiveModelAdapter expects the JSON returned from your server to follow\n the REST adapter conventions substituting underscored keys for camelcased ones.\n\n ### Conventional Names\n\n Attribute names in your JSON payload should be the underscored versions of\n the attributes in your Ember.js models.\n\n For example, if you have a `Person` model:\n\n ```js\n App.FamousPerson = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n occupation: DS.attr('string')\n });\n ```\n\n The JSON returned should look like this:\n\n ```js\n {\n \"famous_person\": {\n \"first_name\": \"Barack\",\n \"last_name\": \"Obama\",\n \"occupation\": \"President\"\n }\n }\n ```\n\n @class ActiveModelAdapter\n @constructor\n @namespace DS\n @extends DS.Adapter\n**/\n\nDS.ActiveModelAdapter = DS.RESTAdapter.extend({\n defaultSerializer: '_ams',\n /**\n The ActiveModelAdapter overrides the `pathForType` method to build\n underscored URLs by decamelizing and pluralizing the object type name.\n\n ```js\n this.pathForType(\"famousPerson\");\n //=> \"famous_people\"\n ```\n\n @method pathForType\n @param {String} type\n @returns String\n */\n pathForType: function(type) {\n var decamelized = Ember.String.decamelize(type);\n return Ember.String.pluralize(decamelized);\n },\n\n /**\n The ActiveModelAdapter overrides the `ajaxError` method\n to return a DS.InvalidError for all 422 Unprocessable Entity\n responses.\n\n A 422 HTTP response from the server generally implies that the request\n was well formed but the API was unable to process it because the\n content was not semantically correct or meaningful per the API.\n\n For more information on 422 HTTP Error code see 11.2 WebDAV RFC 4918\n https://tools.ietf.org/html/rfc4918#section-11.2\n\n @method ajaxError\n @param jqXHR\n @returns error\n */\n ajaxError: function(jqXHR) {\n var error = this._super(jqXHR);\n\n if (jqXHR && jqXHR.status === 422) {\n var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)[\"errors\"],\n errors = {};\n\n forEach(Ember.keys(jsonErrors), function(key) {\n errors[Ember.String.camelize(key)] = jsonErrors[key];\n });\n\n return new DS.InvalidError(errors);\n } else {\n return error;\n }\n }\n});\n\n})();\n//@ sourceURL=activemodel-adapter/system/active_model_adapter");minispade.register('activemodel-adapter/system/active_model_serializer', "(function() {minispade.require('ember-data/serializers/rest_serializer');\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get;\nvar forEach = Ember.EnumerableUtils.forEach;\n\nDS.ActiveModelSerializer = DS.RESTSerializer.extend({\n // SERIALIZE\n\n /**\n Converts camelcased attributes to underscored when serializing.\n\n @method keyForAttribute\n @param {String} attribute\n @returns String\n */\n keyForAttribute: function(attr) {\n return Ember.String.decamelize(attr);\n },\n\n /**\n Underscores relationship names and appends \"_id\" or \"_ids\" when serializing\n relationship keys.\n\n @method keyForRelationship\n @param {String} key\n @param {String} kind\n @returns String\n */\n keyForRelationship: function(key, kind) {\n key = Ember.String.decamelize(key);\n if (kind === \"belongsTo\") {\n return key + \"_id\";\n } else if (kind === \"hasMany\") {\n return Ember.String.singularize(key) + \"_ids\";\n } else {\n return key;\n }\n },\n\n /**\n Does not serialize hasMany relationships by default.\n */\n serializeHasMany: Ember.K,\n\n /**\n Underscores the JSON root keys when serializing.\n\n @method serializeIntoHash\n @param {Object} hash\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @param {Object} options\n */\n serializeIntoHash: function(data, type, record, options) {\n var root = Ember.String.decamelize(type.typeKey);\n data[root] = this.serialize(record, options);\n },\n\n /**\n Serializes a polymorphic type as a fully capitalized model name.\n\n @method serializePolymorphicType\n @param {DS.Model} record\n @param {Object} json\n @param relationship\n */\n serializePolymorphicType: function(record, json, relationship) {\n var key = relationship.key,\n belongsTo = get(record, key);\n key = this.keyForAttribute(key);\n json[key + \"_type\"] = Ember.String.capitalize(belongsTo.constructor.typeKey);\n },\n\n // EXTRACT\n\n /**\n Extracts the model typeKey from underscored root objects.\n\n @method typeForRoot\n @param {String} root\n @returns String the model's typeKey\n */\n typeForRoot: function(root) {\n var camelized = Ember.String.camelize(root);\n return Ember.String.singularize(camelized);\n },\n\n /**\n Add extra step to `DS.RESTSerializer.normalize` so links are\n normalized.\n\n If your payload looks like this\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"links\": { \"flagged_comments\": \"api/comments/flagged\" }\n }\n }\n ```\n The normalized version would look like this\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"links\": { \"flaggedComments\": \"api/comments/flagged\" }\n }\n }\n ```\n\n @method normalize\n @param {subclass of DS.Model} type\n @param {Object} hash\n @param {String} prop\n @returns Object\n */\n\n normalize: function(type, hash, prop) {\n this.normalizeLinks(hash);\n\n return this._super(type, hash, prop);\n },\n\n /**\n Convert `snake_cased` links to `camelCase`\n\n @method normalizeLinks\n @param {Object} hash\n */\n\n normalizeLinks: function(data){\n if (data.links) {\n var links = data.links;\n\n for (var link in links) {\n var camelizedLink = Ember.String.camelize(link);\n\n if (camelizedLink !== link) {\n links[camelizedLink] = links[link];\n delete links[link];\n }\n }\n }\n },\n\n /**\n Normalize the polymorphic type from the JSON.\n\n Normalize:\n ```js\n {\n id: \"1\"\n minion: { type: \"evil_minion\", id: \"12\"}\n }\n ```\n\n To:\n ```js\n {\n id: \"1\"\n minion: { type: \"evilMinion\", id: \"12\"}\n }\n ```\n\n @method normalizeRelationships\n @private\n */\n normalizeRelationships: function(type, hash) {\n var payloadKey, payload;\n\n if (this.keyForRelationship) {\n type.eachRelationship(function(key, relationship) {\n if (relationship.options.polymorphic) {\n payloadKey = this.keyForAttribute(key);\n payload = hash[payloadKey];\n if (payload && payload.type) {\n payload.type = this.typeForRoot(payload.type);\n } else if (payload && relationship.kind === \"hasMany\") {\n var self = this;\n forEach(payload, function(single) {\n single.type = self.typeForRoot(single.type);\n });\n }\n } else {\n payloadKey = this.keyForRelationship(key, relationship.kind);\n payload = hash[payloadKey];\n }\n\n hash[key] = payload;\n\n if (key !== payloadKey) {\n delete hash[payloadKey];\n }\n }, this);\n }\n }\n});\n\n})();\n//@ sourceURL=activemodel-adapter/system/active_model_serializer");minispade.register('activemodel-adapter/system/embedded_records_mixin', "(function() {var get = Ember.get;\nvar forEach = Ember.EnumerableUtils.forEach;\n\n/**\n The EmbeddedRecordsMixin allows you to add embedded record support to your\n serializers.\n To set up embedded records, you include the mixin into the serializer and then\n define your embedded relations.\n\n ```js\n App.PostSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n comments: {embedded: 'always'}\n }\n })\n ```\n\n Currently only `{embedded: 'always'}` records are supported.\n\n @class EmbeddedRecordsMixin\n @namespace DS\n*/\nDS.EmbeddedRecordsMixin = Ember.Mixin.create({\n\n /**\n Serialize has-may relationship when it is configured as embedded objects.\n\n @method serializeHasMany\n */\n serializeHasMany: function(record, json, relationship) {\n var key = relationship.key,\n attrs = get(this, 'attrs'),\n embed = attrs && attrs[key] && attrs[key].embedded === 'always';\n\n if (embed) {\n json[this.keyForAttribute(key)] = get(record, key).map(function(relation) {\n var data = relation.serialize(),\n primaryKey = get(this, 'primaryKey');\n\n data[primaryKey] = get(relation, primaryKey);\n\n return data;\n }, this);\n }\n },\n\n /**\n Extract embedded objects out of the payload for a single object\n and add them as sideloaded objects instead.\n\n @method extractSingle\n */\n extractSingle: function(store, primaryType, payload, recordId, requestType) {\n var root = this.keyForAttribute(primaryType.typeKey),\n partial = payload[root];\n\n updatePayloadWithEmbedded(store, this, primaryType, partial, payload);\n\n return this._super(store, primaryType, payload, recordId, requestType);\n },\n\n /**\n Extract embedded objects out of a standard payload\n and add them as sideloaded objects instead.\n\n @method extractArray\n */\n extractArray: function(store, type, payload) {\n var root = this.keyForAttribute(type.typeKey),\n partials = payload[Ember.String.pluralize(root)];\n\n forEach(partials, function(partial) {\n updatePayloadWithEmbedded(store, this, type, partial, payload);\n }, this);\n\n return this._super(store, type, payload);\n }\n});\n\nfunction updatePayloadWithEmbedded(store, serializer, type, partial, payload) {\n var attrs = get(serializer, 'attrs');\n\n if (!attrs) {\n return;\n }\n\n type.eachRelationship(function(key, relationship) {\n var expandedKey, embeddedTypeKey, attribute, ids,\n config = attrs[key],\n serializer = store.serializerFor(relationship.type.typeKey),\n primaryKey = get(serializer, \"primaryKey\");\n\n if (relationship.kind !== \"hasMany\") {\n return;\n }\n\n if (config && (config.embedded === 'always' || config.embedded === 'load')) {\n // underscore forces the embedded records to be side loaded.\n // it is needed when main type === relationship.type\n embeddedTypeKey = '_' + Ember.String.pluralize(relationship.type.typeKey);\n expandedKey = this.keyForRelationship(key, relationship.kind);\n attribute = this.keyForAttribute(key);\n ids = [];\n\n if (!partial[attribute]) {\n return;\n }\n\n payload[embeddedTypeKey] = payload[embeddedTypeKey] || [];\n\n forEach(partial[attribute], function(data) {\n var embeddedType = store.modelFor(relationship.type.typeKey);\n updatePayloadWithEmbedded(store, serializer, embeddedType, data, payload);\n ids.push(data[primaryKey]);\n payload[embeddedTypeKey].push(data);\n });\n\n partial[expandedKey] = ids;\n delete partial[attribute];\n }\n }, serializer);\n}\n})();\n//@ sourceURL=activemodel-adapter/system/embedded_records_mixin");minispade.register('ember-data/adapters', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/adapters/fixture_adapter\");\nminispade.require(\"ember-data/adapters/rest_adapter\");\n\n})();\n//@ sourceURL=ember-data/adapters");minispade.register('ember-data/adapters/fixture_adapter', "(function() {minispade.require(\"ember-data/core\");\nminispade.require(\"ember-data/system/adapter\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, fmt = Ember.String.fmt,\n indexOf = Ember.EnumerableUtils.indexOf;\n\nvar counter = 0;\n\n/**\n `DS.FixtureAdapter` is an adapter that loads records from memory.\n Its primarily used for development and testing. You can also use\n `DS.FixtureAdapter` while working on the API but are not ready to\n integrate yet. It is a fully functioning adapter. All CRUD methods\n are implemented. You can also implement query logic that a remote\n system would do. Its possible to do develop your entire application\n with `DS.FixtureAdapter`.\n\n For information on how to use the `FixtureAdapter` in your\n application please see the [FixtureAdapter\n guide](/guides/models/the-fixture-adapter/).\n\n @class FixtureAdapter\n @namespace DS\n @extends DS.Adapter\n*/\nDS.FixtureAdapter = DS.Adapter.extend({\n // by default, fixtures are already in normalized form\n serializer: null,\n\n /**\n If `simulateRemoteResponse` is `true` the `FixtureAdapter` will\n wait a number of milliseconds before resolving promises with the\n fixture values. The wait time can be configured via the `latency`\n property.\n\n @property simulateRemoteResponse\n @type {Boolean}\n @default true\n */\n simulateRemoteResponse: true,\n\n /**\n By default the `FixtureAdapter` will simulate a wait of the\n `latency` milliseconds before resolving promises with the fixture\n values. This behavior can be turned off via the\n `simulateRemoteResponse` property.\n\n @property latency\n @type {Number}\n @default 50\n */\n latency: 50,\n\n /**\n Implement this method in order to provide data associated with a type\n\n @method fixturesForType\n @param {Subclass of DS.Model} type\n @return {Array}\n */\n fixturesForType: function(type) {\n if (type.FIXTURES) {\n var fixtures = Ember.A(type.FIXTURES);\n return fixtures.map(function(fixture){\n var fixtureIdType = typeof fixture.id;\n if(fixtureIdType !== \"number\" && fixtureIdType !== \"string\"){\n throw new Error(fmt('the id property must be defined as a number or string for fixture %@', [fixture]));\n }\n fixture.id = fixture.id + '';\n return fixture;\n });\n }\n return null;\n },\n\n /**\n Implement this method in order to query fixtures data\n\n @method queryFixtures\n @param {Array} fixture\n @param {Object} query\n @param {Subclass of DS.Model} type\n @return {Promise|Array}\n */\n queryFixtures: function(fixtures, query, type) {\n Ember.assert('Not implemented: You must override the DS.FixtureAdapter::queryFixtures method to support querying the fixture store.');\n },\n\n /**\n @method updateFixtures\n @param {Subclass of DS.Model} type\n @param {Array} fixture\n */\n updateFixtures: function(type, fixture) {\n if(!type.FIXTURES) {\n type.FIXTURES = [];\n }\n\n var fixtures = type.FIXTURES;\n\n this.deleteLoadedFixture(type, fixture);\n\n fixtures.push(fixture);\n },\n\n /**\n Implement this method in order to provide json for CRUD methods\n\n @method mockJSON\n @param {Subclass of DS.Model} type\n @param {DS.Model} record\n */\n mockJSON: function(store, type, record) {\n return store.serializerFor(type).serialize(record, { includeId: true });\n },\n\n /**\n @method generateIdForRecord\n @param {DS.Store} store\n @param {DS.Model} record\n @return {String} id\n */\n generateIdForRecord: function(store) {\n return \"fixture-\" + counter++;\n },\n\n /**\n @method find\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} id\n @return {Promise} promise\n */\n find: function(store, type, id) {\n var fixtures = this.fixturesForType(type),\n fixture;\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), fixtures);\n\n if (fixtures) {\n fixture = Ember.A(fixtures).findProperty('id', id);\n }\n\n if (fixture) {\n return this.simulateRemoteCall(function() {\n return fixture;\n }, this);\n }\n },\n\n /**\n @method findMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Array} ids\n @return {Promise} promise\n */\n findMany: function(store, type, ids) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), fixtures);\n\n if (fixtures) {\n fixtures = fixtures.filter(function(item) {\n return indexOf(ids, item.id) !== -1;\n });\n }\n\n if (fixtures) {\n return this.simulateRemoteCall(function() {\n return fixtures;\n }, this);\n }\n },\n\n /**\n @private\n @method findAll\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} sinceToken\n @return {Promise} promise\n */\n findAll: function(store, type) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), fixtures);\n\n return this.simulateRemoteCall(function() {\n return fixtures;\n }, this);\n },\n\n /**\n @private\n @method findQuery\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} query\n @param {DS.AdapterPopulatedRecordArray} recordArray\n @return {Promise} promise\n */\n findQuery: function(store, type, query, array) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), fixtures);\n\n fixtures = this.queryFixtures(fixtures, query, type);\n\n if (fixtures) {\n return this.simulateRemoteCall(function() {\n return fixtures;\n }, this);\n }\n },\n\n /**\n @method createRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @return {Promise} promise\n */\n createRecord: function(store, type, record) {\n var fixture = this.mockJSON(store, type, record);\n\n this.updateFixtures(type, fixture);\n\n return this.simulateRemoteCall(function() {\n return fixture;\n }, this);\n },\n\n /**\n @method updateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @return {Promise} promise\n */\n updateRecord: function(store, type, record) {\n var fixture = this.mockJSON(store, type, record);\n\n this.updateFixtures(type, fixture);\n\n return this.simulateRemoteCall(function() {\n return fixture;\n }, this);\n },\n\n /**\n @method deleteRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @return {Promise} promise\n */\n deleteRecord: function(store, type, record) {\n var fixture = this.mockJSON(store, type, record);\n\n this.deleteLoadedFixture(type, fixture);\n\n return this.simulateRemoteCall(function() {\n // no payload in a deletion\n return null;\n });\n },\n\n /*\n @method deleteLoadedFixture\n @private\n @param type\n @param record\n */\n deleteLoadedFixture: function(type, record) {\n var existingFixture = this.findExistingFixture(type, record);\n\n if(existingFixture) {\n var index = indexOf(type.FIXTURES, existingFixture);\n type.FIXTURES.splice(index, 1);\n return true;\n }\n },\n\n /*\n @method findExistingFixture\n @private\n @param type\n @param record\n */\n findExistingFixture: function(type, record) {\n var fixtures = this.fixturesForType(type);\n var id = get(record, 'id');\n\n return this.findFixtureById(fixtures, id);\n },\n\n /*\n @method findFixtureById\n @private\n @param fixtures\n @param id\n */\n findFixtureById: function(fixtures, id) {\n return Ember.A(fixtures).find(function(r) {\n if(''+get(r, 'id') === ''+id) {\n return true;\n } else {\n return false;\n }\n });\n },\n\n /*\n @method simulateRemoteCall\n @private\n @param callback\n @param context\n */\n simulateRemoteCall: function(callback, context) {\n var adapter = this;\n\n return new Ember.RSVP.Promise(function(resolve) {\n if (get(adapter, 'simulateRemoteResponse')) {\n // Schedule with setTimeout\n Ember.run.later(function() {\n resolve(callback.call(context));\n }, get(adapter, 'latency'));\n } else {\n // Asynchronous, but at the of the runloop with zero latency\n Ember.run.schedule('actions', null, function() {\n resolve(callback.call(context));\n });\n }\n }, \"DS: FixtureAdapter#simulateRemoteCall\");\n }\n});\n\n})();\n//@ sourceURL=ember-data/adapters/fixture_adapter");minispade.register('ember-data/adapters/rest_adapter', "(function() {minispade.require(\"ember-data/core\");\nminispade.require('ember-data/system/adapter');\nminispade.require('ember-data/serializers/rest_serializer');\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar forEach = Ember.ArrayPolyfills.forEach;\n\n/**\n The REST adapter allows your store to communicate with an HTTP server by\n transmitting JSON via XHR. Most Ember.js apps that consume a JSON API\n should use the REST adapter.\n\n This adapter is designed around the idea that the JSON exchanged with\n the server should be conventional.\n\n ## JSON Structure\n\n The REST adapter expects the JSON returned from your server to follow\n these conventions.\n\n ### Object Root\n\n The JSON payload should be an object that contains the record inside a\n root property. For example, in response to a `GET` request for\n `/posts/1`, the JSON should look like this:\n\n ```js\n {\n \"post\": {\n \"title\": \"I'm Running to Reform the W3C's Tag\",\n \"author\": \"Yehuda Katz\"\n }\n }\n ```\n\n ### Conventional Names\n\n Attribute names in your JSON payload should be the camelCased versions of\n the attributes in your Ember.js models.\n\n For example, if you have a `Person` model:\n\n ```js\n App.Person = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n occupation: DS.attr('string')\n });\n ```\n\n The JSON returned should look like this:\n\n ```js\n {\n \"person\": {\n \"firstName\": \"Barack\",\n \"lastName\": \"Obama\",\n \"occupation\": \"President\"\n }\n }\n ```\n\n ## Customization\n\n ### Endpoint path customization\n\n Endpoint paths can be prefixed with a `namespace` by setting the namespace\n property on the adapter:\n\n ```js\n DS.RESTAdapter.reopen({\n namespace: 'api/1'\n });\n ```\n Requests for `App.Person` would now target `/api/1/people/1`.\n\n ### Host customization\n\n An adapter can target other hosts by setting the `host` property.\n\n ```js\n DS.RESTAdapter.reopen({\n host: 'https://api.example.com'\n });\n ```\n\n ### Headers customization\n\n Some APIs require HTTP headers, e.g. to provide an API key. An array of\n headers can be added to the adapter which are passed with every request:\n\n ```js\n DS.RESTAdapter.reopen({\n headers: {\n \"API_KEY\": \"secret key\",\n \"ANOTHER_HEADER\": \"Some header value\"\n }\n });\n ```\n\n @class RESTAdapter\n @constructor\n @namespace DS\n @extends DS.Adapter\n*/\nDS.RESTAdapter = DS.Adapter.extend({\n defaultSerializer: '_rest',\n\n\n /**\n Endpoint paths can be prefixed with a `namespace` by setting the namespace\n property on the adapter:\n\n ```javascript\n DS.RESTAdapter.reopen({\n namespace: 'api/1'\n });\n ```\n\n Requests for `App.Post` would now target `/api/1/post/`.\n\n @property namespace\n @type {String}\n */\n\n /**\n An adapter can target other hosts by setting the `host` property.\n\n ```javascript\n DS.RESTAdapter.reopen({\n host: 'https://api.example.com'\n });\n ```\n\n Requests for `App.Post` would now target `https://api.example.com/post/`.\n\n @property host\n @type {String}\n */\n\n /**\n Some APIs require HTTP headers, e.g. to provide an API key. An array of\n headers can be added to the adapter which are passed with every request:\n\n ```javascript\n DS.RESTAdapter.reopen({\n headers: {\n \"API_KEY\": \"secret key\",\n \"ANOTHER_HEADER\": \"Some header value\"\n }\n });\n ```\n\n @property headers\n @type {Object}\n */\n\n /**\n Called by the store in order to fetch the JSON for a given\n type and ID.\n\n The `find` method makes an Ajax request to a URL computed by `buildURL`, and returns a\n promise for the resulting payload.\n\n This method performs an HTTP `GET` request with the id provided as part of the querystring.\n\n @method find\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} id\n @returns {Promise} promise\n */\n find: function(store, type, id) {\n return this.ajax(this.buildURL(type.typeKey, id), 'GET');\n },\n\n /**\n Called by the store in order to fetch a JSON array for all\n of the records for a given type.\n\n The `findAll` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a\n promise for the resulting payload.\n\n @private\n @method findAll\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} sinceToken\n @returns {Promise} promise\n */\n findAll: function(store, type, sinceToken) {\n var query;\n\n if (sinceToken) {\n query = { since: sinceToken };\n }\n\n return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query });\n },\n\n /**\n Called by the store in order to fetch a JSON array for\n the records that match a particular query.\n\n The `findQuery` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a\n promise for the resulting payload.\n\n The `query` argument is a simple JavaScript object that will be passed directly\n to the server as parameters.\n\n @private\n @method findQuery\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} query\n @returns {Promise} promise\n */\n findQuery: function(store, type, query) {\n return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query });\n },\n\n /**\n Called by the store in order to fetch a JSON array for\n the unloaded records in a has-many relationship that were originally\n specified as IDs.\n\n For example, if the original payload looks like:\n\n ```js\n {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"comments\": [ 1, 2, 3 ]\n }\n ```\n\n The IDs will be passed as a URL-encoded Array of IDs, in this form:\n\n ```\n ids[]=1&ids[]=2&ids[]=3\n ```\n\n Many servers, such as Rails and PHP, will automatically convert this URL-encoded array\n into an Array for you on the server-side. If you want to encode the\n IDs, differently, just override this (one-line) method.\n\n The `findMany` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a\n promise for the resulting payload.\n\n @method findMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Array} ids\n @returns {Promise} promise\n */\n findMany: function(store, type, ids) {\n return this.ajax(this.buildURL(type.typeKey), 'GET', { data: { ids: ids } });\n },\n\n /**\n Called by the store in order to fetch a JSON array for\n the unloaded records in a has-many relationship that were originally\n specified as a URL (inside of `links`).\n\n For example, if your original payload looks like this:\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"links\": { \"comments\": \"/posts/1/comments\" }\n }\n }\n ```\n\n This method will be called with the parent record and `/posts/1/comments`.\n\n The `findHasMany` method will make an Ajax (HTTP GET) request to the originally specified URL.\n If the URL is host-relative (starting with a single slash), the\n request will use the host specified on the adapter (if any).\n\n @method findHasMany\n @param {DS.Store} store\n @param {DS.Model} record\n @param {String} url\n @returns {Promise} promise\n */\n findHasMany: function(store, record, url) {\n var host = get(this, 'host'),\n id = get(record, 'id'),\n type = record.constructor.typeKey;\n\n if (host && url.charAt(0) === '/' && url.charAt(1) !== '/') {\n url = host + url;\n }\n\n return this.ajax(this.urlPrefix(url, this.buildURL(type, id)), 'GET');\n },\n\n /**\n Called by the store in order to fetch a JSON array for\n the unloaded records in a belongs-to relationship that were originally\n specified as a URL (inside of `links`).\n\n For example, if your original payload looks like this:\n\n ```js\n {\n \"person\": {\n \"id\": 1,\n \"name\": \"Tom Dale\",\n \"links\": { \"group\": \"/people/1/group\" }\n }\n }\n ```\n\n This method will be called with the parent record and `/people/1/group`.\n\n The `findBelongsTo` method will make an Ajax (HTTP GET) request to the originally specified URL.\n\n @method findBelongsTo\n @param {DS.Store} store\n @param {DS.Model} record\n @param {String} url\n @returns {Promise} promise\n */\n findBelongsTo: function(store, record, url) {\n var id = get(record, 'id'),\n type = record.constructor.typeKey;\n\n return this.ajax(this.urlPrefix(url, this.buildURL(type, id)), 'GET');\n },\n\n /**\n Called by the store when a newly created record is\n saved via the `save` method on a model record instance.\n\n The `createRecord` method serializes the record and makes an Ajax (HTTP POST) request\n to a URL computed by `buildURL`.\n\n See `serialize` for information on how to customize the serialized form\n of a record.\n\n @method createRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @returns {Promise} promise\n */\n createRecord: function(store, type, record) {\n var data = {};\n var serializer = store.serializerFor(type.typeKey);\n\n serializer.serializeIntoHash(data, type, record, { includeId: true });\n\n return this.ajax(this.buildURL(type.typeKey), \"POST\", { data: data });\n },\n\n /**\n Called by the store when an existing record is saved\n via the `save` method on a model record instance.\n\n The `updateRecord` method serializes the record and makes an Ajax (HTTP PUT) request\n to a URL computed by `buildURL`.\n\n See `serialize` for information on how to customize the serialized form\n of a record.\n\n @method updateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @returns {Promise} promise\n */\n updateRecord: function(store, type, record) {\n var data = {};\n var serializer = store.serializerFor(type.typeKey);\n\n serializer.serializeIntoHash(data, type, record);\n\n var id = get(record, 'id');\n\n return this.ajax(this.buildURL(type.typeKey, id), \"PUT\", { data: data });\n },\n\n /**\n Called by the store when a record is deleted.\n\n The `deleteRecord` method makes an Ajax (HTTP DELETE) request to a URL computed by `buildURL`.\n\n @method deleteRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @returns {Promise} promise\n */\n deleteRecord: function(store, type, record) {\n var id = get(record, 'id');\n\n return this.ajax(this.buildURL(type.typeKey, id), \"DELETE\");\n },\n\n /**\n Builds a URL for a given type and optional ID.\n\n By default, it pluralizes the type's name (for example, 'post'\n becomes 'posts' and 'person' becomes 'people'). To override the\n pluralization see [pathForType](#method_pathForType).\n\n If an ID is specified, it adds the ID to the path generated\n for the type, separated by a `/`.\n\n @method buildURL\n @param {String} type\n @param {String} id\n @returns {String} url\n */\n buildURL: function(type, id) {\n var url = [],\n host = get(this, 'host'),\n prefix = this.urlPrefix();\n\n if (type) { url.push(this.pathForType(type)); }\n if (id) { url.push(id); }\n\n if (prefix) { url.unshift(prefix); }\n\n url = url.join('/');\n if (!host && url) { url = '/' + url; }\n\n return url;\n },\n\n /**\n @method urlPrefix\n @private\n @param {String} path\n @param {String} parentUrl\n @return {String} urlPrefix\n */\n urlPrefix: function(path, parentURL) {\n var host = get(this, 'host'),\n namespace = get(this, 'namespace'),\n url = [];\n\n if (path) {\n // Absolute path\n if (path.charAt(0) === '/') {\n if (host) {\n path = path.slice(1);\n url.push(host);\n }\n // Relative path\n } else if (!/^http(s)?:\\/\\//.test(path)) {\n url.push(parentURL);\n }\n } else {\n if (host) { url.push(host); }\n if (namespace) { url.push(namespace); }\n }\n\n if (path) {\n url.push(path);\n }\n\n return url.join('/');\n },\n\n /**\n Determines the pathname for a given type.\n\n By default, it pluralizes the type's name (for example,\n 'post' becomes 'posts' and 'person' becomes 'people').\n\n ### Pathname customization\n\n For example if you have an object LineItem with an\n endpoint of \"/line_items/\".\n\n ```js\n DS.RESTAdapter.reopen({\n pathForType: function(type) {\n var decamelized = Ember.String.decamelize(type);\n return Ember.String.pluralize(decamelized);\n };\n });\n ```\n\n @method pathForType\n @param {String} type\n @returns {String} path\n **/\n pathForType: function(type) {\n return Ember.String.pluralize(type);\n },\n\n /**\n Takes an ajax response, and returns a relavant error.\n\n Returning a `DS.InvalidError` from this method will cause the\n record to transition into the `invalid` state and make the\n `errors` object available on the record.\n\n ```javascript\n App.ApplicationAdapter = DS.RESTAdapter.extend({\n ajaxError: function(jqXHR) {\n var error = this._super(jqXHR);\n\n if (jqXHR && jqXHR.status === 422) {\n var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)[\"errors\"];\n\n return new DS.InvalidError(jsonErrors);\n } else {\n return error;\n }\n }\n });\n ```\n\n Note: As a correctness optimization, the default implementation of\n the `ajaxError` method strips out the `then` method from jquery's\n ajax response (jqXHR). This is important because the jqXHR's\n `then` method fulfills the promise with itself resulting in a\n circular \"thenable\" chain which may cause problems for some\n promise libraries.\n\n @method ajaxError\n @param {Object} jqXHR\n @return {Object} jqXHR\n */\n ajaxError: function(jqXHR) {\n if (jqXHR) {\n jqXHR.then = null;\n }\n\n return jqXHR;\n },\n\n /**\n Takes a URL, an HTTP method and a hash of data, and makes an\n HTTP request.\n\n When the server responds with a payload, Ember Data will call into `extractSingle`\n or `extractArray` (depending on whether the original query was for one record or\n many records).\n\n By default, `ajax` method has the following behavior:\n\n * It sets the response `dataType` to `\"json\"`\n * If the HTTP method is not `\"GET\"`, it sets the `Content-Type` to be\n `application/json; charset=utf-8`\n * If the HTTP method is not `\"GET\"`, it stringifies the data passed in. The\n data is the serialized record in the case of a save.\n * Registers success and failure handlers.\n\n @method ajax\n @private\n @param {String} url\n @param {String} type The request type GET, POST, PUT, DELETE ect.\n @param {Object} hash\n @return {Promise} promise\n */\n ajax: function(url, type, hash) {\n var adapter = this;\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n hash = adapter.ajaxOptions(url, type, hash);\n\n hash.success = function(json) {\n Ember.run(null, resolve, json);\n };\n\n hash.error = function(jqXHR, textStatus, errorThrown) {\n Ember.run(null, reject, adapter.ajaxError(jqXHR));\n };\n\n Ember.$.ajax(hash);\n }, \"DS: RestAdapter#ajax \" + type + \" to \" + url);\n },\n\n /**\n @method ajaxOptions\n @private\n @param {String} url\n @param {String} type The request type GET, POST, PUT, DELETE ect.\n @param {Object} hash\n @return {Object} hash\n */\n ajaxOptions: function(url, type, hash) {\n hash = hash || {};\n hash.url = url;\n hash.type = type;\n hash.dataType = 'json';\n hash.context = this;\n\n if (hash.data && type !== 'GET') {\n hash.contentType = 'application/json; charset=utf-8';\n hash.data = JSON.stringify(hash.data);\n }\n\n if (this.headers !== undefined) {\n var headers = this.headers;\n hash.beforeSend = function (xhr) {\n forEach.call(Ember.keys(headers), function(key) {\n xhr.setRequestHeader(key, headers[key]);\n });\n };\n }\n\n\n return hash;\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/adapters/rest_adapter");minispade.register('ember-data/core', "(function() {/**\n @module ember-data\n*/\n\n/**\n All Ember Data methods and functions are defined inside of this namespace.\n\n @class DS\n @static\n*/\nvar DS;\nif ('undefined' === typeof DS) {\n /**\n @property VERSION\n @type String\n @default '1.0.0-beta.5'\n @static\n */\n DS = Ember.Namespace.create({\n VERSION: '1.0.0-beta.5'\n });\n\n if ('undefined' !== typeof window) {\n window.DS = DS;\n }\n\n if (Ember.libraries) {\n Ember.libraries.registerCoreLibrary('Ember Data', DS.VERSION);\n }\n}\n\n})();\n//@ sourceURL=ember-data/core");minispade.register('ember-data/ext', "(function() {minispade.require('ember-data/ext/date');\n\n})();\n//@ sourceURL=ember-data/ext");minispade.register('ember-data/ext/date', "(function() {/**\n @module ember-data\n*/\n\n/**\n Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>\n\n © 2011 Colin Snover <http://zetafleet.com>\n\n Released under MIT license.\n\n @class Date\n @namespace Ember\n @static\n*/\nEmber.Date = Ember.Date || {};\n\nvar origParse = Date.parse, numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ];\n\n/**\n @method parse\n @param date\n*/\nEmber.Date.parse = function (date) {\n var timestamp, struct, minutesOffset = 0;\n\n // ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string\n // before falling back to any implementation-specific date parsing, so that’s what we do, even if native\n // implementations could be faster\n // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm\n if ((struct = /^(\\d{4}|[+\\-]\\d{6})(?:-(\\d{2})(?:-(\\d{2}))?)?(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(?:(Z)|([+\\-])(\\d{2})(?::(\\d{2}))?)?)?$/.exec(date))) {\n // avoid NaN timestamps caused by “undefined” values being passed to Date.UTC\n for (var i = 0, k; (k = numericKeys[i]); ++i) {\n struct[k] = +struct[k] || 0;\n }\n\n // allow undefined days and months\n struct[2] = (+struct[2] || 1) - 1;\n struct[3] = +struct[3] || 1;\n\n if (struct[8] !== 'Z' && struct[9] !== undefined) {\n minutesOffset = struct[10] * 60 + struct[11];\n\n if (struct[9] === '+') {\n minutesOffset = 0 - minutesOffset;\n }\n }\n\n timestamp = Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]);\n }\n else {\n timestamp = origParse ? origParse(date) : NaN;\n }\n\n return timestamp;\n};\n\nif (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Date) {\n Date.parse = Ember.Date.parse;\n}\n\n})();\n//@ sourceURL=ember-data/ext/date");minispade.register('ember-data/initializers', "(function() {minispade.require(\"ember-data/serializers/json_serializer\");\nminispade.require(\"ember-data/system/debug/debug_adapter\");\nminispade.require(\"ember-data/transforms/index\");\n\n/**\n @module ember-data\n*/\n\nvar set = Ember.set;\n\n/*\n This code registers an injection for Ember.Application.\n\n If an Ember.js developer defines a subclass of DS.Store on their application,\n this code will automatically instantiate it and make it available on the\n router.\n\n Additionally, after an application's controllers have been injected, they will\n each have the store made available to them.\n\n For example, imagine an Ember.js application with the following classes:\n\n App.Store = DS.Store.extend({\n adapter: 'custom'\n });\n\n App.PostsController = Ember.ArrayController.extend({\n // ...\n });\n\n When the application is initialized, `App.Store` will automatically be\n instantiated, and the instance of `App.PostsController` will have its `store`\n property set to that instance.\n\n Note that this code will only be run if the `ember-application` package is\n loaded. If Ember Data is being used in an environment other than a\n typical application (e.g., node.js where only `ember-runtime` is available),\n this code will be ignored.\n*/\n\nEmber.onLoad('Ember.Application', function(Application) {\n Application.initializer({\n name: \"store\",\n\n initialize: function(container, application) {\n application.register('store:main', application.Store || DS.Store);\n application.register('serializer:_default', DS.JSONSerializer);\n application.register('serializer:_rest', DS.RESTSerializer);\n application.register('adapter:_rest', DS.RESTAdapter);\n\n // Eagerly generate the store so defaultStore is populated.\n // TODO: Do this in a finisher hook\n container.lookup('store:main');\n }\n });\n\n Application.initializer({\n name: \"transforms\",\n before: \"store\",\n\n initialize: function(container, application) {\n application.register('transform:boolean', DS.BooleanTransform);\n application.register('transform:date', DS.DateTransform);\n application.register('transform:number', DS.NumberTransform);\n application.register('transform:string', DS.StringTransform);\n }\n });\n\n Application.initializer({\n name: \"dataAdapter\",\n before: \"store\",\n\n initialize: function(container, application) {\n application.register('dataAdapter:main', DS.DebugAdapter);\n }\n });\n\n Application.initializer({\n name: \"injectStore\",\n before: \"store\",\n\n initialize: function(container, application) {\n application.inject('controller', 'store', 'store:main');\n application.inject('route', 'store', 'store:main');\n application.inject('serializer', 'store', 'store:main');\n application.inject('dataAdapter', 'store', 'store:main');\n }\n });\n\n});\n\n})();\n//@ sourceURL=ember-data/initializers");minispade.register('ember-data', "(function() {/**\n Ember Data\n\n @module ember-data\n @main ember-data\n*/\nminispade.require(\"ember-data/core\");\nminispade.require(\"ember-data/initializers\");\nminispade.require(\"ember-data/ext\");\nminispade.require(\"ember-data/system/store\");\nminispade.require(\"ember-data/system/model\");\nminispade.require(\"ember-data/system/changes\");\nminispade.require(\"ember-data/system/relationships\");\nminispade.require(\"ember-data/system/record_arrays\");\nminispade.require(\"ember-data/system/record_array_manager\");\nminispade.require(\"ember-data/system/adapter\");\nminispade.require(\"ember-data/adapters\");\nminispade.require(\"ember-data/system/debug\");\n\n})();\n//@ sourceURL=ember-data");minispade.register('ember-data/serializers/json_serializer', "(function() {var get = Ember.get, set = Ember.set, isNone = Ember.isNone;\n\n// Simple dispatcher to support overriding the aliased\n// method in subclasses.\nfunction aliasMethod(methodName) {\n return function() {\n return this[methodName].apply(this, arguments);\n };\n}\n\n/**\n In Ember Data a Serializer is used to serialize and deserialize\n records when they are transfered in and out of an external source.\n This process involves normalizing property names, transforming\n attribute values and serializeing relationships.\n\n For maximum performance Ember Data recomends you use the\n [RESTSerializer](DS.RESTSerializer.html) or one of its subclasses.\n\n `JSONSerializer` is useful for simpler or legacy backends that may\n not support the http://jsonapi.org/ spec.\n\n @class JSONSerializer\n @namespace DS\n*/\nDS.JSONSerializer = Ember.Object.extend({\n /**\n The primaryKey is used when serializing and deserializing\n data. Ember Data always uses the `id` propery to store the id of\n the record. The external source may not always follow this\n convention. In these cases it is usesful to override the\n primaryKey property to match the primaryKey of your external\n store.\n\n Example\n\n ```javascript\n App.ApplicationSerializer = DS.JSONSerializer.extend({\n primaryKey: '_id'\n });\n ```\n\n @property primaryKey\n @type {String}\n @default 'id'\n */\n primaryKey: 'id',\n\n /**\n Given a subclass of `DS.Model` and a JSON object this method will\n iterate through each attribute of the `DS.Model` and invoke the\n `DS.Transform#deserialize` method on the matching property of the\n JSON object. This method is typically called after the\n serializer's `normalize` method.\n\n @method applyTransforms\n @private\n @param {subclass of DS.Model} type\n @param {Object} data The data to transform\n @return {Object} data The transformed data object\n */\n applyTransforms: function(type, data) {\n type.eachTransformedAttribute(function(key, type) {\n var transform = this.transformFor(type);\n data[key] = transform.deserialize(data[key]);\n }, this);\n\n return data;\n },\n\n /**\n Normalizes a part of the JSON payload returned by\n the server. You should override this method, munge the hash\n and call super if you have generic normalization to do.\n\n It takes the type of the record that is being normalized\n (as a DS.Model class), the property where the hash was\n originally found, and the hash to normalize.\n\n You can use this method, for example, to normalize underscored keys to camelized\n or other general-purpose normalizations.\n\n Example\n\n ```javascript\n App.ApplicationSerializer = DS.JSONSerializer.extend({\n normalize: function(type, hash) {\n var fields = Ember.get(type, 'fields');\n fields.forEach(function(field) {\n var payloadField = Ember.String.underscore(field);\n if (field === payloadField) { return; }\n\n hash[field] = hash[payloadField];\n delete hash[payloadField];\n });\n return this._super.apply(this, arguments);\n }\n });\n ```\n\n @method normalize\n @param {subclass of DS.Model} type\n @param {Object} hash\n @return {Object}\n */\n normalize: function(type, hash) {\n if (!hash) { return hash; }\n\n this.applyTransforms(type, hash);\n return hash;\n },\n\n // SERIALIZE\n /**\n Called when a record is saved in order to convert the\n record into JSON.\n\n By default, it creates a JSON object with a key for\n each attribute and belongsTo relationship.\n\n For example, consider this model:\n\n ```javascript\n App.Comment = DS.Model.extend({\n title: DS.attr(),\n body: DS.attr(),\n\n author: DS.belongsTo('user')\n });\n ```\n\n The default serialization would create a JSON object like:\n\n ```javascript\n {\n \"title\": \"Rails is unagi\",\n \"body\": \"Rails? Omakase? O_O\",\n \"author\": 12\n }\n ```\n\n By default, attributes are passed through as-is, unless\n you specified an attribute type (`DS.attr('date')`). If\n you specify a transform, the JavaScript value will be\n serialized when inserted into the JSON hash.\n\n By default, belongs-to relationships are converted into\n IDs when inserted into the JSON hash.\n\n ## IDs\n\n `serialize` takes an options hash with a single option:\n `includeId`. If this option is `true`, `serialize` will,\n by default include the ID in the JSON object it builds.\n\n The adapter passes in `includeId: true` when serializing\n a record for `createRecord`, but not for `updateRecord`.\n\n ## Customization\n\n Your server may expect a different JSON format than the\n built-in serialization format.\n\n In that case, you can implement `serialize` yourself and\n return a JSON hash of your choosing.\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n serialize: function(post, options) {\n var json = {\n POST_TTL: post.get('title'),\n POST_BDY: post.get('body'),\n POST_CMS: post.get('comments').mapProperty('id')\n }\n\n if (options.includeId) {\n json.POST_ID_ = post.get('id');\n }\n\n return json;\n }\n });\n ```\n\n ## Customizing an App-Wide Serializer\n\n If you want to define a serializer for your entire\n application, you'll probably want to use `eachAttribute`\n and `eachRelationship` on the record.\n\n ```javascript\n App.ApplicationSerializer = DS.JSONSerializer.extend({\n serialize: function(record, options) {\n var json = {};\n\n record.eachAttribute(function(name) {\n json[serverAttributeName(name)] = record.get(name);\n })\n\n record.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'hasMany') {\n json[serverHasManyName(name)] = record.get(name).mapBy('id');\n }\n });\n\n if (options.includeId) {\n json.ID_ = record.get('id');\n }\n\n return json;\n }\n });\n\n function serverAttributeName(attribute) {\n return attribute.underscore().toUpperCase();\n }\n\n function serverHasManyName(name) {\n return serverAttributeName(name.singularize()) + \"_IDS\";\n }\n ```\n\n This serializer will generate JSON that looks like this:\n\n ```javascript\n {\n \"TITLE\": \"Rails is omakase\",\n \"BODY\": \"Yep. Omakase.\",\n \"COMMENT_IDS\": [ 1, 2, 3 ]\n }\n ```\n\n ## Tweaking the Default JSON\n\n If you just want to do some small tweaks on the default JSON,\n you can call super first and make the tweaks on the returned\n JSON.\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n serialize: function(record, options) {\n var json = this._super.apply(this, arguments);\n\n json.subject = json.title;\n delete json.title;\n\n return json;\n }\n });\n ```\n\n @method serialize\n @param {subclass of DS.Model} record\n @param {Object} options\n @return {Object} json\n */\n serialize: function(record, options) {\n var json = {};\n\n if (options && options.includeId) {\n var id = get(record, 'id');\n\n if (id) {\n json[get(this, 'primaryKey')] = id;\n }\n }\n\n record.eachAttribute(function(key, attribute) {\n this.serializeAttribute(record, json, key, attribute);\n }, this);\n\n record.eachRelationship(function(key, relationship) {\n if (relationship.kind === 'belongsTo') {\n this.serializeBelongsTo(record, json, relationship);\n } else if (relationship.kind === 'hasMany') {\n this.serializeHasMany(record, json, relationship);\n }\n }, this);\n\n return json;\n },\n\n /**\n `serializeAttribute` can be used to customize how `DS.attr`\n properties are serialized\n\n For example if you wanted to ensure all you attributes were always\n serialized as properties on an `attributes` object you could\n write:\n\n ```javascript\n App.ApplicationSerializer = DS.JSONSerializer.extend({\n serializeAttribute: function(record, json, key, attributes) {\n json.attributes = json.attributes || {};\n this._super(record, json.attributes, key, attributes);\n }\n });\n ```\n\n @method serializeAttribute\n @param {DS.Model} record\n @param {Object} json\n @param {String} key\n @param {Object} attribute\n */\n serializeAttribute: function(record, json, key, attribute) {\n var attrs = get(this, 'attrs');\n var value = get(record, key), type = attribute.type;\n\n if (type) {\n var transform = this.transformFor(type);\n value = transform.serialize(value);\n }\n\n // if provided, use the mapping provided by `attrs` in\n // the serializer\n key = attrs && attrs[key] || (this.keyForAttribute ? this.keyForAttribute(key) : key);\n\n json[key] = value;\n },\n\n /**\n `serializeBelongsTo` can be used to customize how `DS.belongsTo`\n properties are serialized.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n serializeBelongsTo: function(record, json, relationship) {\n var key = relationship.key;\n\n var belongsTo = get(record, key);\n\n key = this.keyForRelationship ? this.keyForRelationship(key, \"belongsTo\") : key;\n\n json[key] = Ember.isNone(belongsTo) ? belongsTo : belongsTo.toJSON();\n }\n });\n ```\n\n @method serializeBelongsTo\n @param {DS.Model} record\n @param {Object} json\n @param {Object} relationship\n */\n serializeBelongsTo: function(record, json, relationship) {\n var key = relationship.key;\n\n var belongsTo = get(record, key);\n\n key = this.keyForRelationship ? this.keyForRelationship(key, \"belongsTo\") : key;\n\n if (isNone(belongsTo)) {\n json[key] = belongsTo;\n } else {\n json[key] = get(belongsTo, 'id');\n }\n\n if (relationship.options.polymorphic) {\n this.serializePolymorphicType(record, json, relationship);\n }\n },\n\n /**\n `serializeHasMany` can be used to customize how `DS.hasMany`\n properties are serialized.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n serializeHasMany: function(record, json, relationship) {\n var key = relationship.key;\n if (key === 'comments') {\n return;\n } else {\n this._super.apply(this, arguments);\n }\n }\n });\n ```\n\n @method serializeHasMany\n @param {DS.Model} record\n @param {Object} json\n @param {Object} relationship\n */\n serializeHasMany: function(record, json, relationship) {\n var key = relationship.key;\n\n var relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship);\n\n if (relationshipType === 'manyToNone' || relationshipType === 'manyToMany') {\n json[key] = get(record, key).mapBy('id');\n // TODO support for polymorphic manyToNone and manyToMany relationships\n }\n },\n\n /**\n You can use this method to customize how polymorphic objects are\n serialized. Objects are considered to be polymorphic if\n `{polymorphic: true}` is pass as the second argument to the\n `DS.belongsTo` function.\n\n Example\n\n ```javascript\n App.CommentSerializer = DS.JSONSerializer.extend({\n serializePolymorphicType: function(record, json, relationship) {\n var key = relationship.key,\n belongsTo = get(record, key);\n key = this.keyForAttribute ? this.keyForAttribute(key) : key;\n json[key + \"_type\"] = belongsTo.constructor.typeKey;\n }\n });\n ```\n\n @method serializePolymorphicType\n @param {DS.Model} record\n @param {Object} json\n @param {Object} relationship\n */\n serializePolymorphicType: Ember.K,\n\n // EXTRACT\n\n /**\n The `extract` method is used to deserialize payload data from the\n server. By default the `JSONSerializer` does not push the records\n into the store. However records that subclass `JSONSerializer`\n such as the `RESTSerializer` may push records into the store as\n part of the extract call.\n\n This method deletegates to a more specific extract method based on\n the `requestType`.\n\n Example\n\n ```javascript\n var get = Ember.get;\n socket.on('message', function(message) {\n var modelName = message.model;\n var data = message.data;\n var type = store.modelFor(modelName);\n var serializer = store.serializerFor(type.typeKey);\n var record = serializer.extract(store, type, data, get(data, 'id'), 'single');\n store.push(modelName, record);\n });\n ```\n\n @method extract\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @param {String or Number} id\n @param {String} requestType\n @return {Object} json The deserialized payload\n */\n extract: function(store, type, payload, id, requestType) {\n this.extractMeta(store, type, payload);\n\n var specificExtract = \"extract\" + requestType.charAt(0).toUpperCase() + requestType.substr(1);\n return this[specificExtract](store, type, payload, id, requestType);\n },\n\n /**\n `extractFindAll` is a hook into the extract method used when a\n call is made to `DS.Store#findAll`. By default this method is an\n alias for [extractArray](#method_extractArray).\n\n @method extractFindAll\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractFindAll: aliasMethod('extractArray'),\n /**\n `extractFindQuery` is a hook into the extract method used when a\n call is made to `DS.Store#findQuery`. By default this method is an\n alias for [extractArray](#method_extractArray).\n\n @method extractFindQuery\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractFindQuery: aliasMethod('extractArray'),\n /**\n `extractFindMany` is a hook into the extract method used when a\n call is made to `DS.Store#findMany`. By default this method is\n alias for [extractArray](#method_extractArray).\n\n @method extractFindMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractFindMany: aliasMethod('extractArray'),\n /**\n `extractFindHasMany` is a hook into the extract method used when a\n call is made to `DS.Store#findHasMany`. By default this method is\n alias for [extractArray](#method_extractArray).\n\n @method extractFindHasMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractFindHasMany: aliasMethod('extractArray'),\n\n /**\n `extractCreateRecord` is a hook into the extract method used when a\n call is made to `DS.Store#createRecord`. By default this method is\n alias for [extractSave](#method_extractSave).\n\n @method extractCreateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractCreateRecord: aliasMethod('extractSave'),\n /**\n `extractUpdateRecord` is a hook into the extract method used when\n a call is made to `DS.Store#update`. By default this method is alias\n for [extractSave](#method_extractSave).\n\n @method extractUpdateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractUpdateRecord: aliasMethod('extractSave'),\n /**\n `extractDeleteRecord` is a hook into the extract method used when\n a call is made to `DS.Store#deleteRecord`. By default this method is\n alias for [extractSave](#method_extractSave).\n\n @method extractDeleteRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractDeleteRecord: aliasMethod('extractSave'),\n\n /**\n `extractFind` is a hook into the extract method used when\n a call is made to `DS.Store#find`. By default this method is\n alias for [extractSingle](#method_extractSingle).\n\n @method extractFind\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractFind: aliasMethod('extractSingle'),\n /**\n `extractFindBelongsTo` is a hook into the extract method used when\n a call is made to `DS.Store#findBelongsTo`. By default this method is\n alias for [extractSingle](#method_extractSingle).\n\n @method extractFindBelongsTo\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractFindBelongsTo: aliasMethod('extractSingle'),\n /**\n `extractSave` is a hook into the extract method used when a call\n is made to `DS.Model#save`. By default this method is alias\n for [extractSingle](#method_extractSingle).\n\n @method extractSave\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractSave: aliasMethod('extractSingle'),\n\n /**\n `extractSingle` is used to deserialize a single record returned\n from the adapter.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n extractSingle: function(store, type, payload) {\n payload.comments = payload._embedded.comment;\n delete payload._embedded;\n\n return this._super(store, type, payload);\n },\n });\n ```\n\n @method extractSingle\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractSingle: function(store, type, payload) {\n return this.normalize(type, payload);\n },\n\n /**\n `extractArray` is used to deserialize an array of records\n returned from the adapter.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n extractArray: function(store, type, payload) {\n return payload.map(function(json) {\n return this.extractSingle(json);\n }, this);\n }\n });\n ```\n\n @method extractArray\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractArray: function(store, type, payload) {\n return this.normalize(type, payload);\n },\n\n /**\n `extractMeta` is used to deserialize any meta information in the\n adapter payload. By default Ember Data expects meta information to\n be located on the `meta` property of the payload object.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n extractMeta: function(store, type, payload) {\n if (payload && payload._pagination) {\n store.metaForType(type, payload._pagination);\n delete payload._pagination;\n }\n }\n });\n ```\n\n @method extractMeta\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n */\n extractMeta: function(store, type, payload) {\n if (payload && payload.meta) {\n store.metaForType(type, payload.meta);\n delete payload.meta;\n }\n },\n\n /**\n `keyForAttribute` can be used to define rules for how to convert an\n attribute name in your model to a key in your JSON.\n\n Example\n\n ```javascript\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n keyForAttribute: function(attr) {\n return Ember.String.underscore(attr).toUpperCase();\n }\n });\n ```\n\n @method keyForAttribute\n @param {String} key\n @return {String} normalized key\n */\n\n\n /**\n `keyForRelationship` can be used to define a custom key when\n serializeing relationship properties. By default `JSONSerializer`\n does not provide an implementation of this method.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n keyForRelationship: function(key, relationship) {\n return 'rel_' + Ember.String.underscore(key);\n }\n });\n ```\n\n @method keyForRelationship\n @param {String} key\n @param {String} relationship type\n @return {String} normalized key\n */\n\n // HELPERS\n\n /**\n @method transformFor\n @private\n @param {String} attributeType\n @param {Boolean} skipAssertion\n @return {DS.Transform} transform\n */\n transformFor: function(attributeType, skipAssertion) {\n var transform = this.container.lookup('transform:' + attributeType);\n Ember.assert(\"Unable to find transform for '\" + attributeType + \"'\", skipAssertion || !!transform);\n return transform;\n }\n});\n\n})();\n//@ sourceURL=ember-data/serializers/json_serializer");minispade.register('ember-data/serializers/rest_serializer', "(function() {minispade.require('ember-data/serializers/json_serializer');\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar forEach = Ember.ArrayPolyfills.forEach;\nvar map = Ember.ArrayPolyfills.map;\n\nfunction coerceId(id) {\n return id == null ? null : id+'';\n}\n\n/**\n Normally, applications will use the `RESTSerializer` by implementing\n the `normalize` method and individual normalizations under\n `normalizeHash`.\n\n This allows you to do whatever kind of munging you need, and is\n especially useful if your server is inconsistent and you need to\n do munging differently for many different kinds of responses.\n\n See the `normalize` documentation for more information.\n\n ## Across the Board Normalization\n\n There are also a number of hooks that you might find useful to defined\n across-the-board rules for your payload. These rules will be useful\n if your server is consistent, or if you're building an adapter for\n an infrastructure service, like Parse, and want to encode service\n conventions.\n\n For example, if all of your keys are underscored and all-caps, but\n otherwise consistent with the names you use in your models, you\n can implement across-the-board rules for how to convert an attribute\n name in your model to a key in your JSON.\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n keyForAttribute: function(attr) {\n return Ember.String.underscore(attr).toUpperCase();\n }\n });\n ```\n\n You can also implement `keyForRelationship`, which takes the name\n of the relationship as the first parameter, and the kind of\n relationship (`hasMany` or `belongsTo`) as the second parameter.\n\n @class RESTSerializer\n @namespace DS\n @extends DS.JSONSerializer\n*/\nDS.RESTSerializer = DS.JSONSerializer.extend({\n /**\n If you want to do normalizations specific to some part of the payload, you\n can specify those under `normalizeHash`.\n\n For example, given the following json where the the `IDs` under\n `\"comments\"` are provided as `_id` instead of `id`.\n\n ```javascript\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"comments\": [ 1, 2 ]\n },\n \"comments\": [{\n \"_id\": 1,\n \"body\": \"FIRST\"\n }, {\n \"_id\": 2,\n \"body\": \"Rails is unagi\"\n }]\n }\n ```\n\n You use `normalizeHash` to normalize just the comments:\n\n ```javascript\n App.PostSerializer = DS.RESTSerializer.extend({\n normalizeHash: {\n comments: function(hash) {\n hash.id = hash._id;\n delete hash._id;\n return hash;\n }\n }\n });\n ```\n\n The key under `normalizeHash` is usually just the original key\n that was in the original payload. However, key names will be\n impacted by any modifications done in the `normalizePayload`\n method. The `DS.RESTSerializer`'s default implemention makes no\n changes to the payload keys.\n\n @property normalizeHash\n @type {Object}\n @default undefined\n */\n\n /**\n Normalizes a part of the JSON payload returned by\n the server. You should override this method, munge the hash\n and call super if you have generic normalization to do.\n\n It takes the type of the record that is being normalized\n (as a DS.Model class), the property where the hash was\n originally found, and the hash to normalize.\n\n For example, if you have a payload that looks like this:\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"comments\": [ 1, 2 ]\n },\n \"comments\": [{\n \"id\": 1,\n \"body\": \"FIRST\"\n }, {\n \"id\": 2,\n \"body\": \"Rails is unagi\"\n }]\n }\n ```\n\n The `normalize` method will be called three times:\n\n * With `App.Post`, `\"posts\"` and `{ id: 1, title: \"Rails is omakase\", ... }`\n * With `App.Comment`, `\"comments\"` and `{ id: 1, body: \"FIRST\" }`\n * With `App.Comment`, `\"comments\"` and `{ id: 2, body: \"Rails is unagi\" }`\n\n You can use this method, for example, to normalize underscored keys to camelized\n or other general-purpose normalizations.\n\n If you want to do normalizations specific to some part of the payload, you\n can specify those under `normalizeHash`.\n\n For example, if the `IDs` under `\"comments\"` are provided as `_id` instead of\n `id`, you can specify how to normalize just the comments:\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n normalizeHash: {\n comments: function(hash) {\n hash.id = hash._id;\n delete hash._id;\n return hash;\n }\n }\n });\n ```\n\n The key under `normalizeHash` is just the original key that was in the original\n payload.\n\n @method normalize\n @param {subclass of DS.Model} type\n @param {Object} hash\n @param {String} prop\n @returns {Object}\n */\n normalize: function(type, hash, prop) {\n this.normalizeId(hash);\n this.normalizeAttributes(type, hash);\n this.normalizeRelationships(type, hash);\n\n this.normalizeUsingDeclaredMapping(type, hash);\n\n if (this.normalizeHash && this.normalizeHash[prop]) {\n this.normalizeHash[prop](hash);\n }\n\n return this._super(type, hash, prop);\n },\n\n /**\n You can use this method to normalize all payloads, regardless of whether they\n represent single records or an array.\n\n For example, you might want to remove some extraneous data from the payload:\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n normalizePayload: function(type, payload) {\n delete payload.version;\n delete payload.status;\n return payload;\n }\n });\n ```\n\n @method normalizePayload\n @param {subclass of DS.Model} type\n @param {Object} hash\n @returns {Object} the normalized payload\n */\n normalizePayload: function(type, payload) {\n return payload;\n },\n\n /**\n @method normalizeId\n @private\n */\n normalizeId: function(hash) {\n var primaryKey = get(this, 'primaryKey');\n\n if (primaryKey === 'id') { return; }\n\n hash.id = hash[primaryKey];\n delete hash[primaryKey];\n },\n\n /**\n @method normalizeUsingDeclaredMapping\n @private\n */\n normalizeUsingDeclaredMapping: function(type, hash) {\n var attrs = get(this, 'attrs'), payloadKey, key;\n\n if (attrs) {\n for (key in attrs) {\n payloadKey = attrs[key];\n if (payloadKey && payloadKey.key) {\n payloadKey = payloadKey.key;\n }\n if (typeof payloadKey === 'string') {\n hash[key] = hash[payloadKey];\n delete hash[payloadKey];\n }\n }\n }\n },\n\n /**\n @method normalizeAttributes\n @private\n */\n normalizeAttributes: function(type, hash) {\n var payloadKey, key;\n\n if (this.keyForAttribute) {\n type.eachAttribute(function(key) {\n payloadKey = this.keyForAttribute(key);\n if (key === payloadKey) { return; }\n\n hash[key] = hash[payloadKey];\n delete hash[payloadKey];\n }, this);\n }\n },\n\n /**\n @method normalizeRelationships\n @private\n */\n normalizeRelationships: function(type, hash) {\n var payloadKey, key;\n\n if (this.keyForRelationship) {\n type.eachRelationship(function(key, relationship) {\n payloadKey = this.keyForRelationship(key, relationship.kind);\n if (key === payloadKey) { return; }\n\n hash[key] = hash[payloadKey];\n delete hash[payloadKey];\n }, this);\n }\n },\n\n /**\n Called when the server has returned a payload representing\n a single record, such as in response to a `find` or `save`.\n\n It is your opportunity to clean up the server's response into the normalized\n form expected by Ember Data.\n\n If you want, you can just restructure the top-level of your payload, and\n do more fine-grained normalization in the `normalize` method.\n\n For example, if you have a payload like this in response to a request for\n post 1:\n\n ```js\n {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n\n \"_embedded\": {\n \"comment\": [{\n \"_id\": 1,\n \"comment_title\": \"FIRST\"\n }, {\n \"_id\": 2,\n \"comment_title\": \"Rails is unagi\"\n }]\n }\n }\n ```\n\n You could implement a serializer that looks like this to get your payload\n into shape:\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n // First, restructure the top-level so it's organized by type\n extractSingle: function(store, type, payload, id, requestType) {\n var comments = payload._embedded.comment;\n delete payload._embedded;\n\n payload = { comments: comments, post: payload };\n return this._super(store, type, payload, id, requestType);\n },\n\n normalizeHash: {\n // Next, normalize individual comments, which (after `extract`)\n // are now located under `comments`\n comments: function(hash) {\n hash.id = hash._id;\n hash.title = hash.comment_title;\n delete hash._id;\n delete hash.comment_title;\n return hash;\n }\n }\n })\n ```\n\n When you call super from your own implementation of `extractSingle`, the\n built-in implementation will find the primary record in your normalized\n payload and push the remaining records into the store.\n\n The primary record is the single hash found under `post` or the first\n element of the `posts` array.\n\n The primary record has special meaning when the record is being created\n for the first time or updated (`createRecord` or `updateRecord`). In\n particular, it will update the properties of the record that was saved.\n\n @method extractSingle\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @param {String} id\n @param {'find'|'createRecord'|'updateRecord'|'deleteRecord'} requestType\n @returns {Object} the primary response to the original request\n */\n extractSingle: function(store, primaryType, payload, recordId, requestType) {\n payload = this.normalizePayload(primaryType, payload);\n\n var primaryTypeName = primaryType.typeKey,\n primaryRecord;\n\n for (var prop in payload) {\n var typeName = this.typeForRoot(prop),\n isPrimary = typeName === primaryTypeName;\n\n // legacy support for singular resources\n if (isPrimary && Ember.typeOf(payload[prop]) !== \"array\" ) {\n primaryRecord = this.normalize(primaryType, payload[prop], prop);\n continue;\n }\n\n var type = store.modelFor(typeName);\n\n /*jshint loopfunc:true*/\n forEach.call(payload[prop], function(hash) {\n var typeName = this.typeForRoot(prop),\n type = store.modelFor(typeName),\n typeSerializer = store.serializerFor(type);\n\n hash = typeSerializer.normalize(type, hash, prop);\n\n var isFirstCreatedRecord = isPrimary && !recordId && !primaryRecord,\n isUpdatedRecord = isPrimary && coerceId(hash.id) === recordId;\n\n // find the primary record.\n //\n // It's either:\n // * the record with the same ID as the original request\n // * in the case of a newly created record that didn't have an ID, the first\n // record in the Array\n if (isFirstCreatedRecord || isUpdatedRecord) {\n primaryRecord = hash;\n } else {\n store.push(typeName, hash);\n }\n }, this);\n }\n\n return primaryRecord;\n },\n\n /**\n Called when the server has returned a payload representing\n multiple records, such as in response to a `findAll` or `findQuery`.\n\n It is your opportunity to clean up the server's response into the normalized\n form expected by Ember Data.\n\n If you want, you can just restructure the top-level of your payload, and\n do more fine-grained normalization in the `normalize` method.\n\n For example, if you have a payload like this in response to a request for\n all posts:\n\n ```js\n {\n \"_embedded\": {\n \"post\": [{\n \"id\": 1,\n \"title\": \"Rails is omakase\"\n }, {\n \"id\": 2,\n \"title\": \"The Parley Letter\"\n }],\n \"comment\": [{\n \"_id\": 1,\n \"comment_title\": \"Rails is unagi\"\n \"post_id\": 1\n }, {\n \"_id\": 2,\n \"comment_title\": \"Don't tread on me\",\n \"post_id\": 2\n }]\n }\n }\n ```\n\n You could implement a serializer that looks like this to get your payload\n into shape:\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n // First, restructure the top-level so it's organized by type\n // and the comments are listed under a post's `comments` key.\n extractArray: function(store, type, payload, id, requestType) {\n var posts = payload._embedded.post;\n var comments = [];\n var postCache = {};\n\n posts.forEach(function(post) {\n post.comments = [];\n postCache[post.id] = post;\n });\n\n payload._embedded.comment.forEach(function(comment) {\n comments.push(comment);\n postCache[comment.post_id].comments.push(comment);\n delete comment.post_id;\n }\n\n payload = { comments: comments, posts: payload };\n\n return this._super(store, type, payload, id, requestType);\n },\n\n normalizeHash: {\n // Next, normalize individual comments, which (after `extract`)\n // are now located under `comments`\n comments: function(hash) {\n hash.id = hash._id;\n hash.title = hash.comment_title;\n delete hash._id;\n delete hash.comment_title;\n return hash;\n }\n }\n })\n ```\n\n When you call super from your own implementation of `extractArray`, the\n built-in implementation will find the primary array in your normalized\n payload and push the remaining records into the store.\n\n The primary array is the array found under `posts`.\n\n The primary record has special meaning when responding to `findQuery`\n or `findHasMany`. In particular, the primary array will become the\n list of records in the record array that kicked off the request.\n\n If your primary array contains secondary (embedded) records of the same type,\n you cannot place these into the primary array `posts`. Instead, place the\n secondary items into an underscore prefixed property `_posts`, which will\n push these items into the store and will not affect the resulting query.\n\n @method extractArray\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @param {'findAll'|'findMany'|'findHasMany'|'findQuery'} requestType\n @returns {Array} The primary array that was returned in response\n to the original query.\n */\n extractArray: function(store, primaryType, payload) {\n payload = this.normalizePayload(primaryType, payload);\n\n var primaryTypeName = primaryType.typeKey,\n primaryArray;\n\n for (var prop in payload) {\n var typeKey = prop,\n forcedSecondary = false;\n\n if (prop.charAt(0) === '_') {\n forcedSecondary = true;\n typeKey = prop.substr(1);\n }\n\n var typeName = this.typeForRoot(typeKey),\n type = store.modelFor(typeName),\n typeSerializer = store.serializerFor(type),\n isPrimary = (!forcedSecondary && (typeName === primaryTypeName));\n\n /*jshint loopfunc:true*/\n var normalizedArray = map.call(payload[prop], function(hash) {\n return typeSerializer.normalize(type, hash, prop);\n }, this);\n\n if (isPrimary) {\n primaryArray = normalizedArray;\n } else {\n store.pushMany(typeName, normalizedArray);\n }\n }\n\n return primaryArray;\n },\n\n /**\n This method allows you to push a payload containing top-level\n collections of records organized per type.\n\n ```js\n {\n \"posts\": [{\n \"id\": \"1\",\n \"title\": \"Rails is omakase\",\n \"author\", \"1\",\n \"comments\": [ \"1\" ]\n }],\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"FIRST\"\n }],\n \"users\": [{\n \"id\": \"1\",\n \"name\": \"@d2h\"\n }]\n }\n ```\n\n It will first normalize the payload, so you can use this to push\n in data streaming in from your server structured the same way\n that fetches and saves are structured.\n\n @method pushPayload\n @param {DS.Store} store\n @param {Object} payload\n */\n pushPayload: function(store, payload) {\n payload = this.normalizePayload(null, payload);\n\n for (var prop in payload) {\n var typeName = this.typeForRoot(prop),\n type = store.modelFor(typeName);\n\n /*jshint loopfunc:true*/\n var normalizedArray = map.call(Ember.makeArray(payload[prop]), function(hash) {\n return this.normalize(type, hash, prop);\n }, this);\n\n store.pushMany(typeName, normalizedArray);\n }\n },\n\n /**\n You can use this method to normalize the JSON root keys returned\n into the model type expected by your store.\n\n For example, your server may return underscored root keys rather than\n the expected camelcased versions.\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n typeForRoot: function(root) {\n var camelized = Ember.String.camelize(root);\n return Ember.String.singularize(camelized);\n }\n });\n ```\n\n @method typeForRoot\n @param {String} root\n @returns {String} the model's typeKey\n */\n typeForRoot: function(root) {\n return Ember.String.singularize(root);\n },\n\n // SERIALIZE\n\n /**\n Called when a record is saved in order to convert the\n record into JSON.\n\n By default, it creates a JSON object with a key for\n each attribute and belongsTo relationship.\n\n For example, consider this model:\n\n ```js\n App.Comment = DS.Model.extend({\n title: DS.attr(),\n body: DS.attr(),\n\n author: DS.belongsTo('user')\n });\n ```\n\n The default serialization would create a JSON object like:\n\n ```js\n {\n \"title\": \"Rails is unagi\",\n \"body\": \"Rails? Omakase? O_O\",\n \"author\": 12\n }\n ```\n\n By default, attributes are passed through as-is, unless\n you specified an attribute type (`DS.attr('date')`). If\n you specify a transform, the JavaScript value will be\n serialized when inserted into the JSON hash.\n\n By default, belongs-to relationships are converted into\n IDs when inserted into the JSON hash.\n\n ## IDs\n\n `serialize` takes an options hash with a single option:\n `includeId`. If this option is `true`, `serialize` will,\n by default include the ID in the JSON object it builds.\n\n The adapter passes in `includeId: true` when serializing\n a record for `createRecord`, but not for `updateRecord`.\n\n ## Customization\n\n Your server may expect a different JSON format than the\n built-in serialization format.\n\n In that case, you can implement `serialize` yourself and\n return a JSON hash of your choosing.\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n serialize: function(post, options) {\n var json = {\n POST_TTL: post.get('title'),\n POST_BDY: post.get('body'),\n POST_CMS: post.get('comments').mapProperty('id')\n }\n\n if (options.includeId) {\n json.POST_ID_ = post.get('id');\n }\n\n return json;\n }\n });\n ```\n\n ## Customizing an App-Wide Serializer\n\n If you want to define a serializer for your entire\n application, you'll probably want to use `eachAttribute`\n and `eachRelationship` on the record.\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n serialize: function(record, options) {\n var json = {};\n\n record.eachAttribute(function(name) {\n json[serverAttributeName(name)] = record.get(name);\n })\n\n record.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'hasMany') {\n json[serverHasManyName(name)] = record.get(name).mapBy('id');\n }\n });\n\n if (options.includeId) {\n json.ID_ = record.get('id');\n }\n\n return json;\n }\n });\n\n function serverAttributeName(attribute) {\n return attribute.underscore().toUpperCase();\n }\n\n function serverHasManyName(name) {\n return serverAttributeName(name.singularize()) + \"_IDS\";\n }\n ```\n\n This serializer will generate JSON that looks like this:\n\n ```js\n {\n \"TITLE\": \"Rails is omakase\",\n \"BODY\": \"Yep. Omakase.\",\n \"COMMENT_IDS\": [ 1, 2, 3 ]\n }\n ```\n\n ## Tweaking the Default JSON\n\n If you just want to do some small tweaks on the default JSON,\n you can call super first and make the tweaks on the returned\n JSON.\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n serialize: function(record, options) {\n var json = this._super(record, options);\n\n json.subject = json.title;\n delete json.title;\n\n return json;\n }\n });\n ```\n\n @method serialize\n @param record\n @param options\n */\n serialize: function(record, options) {\n return this._super.apply(this, arguments);\n },\n\n /**\n You can use this method to customize the root keys serialized into the JSON.\n By default the REST Serializer sends camelized root keys.\n For example, your server may expect underscored root objects.\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n serializeIntoHash: function(data, type, record, options) {\n var root = Ember.String.decamelize(type.typeKey);\n data[root] = this.serialize(record, options);\n }\n });\n ```\n\n @method serializeIntoHash\n @param {Object} hash\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @param {Object} options\n */\n serializeIntoHash: function(hash, type, record, options) {\n hash[type.typeKey] = this.serialize(record, options);\n },\n\n /**\n You can use this method to customize how polymorphic objects are serialized.\n By default the JSON Serializer creates the key by appending `Type` to\n the attribute and value from the model's camelcased model name.\n\n @method serializePolymorphicType\n @param {DS.Model} record\n @param {Object} json\n @param {Object} relationship\n */\n serializePolymorphicType: function(record, json, relationship) {\n var key = relationship.key,\n belongsTo = get(record, key);\n key = this.keyForAttribute ? this.keyForAttribute(key) : key;\n json[key + \"Type\"] = belongsTo.constructor.typeKey;\n }\n});\n\n})();\n//@ sourceURL=ember-data/serializers/rest_serializer");minispade.register('ember-data/system/adapter', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar map = Ember.ArrayPolyfills.map;\n\nvar errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];\n\n/**\n A `DS.InvalidError` is used by an adapter to signal the external API\n was unable to process a request because the content was not\n semantically correct or meaningful per the API. Usually this means a\n record failed some form of server side validation. When a promise\n from an adapter is rejected with a `DS.InvalidError` the record will\n transition to the `invalid` state and the errors will be set to the\n `errors` property on the record.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.RESTAdapter.extend({\n ajaxError: function(jqXHR) {\n var error = this._super(jqXHR);\n\n if (jqXHR && jqXHR.status === 422) {\n var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)[\"errors\"];\n return new DS.InvalidError(jsonErrors);\n } else {\n return error;\n }\n }\n });\n ```\n\n @class InvalidError\n @namespace DS\n*/\nDS.InvalidError = function(errors) {\n var tmp = Error.prototype.constructor.call(this, \"The backend rejected the commit because it was invalid: \" + Ember.inspect(errors));\n this.errors = errors;\n\n for (var i=0, l=errorProps.length; i<l; i++) {\n this[errorProps[i]] = tmp[errorProps[i]];\n }\n};\nDS.InvalidError.prototype = Ember.create(Error.prototype);\n\n/**\n An adapter is an object that receives requests from a store and\n translates them into the appropriate action to take against your\n persistence layer. The persistence layer is usually an HTTP API, but\n may be anything, such as the browser's local storage. Typically the\n adapter is not invoked directly instead its functionality is accessed\n through the `store`.\n\n ### Creating an Adapter\n\n First, create a new subclass of `DS.Adapter`:\n\n ```javascript\n App.MyAdapter = DS.Adapter.extend({\n // ...your code here\n });\n ```\n\n To tell your store which adapter to use, set its `adapter` property:\n\n ```javascript\n App.store = DS.Store.create({\n adapter: App.MyAdapter.create()\n });\n ```\n\n `DS.Adapter` is an abstract base class that you should override in your\n application to customize it for your backend. The minimum set of methods\n that you should implement is:\n\n * `find()`\n * `createRecord()`\n * `updateRecord()`\n * `deleteRecord()`\n * `findAll()`\n * `findQuery()`\n\n To improve the network performance of your application, you can optimize\n your adapter by overriding these lower-level methods:\n\n * `findMany()`\n\n\n For an example implementation, see `DS.RESTAdapter`, the\n included REST adapter.\n\n @class Adapter\n @namespace DS\n @extends Ember.Object\n*/\n\nDS.Adapter = Ember.Object.extend({\n\n /**\n If you would like your adapter to use a custom serializer you can\n set the `defaultSerializer` property to be the name of the custom\n serializer.\n\n Note the `defaultSerializer` serializer has a lower priority then\n a model specific serializer (i.e. `PostSerializer`) or the\n `application` serializer.\n\n ```javascript\n var DjangoAdapter = DS.Adapter.extend({\n defaultSerializer: 'django'\n });\n ```\n\n @property defaultSerializer\n @type {String}\n */\n\n /**\n The `find()` method is invoked when the store is asked for a record that\n has not previously been loaded. In response to `find()` being called, you\n should query your persistence layer for a record with the given ID. Once\n found, you can asynchronously call the store's `push()` method to push\n the record into the store.\n\n Here is an example `find` implementation:\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n find: function(store, type, id) {\n var url = [type, id].join('/');\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.getJSON(url).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method find\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} id\n @return {Promise} promise\n */\n find: Ember.required(Function),\n\n /**\n The `findAll()` method is called when you call `find` on the store\n without an ID (i.e. `store.find('post')`).\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n findAll: function(store, type, sinceToken) {\n var url = type;\n var query = { since: sinceToken };\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.getJSON(url, query).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @private\n @method findAll\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} sinceToken\n @return {Promise} promise\n */\n findAll: null,\n\n /**\n This method is called when you call `find` on the store with a\n query object as the second parameter (i.e. `store.find('person', {\n page: 1 })`).\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n findQuery: function(store, type, query) {\n var url = type;\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.getJSON(url, query).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @private\n @method findQuery\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} query\n @param {DS.AdapterPopulatedRecordArray} recordArray\n @return {Promise} promise\n */\n findQuery: null,\n\n /**\n If the globally unique IDs for your records should be generated on the client,\n implement the `generateIdForRecord()` method. This method will be invoked\n each time you create a new record, and the value returned from it will be\n assigned to the record's `primaryKey`.\n\n Most traditional REST-like HTTP APIs will not use this method. Instead, the ID\n of the record will be set by the server, and your adapter will update the store\n with the new ID when it calls `didCreateRecord()`. Only implement this method if\n you intend to generate record IDs on the client-side.\n\n The `generateIdForRecord()` method will be invoked with the requesting store as\n the first parameter and the newly created record as the second parameter:\n\n ```javascript\n generateIdForRecord: function(store, record) {\n var uuid = App.generateUUIDWithStatisticallyLowOddsOfCollision();\n return uuid;\n }\n ```\n\n @method generateIdForRecord\n @param {DS.Store} store\n @param {DS.Model} record\n @return {String|Number} id\n */\n generateIdForRecord: null,\n\n /**\n Proxies to the serializer's `serialize` method.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n createRecord: function(store, type, record) {\n var data = this.serialize(record, { includeId: true });\n var url = type;\n\n // ...\n }\n });\n ```\n\n @method serialize\n @param {DS.Model} record\n @param {Object} options\n @return {Object} serialized record\n */\n serialize: function(record, options) {\n return get(record, 'store').serializerFor(record.constructor.typeKey).serialize(record, options);\n },\n\n /**\n Implement this method in a subclass to handle the creation of\n new records.\n\n Serializes the record and send it to the server.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n createRecord: function(store, type, record) {\n var data = this.serialize(record, { includeId: true });\n var url = type;\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.ajax({\n type: 'POST',\n url: url,\n dataType: 'json',\n data: data\n }).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method createRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type the DS.Model class of the record\n @param {DS.Model} record\n @return {Promise} promise\n */\n createRecord: Ember.required(Function),\n\n /**\n Implement this method in a subclass to handle the updating of\n a record.\n\n Serializes the record update and send it to the server.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n updateRecord: function(store, type, record) {\n var data = this.serialize(record, { includeId: true });\n var id = record.get('id');\n var url = [type, id].join('/');\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.ajax({\n type: 'PUT',\n url: url,\n dataType: 'json',\n data: data\n }).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method updateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type the DS.Model class of the record\n @param {DS.Model} record\n @return {Promise} promise\n */\n updateRecord: Ember.required(Function),\n\n /**\n Implement this method in a subclass to handle the deletion of\n a record.\n\n Sends a delete request for the record to the server.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n deleteRecord: function(store, type, record) {\n var data = this.serialize(record, { includeId: true });\n var id = record.get('id');\n var url = [type, id].join('/');\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.ajax({\n type: 'DELETE',\n url: url,\n dataType: 'json',\n data: data\n }).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method deleteRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type the DS.Model class of the record\n @param {DS.Model} record\n @return {Promise} promise\n */\n deleteRecord: Ember.required(Function),\n\n /**\n Find multiple records at once.\n\n By default, it loops over the provided ids and calls `find` on each.\n May be overwritten to improve performance and reduce the number of\n server requests.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n findMany: function(store, type, ids) {\n var url = type;\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.getJSON(url, {ids: ids}).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method findMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type the DS.Model class of the records\n @param {Array} ids\n @return {Promise} promise\n */\n findMany: function(store, type, ids) {\n var promises = map.call(ids, function(id) {\n return this.find(store, type, id);\n }, this);\n\n return Ember.RSVP.all(promises);\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/adapter");minispade.register('ember-data/system/changes', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/system/changes/attribute_change\");\nminispade.require(\"ember-data/system/changes/relationship_change\");\n\n})();\n//@ sourceURL=ember-data/system/changes");minispade.register('ember-data/system/changes/attribute_change', "(function() {/**\n @module ember-data\n*/\n\n/**\n An AttributeChange object is created whenever a record's\n attribute changes value. It is used to track changes to a\n record between transaction commits.\n\n @class AttributeChange\n @namespace DS\n @private\n @constructor\n*/\nvar AttributeChange = DS.AttributeChange = function(options) {\n this.record = options.record;\n this.store = options.store;\n this.name = options.name;\n this.value = options.value;\n this.oldValue = options.oldValue;\n};\n\nAttributeChange.createChange = function(options) {\n return new AttributeChange(options);\n};\n\nAttributeChange.prototype = {\n sync: function() {\n if (this.value !== this.oldValue) {\n this.record.send('becomeDirty');\n this.record.updateRecordArraysLater();\n }\n\n // TODO: Use this object in the commit process\n this.destroy();\n },\n\n /**\n If the AttributeChange is destroyed (either by being rolled back\n or being committed), remove it from the list of pending changes\n on the record.\n\n @method destroy\n */\n destroy: function() {\n delete this.record._changesToSync[this.name];\n }\n};\n\n})();\n//@ sourceURL=ember-data/system/changes/attribute_change");minispade.register('ember-data/system/changes/relationship_change', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar forEach = Ember.EnumerableUtils.forEach;\n\n/**\n @class RelationshipChange\n @namespace DS\n @private\n @construtor\n*/\nDS.RelationshipChange = function(options) {\n this.parentRecord = options.parentRecord;\n this.childRecord = options.childRecord;\n this.firstRecord = options.firstRecord;\n this.firstRecordKind = options.firstRecordKind;\n this.firstRecordName = options.firstRecordName;\n this.secondRecord = options.secondRecord;\n this.secondRecordKind = options.secondRecordKind;\n this.secondRecordName = options.secondRecordName;\n this.changeType = options.changeType;\n this.store = options.store;\n\n this.committed = {};\n};\n\n/**\n @class RelationshipChangeAdd\n @namespace DS\n @private\n @construtor\n*/\nDS.RelationshipChangeAdd = function(options){\n DS.RelationshipChange.call(this, options);\n};\n\n/**\n @class RelationshipChangeRemove\n @namespace DS\n @private\n @construtor\n*/\nDS.RelationshipChangeRemove = function(options){\n DS.RelationshipChange.call(this, options);\n};\n\nDS.RelationshipChange.create = function(options) {\n return new DS.RelationshipChange(options);\n};\n\nDS.RelationshipChangeAdd.create = function(options) {\n return new DS.RelationshipChangeAdd(options);\n};\n\nDS.RelationshipChangeRemove.create = function(options) {\n return new DS.RelationshipChangeRemove(options);\n};\n\nDS.OneToManyChange = {};\nDS.OneToNoneChange = {};\nDS.ManyToNoneChange = {};\nDS.OneToOneChange = {};\nDS.ManyToManyChange = {};\n\nDS.RelationshipChange._createChange = function(options){\n if(options.changeType === \"add\"){\n return DS.RelationshipChangeAdd.create(options);\n }\n if(options.changeType === \"remove\"){\n return DS.RelationshipChangeRemove.create(options);\n }\n};\n\n\nDS.RelationshipChange.determineRelationshipType = function(recordType, knownSide){\n var knownKey = knownSide.key, key, otherKind;\n var knownKind = knownSide.kind;\n\n var inverse = recordType.inverseFor(knownKey);\n\n if (inverse){\n key = inverse.name;\n otherKind = inverse.kind;\n }\n\n if (!inverse){\n return knownKind === \"belongsTo\" ? \"oneToNone\" : \"manyToNone\";\n }\n else{\n if(otherKind === \"belongsTo\"){\n return knownKind === \"belongsTo\" ? \"oneToOne\" : \"manyToOne\";\n }\n else{\n return knownKind === \"belongsTo\" ? \"oneToMany\" : \"manyToMany\";\n }\n }\n\n};\n\nDS.RelationshipChange.createChange = function(firstRecord, secondRecord, store, options){\n // Get the type of the child based on the child's client ID\n var firstRecordType = firstRecord.constructor, changeType;\n changeType = DS.RelationshipChange.determineRelationshipType(firstRecordType, options);\n if (changeType === \"oneToMany\"){\n return DS.OneToManyChange.createChange(firstRecord, secondRecord, store, options);\n }\n else if (changeType === \"manyToOne\"){\n return DS.OneToManyChange.createChange(secondRecord, firstRecord, store, options);\n }\n else if (changeType === \"oneToNone\"){\n return DS.OneToNoneChange.createChange(firstRecord, secondRecord, store, options);\n }\n else if (changeType === \"manyToNone\"){\n return DS.ManyToNoneChange.createChange(firstRecord, secondRecord, store, options);\n }\n else if (changeType === \"oneToOne\"){\n return DS.OneToOneChange.createChange(firstRecord, secondRecord, store, options);\n }\n else if (changeType === \"manyToMany\"){\n return DS.ManyToManyChange.createChange(firstRecord, secondRecord, store, options);\n }\n};\n\nDS.OneToNoneChange.createChange = function(childRecord, parentRecord, store, options) {\n var key = options.key;\n var change = DS.RelationshipChange._createChange({\n parentRecord: parentRecord,\n childRecord: childRecord,\n firstRecord: childRecord,\n store: store,\n changeType: options.changeType,\n firstRecordName: key,\n firstRecordKind: \"belongsTo\"\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change);\n\n return change;\n};\n\nDS.ManyToNoneChange.createChange = function(childRecord, parentRecord, store, options) {\n var key = options.key;\n var change = DS.RelationshipChange._createChange({\n parentRecord: childRecord,\n childRecord: parentRecord,\n secondRecord: childRecord,\n store: store,\n changeType: options.changeType,\n secondRecordName: options.key,\n secondRecordKind: \"hasMany\"\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change);\n return change;\n};\n\n\nDS.ManyToManyChange.createChange = function(childRecord, parentRecord, store, options) {\n // If the name of the belongsTo side of the relationship is specified,\n // use that\n // If the type of the parent is specified, look it up on the child's type\n // definition.\n var key = options.key;\n\n var change = DS.RelationshipChange._createChange({\n parentRecord: parentRecord,\n childRecord: childRecord,\n firstRecord: childRecord,\n secondRecord: parentRecord,\n firstRecordKind: \"hasMany\",\n secondRecordKind: \"hasMany\",\n store: store,\n changeType: options.changeType,\n firstRecordName: key\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change);\n\n\n return change;\n};\n\nDS.OneToOneChange.createChange = function(childRecord, parentRecord, store, options) {\n var key;\n\n // If the name of the belongsTo side of the relationship is specified,\n // use that\n // If the type of the parent is specified, look it up on the child's type\n // definition.\n if (options.parentType) {\n key = options.parentType.inverseFor(options.key).name;\n } else if (options.key) {\n key = options.key;\n } else {\n Ember.assert(\"You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent\", false);\n }\n\n var change = DS.RelationshipChange._createChange({\n parentRecord: parentRecord,\n childRecord: childRecord,\n firstRecord: childRecord,\n secondRecord: parentRecord,\n firstRecordKind: \"belongsTo\",\n secondRecordKind: \"belongsTo\",\n store: store,\n changeType: options.changeType,\n firstRecordName: key\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change);\n\n\n return change;\n};\n\nDS.OneToOneChange.maintainInvariant = function(options, store, childRecord, key){\n if (options.changeType === \"add\" && store.recordIsMaterialized(childRecord)) {\n var oldParent = get(childRecord, key);\n if (oldParent){\n var correspondingChange = DS.OneToOneChange.createChange(childRecord, oldParent, store, {\n parentType: options.parentType,\n hasManyName: options.hasManyName,\n changeType: \"remove\",\n key: options.key\n });\n store.addRelationshipChangeFor(childRecord, key, options.parentRecord , null, correspondingChange);\n correspondingChange.sync();\n }\n }\n};\n\nDS.OneToManyChange.createChange = function(childRecord, parentRecord, store, options) {\n var key;\n\n // If the name of the belongsTo side of the relationship is specified,\n // use that\n // If the type of the parent is specified, look it up on the child's type\n // definition.\n if (options.parentType) {\n key = options.parentType.inverseFor(options.key).name;\n DS.OneToManyChange.maintainInvariant( options, store, childRecord, key );\n } else if (options.key) {\n key = options.key;\n } else {\n Ember.assert(\"You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent\", false);\n }\n\n var change = DS.RelationshipChange._createChange({\n parentRecord: parentRecord,\n childRecord: childRecord,\n firstRecord: childRecord,\n secondRecord: parentRecord,\n firstRecordKind: \"belongsTo\",\n secondRecordKind: \"hasMany\",\n store: store,\n changeType: options.changeType,\n firstRecordName: key\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, change.getSecondRecordName(), change);\n\n\n return change;\n};\n\n\nDS.OneToManyChange.maintainInvariant = function(options, store, childRecord, key){\n if (options.changeType === \"add\" && childRecord) {\n var oldParent = get(childRecord, key);\n if (oldParent){\n var correspondingChange = DS.OneToManyChange.createChange(childRecord, oldParent, store, {\n parentType: options.parentType,\n hasManyName: options.hasManyName,\n changeType: \"remove\",\n key: options.key\n });\n store.addRelationshipChangeFor(childRecord, key, options.parentRecord, correspondingChange.getSecondRecordName(), correspondingChange);\n correspondingChange.sync();\n }\n }\n};\n\n/**\n @class RelationshipChange\n @namespace DS\n*/\nDS.RelationshipChange.prototype = {\n\n getSecondRecordName: function() {\n var name = this.secondRecordName, parent;\n\n if (!name) {\n parent = this.secondRecord;\n if (!parent) { return; }\n\n var childType = this.firstRecord.constructor;\n var inverse = childType.inverseFor(this.firstRecordName);\n this.secondRecordName = inverse.name;\n }\n\n return this.secondRecordName;\n },\n\n /**\n Get the name of the relationship on the belongsTo side.\n\n @method getFirstRecordName\n @return {String}\n */\n getFirstRecordName: function() {\n var name = this.firstRecordName;\n return name;\n },\n\n /**\n @method destroy\n @private\n */\n destroy: function() {\n var childRecord = this.childRecord,\n belongsToName = this.getFirstRecordName(),\n hasManyName = this.getSecondRecordName(),\n store = this.store;\n\n store.removeRelationshipChangeFor(childRecord, belongsToName, this.parentRecord, hasManyName, this.changeType);\n },\n\n getSecondRecord: function(){\n return this.secondRecord;\n },\n\n /**\n @method getFirstRecord\n @private\n */\n getFirstRecord: function() {\n return this.firstRecord;\n },\n\n coalesce: function(){\n var relationshipPairs = this.store.relationshipChangePairsFor(this.firstRecord);\n forEach(relationshipPairs, function(pair){\n var addedChange = pair[\"add\"];\n var removedChange = pair[\"remove\"];\n if(addedChange && removedChange) {\n addedChange.destroy();\n removedChange.destroy();\n }\n });\n }\n};\n\nDS.RelationshipChangeAdd.prototype = Ember.create(DS.RelationshipChange.create({}));\nDS.RelationshipChangeRemove.prototype = Ember.create(DS.RelationshipChange.create({}));\n\n// the object is a value, and not a promise\nfunction isValue(object) {\n return typeof object === 'object' && (!object.then || typeof object.then !== 'function');\n}\n\nDS.RelationshipChangeAdd.prototype.changeType = \"add\";\nDS.RelationshipChangeAdd.prototype.sync = function() {\n var secondRecordName = this.getSecondRecordName(),\n firstRecordName = this.getFirstRecordName(),\n firstRecord = this.getFirstRecord(),\n secondRecord = this.getSecondRecord();\n\n //Ember.assert(\"You specified a hasMany (\" + hasManyName + \") on \" + (!belongsToName && (newParent || oldParent || this.lastParent).constructor) + \" but did not specify an inverse belongsTo on \" + child.constructor, belongsToName);\n //Ember.assert(\"You specified a belongsTo (\" + belongsToName + \") on \" + child.constructor + \" but did not specify an inverse hasMany on \" + (!hasManyName && (newParent || oldParent || this.lastParentRecord).constructor), hasManyName);\n\n if (secondRecord instanceof DS.Model && firstRecord instanceof DS.Model) {\n if(this.secondRecordKind === \"belongsTo\"){\n secondRecord.suspendRelationshipObservers(function(){\n set(secondRecord, secondRecordName, firstRecord);\n });\n\n }\n else if(this.secondRecordKind === \"hasMany\"){\n secondRecord.suspendRelationshipObservers(function(){\n var relationship = get(secondRecord, secondRecordName);\n if (isValue(relationship)) { relationship.addObject(firstRecord); }\n });\n }\n }\n\n if (firstRecord instanceof DS.Model && secondRecord instanceof DS.Model && get(firstRecord, firstRecordName) !== secondRecord) {\n if(this.firstRecordKind === \"belongsTo\"){\n firstRecord.suspendRelationshipObservers(function(){\n set(firstRecord, firstRecordName, secondRecord);\n });\n }\n else if(this.firstRecordKind === \"hasMany\"){\n firstRecord.suspendRelationshipObservers(function(){\n var relationship = get(firstRecord, firstRecordName);\n if (isValue(relationship)) { relationship.addObject(secondRecord); }\n });\n }\n }\n\n this.coalesce();\n};\n\nDS.RelationshipChangeRemove.prototype.changeType = \"remove\";\nDS.RelationshipChangeRemove.prototype.sync = function() {\n var secondRecordName = this.getSecondRecordName(),\n firstRecordName = this.getFirstRecordName(),\n firstRecord = this.getFirstRecord(),\n secondRecord = this.getSecondRecord();\n\n //Ember.assert(\"You specified a hasMany (\" + hasManyName + \") on \" + (!belongsToName && (newParent || oldParent || this.lastParent).constructor) + \" but did not specify an inverse belongsTo on \" + child.constructor, belongsToName);\n //Ember.assert(\"You specified a belongsTo (\" + belongsToName + \") on \" + child.constructor + \" but did not specify an inverse hasMany on \" + (!hasManyName && (newParent || oldParent || this.lastParentRecord).constructor), hasManyName);\n\n if (secondRecord instanceof DS.Model && firstRecord instanceof DS.Model) {\n if(this.secondRecordKind === \"belongsTo\"){\n secondRecord.suspendRelationshipObservers(function(){\n set(secondRecord, secondRecordName, null);\n });\n }\n else if(this.secondRecordKind === \"hasMany\"){\n secondRecord.suspendRelationshipObservers(function(){\n var relationship = get(secondRecord, secondRecordName);\n if (isValue(relationship)) { relationship.removeObject(firstRecord); }\n });\n }\n }\n\n if (firstRecord instanceof DS.Model && get(firstRecord, firstRecordName)) {\n if(this.firstRecordKind === \"belongsTo\"){\n firstRecord.suspendRelationshipObservers(function(){\n set(firstRecord, firstRecordName, null);\n });\n }\n else if(this.firstRecordKind === \"hasMany\"){\n firstRecord.suspendRelationshipObservers(function(){\n var relationship = get(firstRecord, firstRecordName);\n if (isValue(relationship)) { relationship.removeObject(secondRecord); }\n });\n }\n }\n\n this.coalesce();\n};\n\n})();\n//@ sourceURL=ember-data/system/changes/relationship_change");minispade.register('ember-data/system/debug', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/system/debug/debug_info\");\nminispade.require(\"ember-data/system/debug/debug_adapter\");\n\n})();\n//@ sourceURL=ember-data/system/debug");minispade.register('ember-data/system/debug/debug_adapter', "(function() {/**\n @module ember-data\n*/\nvar get = Ember.get, capitalize = Ember.String.capitalize, underscore = Ember.String.underscore, DS = window.DS ;\n\n/**\n Extend `Ember.DataAdapter` with ED specific code.\n\n @class DebugAdapter\n @namespace DS\n @extends Ember.DataAdapter\n @private\n*/\nDS.DebugAdapter = Ember.DataAdapter.extend({\n getFilters: function() {\n return [\n { name: 'isNew', desc: 'New' },\n { name: 'isModified', desc: 'Modified' },\n { name: 'isClean', desc: 'Clean' }\n ];\n },\n\n detect: function(klass) {\n return klass !== DS.Model && DS.Model.detect(klass);\n },\n\n columnsForType: function(type) {\n var columns = [{ name: 'id', desc: 'Id' }], count = 0, self = this;\n get(type, 'attributes').forEach(function(name, meta) {\n if (count++ > self.attributeLimit) { return false; }\n var desc = capitalize(underscore(name).replace('_', ' '));\n columns.push({ name: name, desc: desc });\n });\n return columns;\n },\n\n getRecords: function(type) {\n return this.get('store').all(type);\n },\n\n getRecordColumnValues: function(record) {\n var self = this, count = 0,\n columnValues = { id: get(record, 'id') };\n\n record.eachAttribute(function(key) {\n if (count++ > self.attributeLimit) {\n return false;\n }\n var value = get(record, key);\n columnValues[key] = value;\n });\n return columnValues;\n },\n\n getRecordKeywords: function(record) {\n var keywords = [], keys = Ember.A(['id']);\n record.eachAttribute(function(key) {\n keys.push(key);\n });\n keys.forEach(function(key) {\n keywords.push(get(record, key));\n });\n return keywords;\n },\n\n getRecordFilterValues: function(record) {\n return {\n isNew: record.get('isNew'),\n isModified: record.get('isDirty') && !record.get('isNew'),\n isClean: !record.get('isDirty')\n };\n },\n\n getRecordColor: function(record) {\n var color = 'black';\n if (record.get('isNew')) {\n color = 'green';\n } else if (record.get('isDirty')) {\n color = 'blue';\n }\n return color;\n },\n\n observeRecord: function(record, recordUpdated) {\n var releaseMethods = Ember.A(), self = this,\n keysToObserve = Ember.A(['id', 'isNew', 'isDirty']);\n\n record.eachAttribute(function(key) {\n keysToObserve.push(key);\n });\n\n keysToObserve.forEach(function(key) {\n var handler = function() {\n recordUpdated(self.wrapRecord(record));\n };\n Ember.addObserver(record, key, handler);\n releaseMethods.push(function() {\n Ember.removeObserver(record, key, handler);\n });\n });\n\n var release = function() {\n releaseMethods.forEach(function(fn) { fn(); } );\n };\n\n return release;\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/system/debug/debug_adapter");minispade.register('ember-data/system/debug/debug_info', "(function() {minispade.require(\"ember-data/system/model/model\");\n\nDS.Model.reopen({\n\n /**\n Provides info about the model for debugging purposes\n by grouping the properties into more semantic groups.\n\n Meant to be used by debugging tools such as the Chrome Ember Extension.\n\n - Groups all attributes in \"Attributes\" group.\n - Groups all belongsTo relationships in \"Belongs To\" group.\n - Groups all hasMany relationships in \"Has Many\" group.\n - Groups all flags in \"Flags\" group.\n - Flags relationship CPs as expensive properties.\n\n @method _debugInfo\n @for DS.Model\n @private\n */\n _debugInfo: function() {\n var attributes = ['id'],\n relationships = { belongsTo: [], hasMany: [] },\n expensiveProperties = [];\n\n this.eachAttribute(function(name, meta) {\n attributes.push(name);\n }, this);\n\n this.eachRelationship(function(name, relationship) {\n relationships[relationship.kind].push(name);\n expensiveProperties.push(name);\n });\n\n var groups = [\n {\n name: 'Attributes',\n properties: attributes,\n expand: true\n },\n {\n name: 'Belongs To',\n properties: relationships.belongsTo,\n expand: true\n },\n {\n name: 'Has Many',\n properties: relationships.hasMany,\n expand: true\n },\n {\n name: 'Flags',\n properties: ['isLoaded', 'isDirty', 'isSaving', 'isDeleted', 'isError', 'isNew', 'isValid']\n }\n ];\n\n return {\n propertyInfo: {\n // include all other mixins / properties (not just the grouped ones)\n includeOtherProperties: true,\n groups: groups,\n // don't pre-calculate unless cached\n expensiveProperties: expensiveProperties\n }\n };\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/system/debug/debug_info");minispade.register('ember-data/system/model', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/system/model/model\");\nminispade.require(\"ember-data/system/model/states\");\nminispade.require(\"ember-data/system/model/attributes\");\n\n})();\n//@ sourceURL=ember-data/system/model");minispade.register('ember-data/system/model/attributes', "(function() {minispade.require(\"ember-data/system/model/model\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get;\n\n/**\n @class Model\n @namespace DS\n*/\nDS.Model.reopenClass({\n /**\n A map whose keys are the attributes of the model (properties\n described by DS.attr) and whose values are the meta object for the\n property.\n\n Example\n\n ```javascript\n\n App.Person = DS.Model.extend({\n firstName: attr('string'),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\n var attributes = Ember.get(App.Person, 'attributes')\n\n attributes.forEach(function(name, meta) {\n console.log(name, meta);\n });\n\n // prints:\n // firstName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"firstName\"}\n // lastName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"lastName\"}\n // birthday {type: \"date\", isAttribute: true, options: Object, parentType: function, name: \"birthday\"}\n ```\n\n @property attributes\n @static\n @type {Ember.Map}\n @readOnly\n */\n attributes: Ember.computed(function() {\n var map = Ember.Map.create();\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isAttribute) {\n Ember.assert(\"You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from \" + this.toString(), name !== 'id');\n\n meta.name = name;\n map.set(name, meta);\n }\n });\n\n return map;\n }),\n\n /**\n A map whose keys are the attributes of the model (properties\n described by DS.attr) and whose values are type of transformation\n applied to each attribute. This map does not include any\n attributes that do not have an transformation type.\n\n Example\n\n ```javascript\n App.Person = DS.Model.extend({\n firstName: attr(),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\n var transformedAttributes = Ember.get(App.Person, 'transformedAttributes')\n\n transformedAttributes.forEach(function(field, type) {\n console.log(field, type);\n });\n\n // prints:\n // lastName string\n // birthday date\n ```\n\n @property transformedAttributes\n @static\n @type {Ember.Map}\n @readOnly\n */\n transformedAttributes: Ember.computed(function() {\n var map = Ember.Map.create();\n\n this.eachAttribute(function(key, meta) {\n if (meta.type) {\n map.set(key, meta.type);\n }\n });\n\n return map;\n }),\n\n /**\n Iterates through the attributes of the model, calling the passed function on each\n attribute.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(name, meta);\n ```\n\n - `name` the name of the current property in the iteration\n - `meta` the meta object for the attribute property in the iteration\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context.\n\n Example\n\n ```javascript\n App.Person = DS.Model.extend({\n firstName: attr('string'),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\n App.Person.eachAttribute(function(name, meta) {\n console.log(name, meta);\n });\n\n // prints:\n // firstName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"firstName\"}\n // lastName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"lastName\"}\n // birthday {type: \"date\", isAttribute: true, options: Object, parentType: function, name: \"birthday\"}\n ```\n\n @method eachAttribute\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @static\n */\n eachAttribute: function(callback, binding) {\n get(this, 'attributes').forEach(function(name, meta) {\n callback.call(binding, name, meta);\n }, binding);\n },\n\n /**\n Iterates through the transformedAttributes of the model, calling\n the passed function on each attribute. Note the callback will not be\n called for any attributes that do not have an transformation type.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(name, type);\n ```\n\n - `name` the name of the current property in the iteration\n - `type` a tring contrining the name of the type of transformed\n applied to the attribute\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context.\n\n Example\n\n ```javascript\n App.Person = DS.Model.extend({\n firstName: attr(),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\n App.Person.eachTransformedAttribute(function(name, type) {\n console.log(name, type);\n });\n\n // prints:\n // lastName string\n // birthday date\n ```\n\n @method eachTransformedAttribute\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @static\n */\n eachTransformedAttribute: function(callback, binding) {\n get(this, 'transformedAttributes').forEach(function(name, type) {\n callback.call(binding, name, type);\n });\n }\n});\n\n\nDS.Model.reopen({\n eachAttribute: function(callback, binding) {\n this.constructor.eachAttribute(callback, binding);\n }\n});\n\nfunction getDefaultValue(record, options, key) {\n if (typeof options.defaultValue === \"function\") {\n return options.defaultValue();\n } else {\n return options.defaultValue;\n }\n}\n\nfunction hasValue(record, key) {\n return record._attributes.hasOwnProperty(key) ||\n record._inFlightAttributes.hasOwnProperty(key) ||\n record._data.hasOwnProperty(key);\n}\n\nfunction getValue(record, key) {\n if (record._attributes.hasOwnProperty(key)) {\n return record._attributes[key];\n } else if (record._inFlightAttributes.hasOwnProperty(key)) {\n return record._inFlightAttributes[key];\n } else {\n return record._data[key];\n }\n}\n\n/**\n `DS.attr` defines an attribute on a [DS.Model](DS.Model.html).\n By default, attributes are passed through as-is, however you can specify an\n optional type to have the value automatically transformed.\n Ember Data ships with four basic transform types: `string`, `number`,\n `boolean` and `date`. You can define your own transforms by subclassing\n [DS.Transform](DS.Transform.html).\n\n `DS.attr` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `defaultValue`: Pass a string or a function to be called to set the attribute\n to a default value if none is supplied.\n\n Example\n\n ```javascript\n var attr = DS.attr;\n\n App.User = DS.Model.extend({\n username: attr('string'),\n email: attr('string'),\n verified: attr('boolean', {defaultValue: false})\n });\n ```\n\n @namespace\n @method attr\n @for DS\n @param {String} type the attribute type\n @param {Object} options a hash of options\n @return {Attribute}\n*/\n\nDS.attr = function(type, options) {\n options = options || {};\n\n var meta = {\n type: type,\n isAttribute: true,\n options: options\n };\n\n return Ember.computed(function(key, value) {\n if (arguments.length > 1) {\n Ember.assert(\"You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from \" + this.constructor.toString(), key !== 'id');\n var oldValue = this._attributes[key] || this._inFlightAttributes[key] || this._data[key];\n\n this.send('didSetProperty', {\n name: key,\n oldValue: oldValue,\n originalValue: this._data[key],\n value: value\n });\n\n this._attributes[key] = value;\n return value;\n } else if (hasValue(this, key)) {\n return getValue(this, key);\n } else {\n return getDefaultValue(this, options, key);\n }\n\n // `data` is never set directly. However, it may be\n // invalidated from the state manager's setData\n // event.\n }).property('data').meta(meta);\n};\n\n\n})();\n//@ sourceURL=ember-data/system/model/attributes");minispade.register('ember-data/system/model/errors', "(function() {var get = Ember.get, isEmpty = Ember.isEmpty;\n\n/**\n@module ember-data\n*/\n\n/**\n Holds validation errors for a given record organized by attribute names.\n\n @class Errors\n @namespace DS\n @extends Ember.Object\n @uses Ember.Enumerable\n @uses Ember.Evented\n */\nDS.Errors = Ember.Object.extend(Ember.Enumerable, Ember.Evented, {\n /**\n Register with target handler\n\n @method registerHandlers\n @param {Object} target\n @param {Function} becameInvalid\n @param {Function} becameValid\n */\n registerHandlers: function(target, becameInvalid, becameValid) {\n this.on('becameInvalid', target, becameInvalid);\n this.on('becameValid', target, becameValid);\n },\n\n /**\n @property errorsByAttributeName\n @type {Ember.MapWithDefault}\n @private\n */\n errorsByAttributeName: Ember.reduceComputed(\"content\", {\n initialValue: function() {\n return Ember.MapWithDefault.create({\n defaultValue: function() {\n return Ember.A();\n }\n });\n },\n\n addedItem: function(errors, error) {\n errors.get(error.attribute).pushObject(error);\n\n return errors;\n },\n\n removedItem: function(errors, error) {\n errors.get(error.attribute).removeObject(error);\n\n return errors;\n }\n }),\n\n /**\n Returns errors for a given attribute\n\n @method errorsFor\n @param {String} attribute\n @returns {Array}\n */\n errorsFor: function(attribute) {\n return get(this, 'errorsByAttributeName').get(attribute);\n },\n\n /**\n */\n messages: Ember.computed.mapBy('content', 'message'),\n\n /**\n @property content\n @type {Array}\n @private\n */\n content: Ember.computed(function() {\n return Ember.A();\n }),\n\n /**\n @method unknownProperty\n @private\n */\n unknownProperty: function(attribute) {\n var errors = this.errorsFor(attribute);\n if (isEmpty(errors)) { return null; }\n return errors;\n },\n\n /**\n @method nextObject\n @private\n */\n nextObject: function(index, previousObject, context) {\n return get(this, 'content').objectAt(index);\n },\n\n /**\n Total number of errors.\n\n @property length\n @type {Number}\n @readOnly\n */\n length: Ember.computed.oneWay('content.length').readOnly(),\n\n /**\n @property isEmpty\n @type {Boolean}\n @readOnly\n */\n isEmpty: Ember.computed.not('length').readOnly(),\n\n /**\n Adds error messages to a given attribute and sends\n `becameInvalid` event to the record.\n\n @method add\n @param {String} attribute\n @param {Array|String} messages\n */\n add: function(attribute, messages) {\n var wasEmpty = get(this, 'isEmpty');\n\n messages = this._findOrCreateMessages(attribute, messages);\n get(this, 'content').addObjects(messages);\n\n this.notifyPropertyChange(attribute);\n this.enumerableContentDidChange();\n\n if (wasEmpty && !get(this, 'isEmpty')) {\n this.trigger('becameInvalid');\n }\n },\n\n /**\n @method _findOrCreateMessages\n @private\n */\n _findOrCreateMessages: function(attribute, messages) {\n var errors = this.errorsFor(attribute);\n\n return Ember.makeArray(messages).map(function(message) {\n return errors.findBy('message', message) || {\n attribute: attribute,\n message: message\n };\n });\n },\n\n /**\n Removes all error messages from the given attribute and sends\n `becameValid` event to the record if there no more errors left.\n\n @method remove\n @param {String} attribute\n */\n remove: function(attribute) {\n if (get(this, 'isEmpty')) { return; }\n\n var content = get(this, 'content').rejectBy('attribute', attribute);\n get(this, 'content').setObjects(content);\n\n this.notifyPropertyChange(attribute);\n this.enumerableContentDidChange();\n\n if (get(this, 'isEmpty')) {\n this.trigger('becameValid');\n }\n },\n\n /**\n Removes all error messages and sends `becameValid` event\n to the record.\n\n @method clear\n */\n clear: function() {\n if (get(this, 'isEmpty')) { return; }\n\n get(this, 'content').clear();\n this.enumerableContentDidChange();\n\n this.trigger('becameValid');\n },\n\n /**\n Checks if there is error messages for the given attribute.\n\n @method has\n @param {String} attribute\n @returns {Boolean} true if there some errors on given attribute\n */\n has: function(attribute) {\n return !isEmpty(this.errorsFor(attribute));\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/model/errors");minispade.register('ember-data/system/model/model', "(function() {minispade.require(\"ember-data/system/model/states\");\nminispade.require(\"ember-data/system/model/errors\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set,\n merge = Ember.merge, once = Ember.run.once;\n\nvar retrieveFromCurrentState = Ember.computed('currentState', function(key, value) {\n return get(get(this, 'currentState'), key);\n}).readOnly();\n\n/**\n\n The model class that all Ember Data records descend from.\n\n @class Model\n @namespace DS\n @extends Ember.Object\n @uses Ember.Evented\n*/\nDS.Model = Ember.Object.extend(Ember.Evented, {\n /**\n If this property is `true` the record is in the `empty`\n state. Empty is the first state all records enter after they have\n been created. Most records created by the store will quickly\n transition to the `loading` state if data needs to be fetched from\n the server or the `created` state if the record is created on the\n client. A record can also enter the empty state if the adapter is\n unable to locate the record.\n\n @property isEmpty\n @type {Boolean}\n @readOnly\n */\n isEmpty: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `loading` state. A\n record enters this state when the store askes the adapter for its\n data. It remains in this state until the adapter provides the\n requested data.\n\n @property isLoading\n @type {Boolean}\n @readOnly\n */\n isLoading: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `loaded` state. A\n record enters this state when its data is populated. Most of a\n record's lifecycle is spent inside substates of the `loaded`\n state.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isLoaded'); // true\n\n store.find('model', 1).then(function(model) {\n model.get('isLoaded'); // true\n });\n ```\n\n @property isLoaded\n @type {Boolean}\n @readOnly\n */\n isLoaded: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `dirty` state. The\n record has local changes that have not yet been saved by the\n adapter. This includes records that have been created (but not yet\n saved) or deleted.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isDirty'); // true\n\n store.find('model', 1).then(function(model) {\n model.get('isDirty'); // false\n model.set('foo', 'some value');\n model.set('isDirty'); // true\n });\n ```\n\n @property isDirty\n @type {Boolean}\n @readOnly\n */\n isDirty: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `saving` state. A\n record enters the saving state when `save` is called, but the\n adapter has not yet acknowledged that the changes have been\n persisted to the backend.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isSaving'); // false\n var promise = record.save();\n record.get('isSaving'); // true\n promise.then(function() {\n record.get('isSaving'); // false\n });\n ```\n\n @property isSaving\n @type {Boolean}\n @readOnly\n */\n isSaving: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `deleted` state\n and has been marked for deletion. When `isDeleted` is true and\n `isDirty` is true, the record is deleted locally but the deletion\n was not yet persisted. When `isSaving` is true, the change is\n in-flight. When both `isDirty` and `isSaving` are false, the\n change has persisted.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isDeleted'); // false\n record.deleteRecord();\n record.get('isDeleted'); // true\n ```\n\n @property isDeleted\n @type {Boolean}\n @readOnly\n */\n isDeleted: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `new` state. A\n record will be in the `new` state when it has been created on the\n client and the adapter has not yet report that it was successfully\n saved.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isNew'); // true\n\n store.find('model', 1).then(function(model) {\n model.get('isNew'); // false\n });\n ```\n\n @property isNew\n @type {Boolean}\n @readOnly\n */\n isNew: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `valid` state. A\n record will be in the `valid` state when no client-side\n validations have failed and the adapter did not report any\n server-side validation failures.\n\n @property isValid\n @type {Boolean}\n @readOnly\n */\n isValid: retrieveFromCurrentState,\n /**\n If the record is in the dirty state this property will report what\n kind of change has caused it to move into the dirty\n state. Possible values are:\n\n - `created` The record has been created by the client and not yet saved to the adapter.\n - `updated` The record has been updated by the client and not yet saved to the adapter.\n - `deleted` The record has been deleted by the client and not yet saved to the adapter.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('dirtyType'); // 'created'\n ```\n\n @property dirtyType\n @type {String}\n @readOnly\n */\n dirtyType: retrieveFromCurrentState,\n\n /**\n If `true` the adapter reported that it was unable to save local\n changes to the backend. This may also result in the record having\n its `isValid` property become false if the adapter reported that\n server-side validations failed.\n\n Example\n\n ```javascript\n record.get('isError'); // false\n record.set('foo', 'invalid value');\n record.save().then(null, function() {\n record.get('isError'); // true\n });\n ```\n\n @property isError\n @type {Boolean}\n @readOnly\n */\n isError: false,\n /**\n If `true` the store is attempting to reload the record form the adapter.\n\n Example\n\n ```javascript\n record.get('isReloading'); // false\n record.reload();\n record.get('isReloading'); // true\n ```\n\n @property isReloading\n @type {Boolean}\n @readOnly\n */\n isReloading: false,\n\n /**\n The `clientId` property is a transient numerical identifier\n generated at runtime by the data store. It is important\n primarily because newly created objects may not yet have an\n externally generated id.\n\n @property clientId\n @private\n @type {Number|String}\n */\n clientId: null,\n /**\n All ember models have an id property. This is an identifier\n managed by an external source. These are always coerced to be\n strings before being used internally. Note when declaring the\n attributes for a model it is an error to declare an id\n attribute.\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('id'); // null\n\n store.find('model', 1).then(function(model) {\n model.get('id'); // '1'\n });\n ```\n\n @property id\n @type {String}\n */\n id: null,\n transaction: null,\n /**\n @property currentState\n @private\n @type {Object}\n */\n currentState: null,\n /**\n When the record is in the `invalid` state this object will contain\n any errors returned by the adapter. When present the errors hash\n typically contains keys coresponding to the invalid property names\n and values which are an array of error messages.\n\n ```javascript\n record.get('errors.length'); // 0\n record.set('foo', 'invalid value');\n record.save().then(null, function() {\n record.get('errors').get('foo'); // ['foo should be a number.']\n });\n ```\n\n @property errors\n @type {Object}\n */\n errors: null,\n\n /**\n Create a JSON representation of the record, using the serialization\n strategy of the store's adapter.\n\n `serialize` takes an optional hash as a parameter, currently\n supported options are:\n\n - `includeId`: `true` if the record's ID should be included in the\n JSON representation.\n\n @method serialize\n @param {Object} options\n @returns {Object} an object whose values are primitive JSON values only\n */\n serialize: function(options) {\n var store = get(this, 'store');\n return store.serialize(this, options);\n },\n\n /**\n Use [DS.JSONSerializer](DS.JSONSerializer.html) to\n get the JSON representation of a record.\n\n `toJSON` takes an optional hash as a parameter, currently\n supported options are:\n\n - `includeId`: `true` if the record's ID should be included in the\n JSON representation.\n\n @method toJSON\n @param {Object} options\n @returns {Object} A JSON representation of the object.\n */\n toJSON: function(options) {\n // container is for lazy transform lookups\n var serializer = DS.JSONSerializer.create({ container: this.container });\n return serializer.serialize(this, options);\n },\n\n /**\n Fired when the record is loaded from the server.\n\n @event didLoad\n */\n didLoad: Ember.K,\n\n /**\n Fired when the record is updated.\n\n @event didUpdate\n */\n didUpdate: Ember.K,\n\n /**\n Fired when the record is created.\n\n @event didCreate\n */\n didCreate: Ember.K,\n\n /**\n Fired when the record is deleted.\n\n @event didDelete\n */\n didDelete: Ember.K,\n\n /**\n Fired when the record becomes invalid.\n\n @event becameInvalid\n */\n becameInvalid: Ember.K,\n\n /**\n Fired when the record enters the error state.\n\n @event becameError\n */\n becameError: Ember.K,\n\n /**\n @property data\n @private\n @type {Object}\n */\n data: Ember.computed(function() {\n this._data = this._data || {};\n return this._data;\n }).property(),\n\n _data: null,\n\n init: function() {\n set(this, 'currentState', DS.RootState.empty);\n var errors = DS.Errors.create();\n errors.registerHandlers(this, function() {\n this.send('becameInvalid');\n }, function() {\n this.send('becameValid');\n });\n set(this, 'errors', errors);\n this._super();\n this._setup();\n },\n\n _setup: function() {\n this._changesToSync = {};\n this._deferredTriggers = [];\n this._data = {};\n this._attributes = {};\n this._inFlightAttributes = {};\n this._relationships = {};\n },\n\n /**\n @method send\n @private\n @param {String} name\n @param {Object} context\n */\n send: function(name, context) {\n var currentState = get(this, 'currentState');\n\n if (!currentState[name]) {\n this._unhandledEvent(currentState, name, context);\n }\n\n return currentState[name](this, context);\n },\n\n /**\n @method transitionTo\n @private\n @param {String} name\n */\n transitionTo: function(name) {\n // POSSIBLE TODO: Remove this code and replace with\n // always having direct references to state objects\n\n var pivotName = name.split(\".\", 1),\n currentState = get(this, 'currentState'),\n state = currentState;\n\n do {\n if (state.exit) { state.exit(this); }\n state = state.parentState;\n } while (!state.hasOwnProperty(pivotName));\n\n var path = name.split(\".\");\n\n var setups = [], enters = [], i, l;\n\n for (i=0, l=path.length; i<l; i++) {\n state = state[path[i]];\n\n if (state.enter) { enters.push(state); }\n if (state.setup) { setups.push(state); }\n }\n\n for (i=0, l=enters.length; i<l; i++) {\n enters[i].enter(this);\n }\n\n set(this, 'currentState', state);\n\n for (i=0, l=setups.length; i<l; i++) {\n setups[i].setup(this);\n }\n\n this.updateRecordArraysLater();\n },\n\n _unhandledEvent: function(state, name, context) {\n var errorMessage = \"Attempted to handle event `\" + name + \"` \";\n errorMessage += \"on \" + String(this) + \" while in state \";\n errorMessage += state.stateName + \". \";\n\n if (context !== undefined) {\n errorMessage += \"Called with \" + Ember.inspect(context) + \".\";\n }\n\n throw new Ember.Error(errorMessage);\n },\n\n withTransaction: function(fn) {\n var transaction = get(this, 'transaction');\n if (transaction) { fn(transaction); }\n },\n\n /**\n @method loadingData\n @private\n @param {Promise} promise\n */\n loadingData: function(promise) {\n this.send('loadingData', promise);\n },\n\n /**\n @method loadedData\n @private\n */\n loadedData: function() {\n this.send('loadedData');\n },\n\n /**\n @method notFound\n @private\n */\n notFound: function() {\n this.send('notFound');\n },\n\n /**\n @method pushedData\n @private\n */\n pushedData: function() {\n this.send('pushedData');\n },\n\n /**\n Marks the record as deleted but does not save it. You must call\n `save` afterwards if you want to persist it. You might use this\n method if you want to allow the user to still `rollback()` a\n delete after it was made.\n\n Example\n\n ```javascript\n App.ModelDeleteRoute = Ember.Route.extend({\n actions: {\n softDelete: function() {\n this.get('model').deleteRecord();\n },\n confirm: function() {\n this.get('model').save();\n },\n undo: function() {\n this.get('model').rollback();\n }\n }\n });\n ```\n\n @method deleteRecord\n */\n deleteRecord: function() {\n this.send('deleteRecord');\n },\n\n /**\n Same as `deleteRecord`, but saves the record immediately.\n\n Example\n\n ```javascript\n App.ModelDeleteRoute = Ember.Route.extend({\n actions: {\n delete: function() {\n var controller = this.controller;\n this.get('model').destroyRecord().then(function() {\n controller.transitionToRoute('model.index');\n });\n }\n }\n });\n ```\n\n @method destroyRecord\n @return {Promise} a promise that will be resolved when the adapter returns\n successfully or rejected if the adapter returns with an error.\n */\n destroyRecord: function() {\n this.deleteRecord();\n return this.save();\n },\n\n /**\n @method unloadRecord\n @private\n */\n unloadRecord: function() {\n Ember.assert(\"You can only unload a loaded, non-dirty record.\", !get(this, 'isDirty'));\n\n this.send('unloadRecord');\n },\n\n /**\n @method clearRelationships\n @private\n */\n clearRelationships: function() {\n this.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'belongsTo') {\n set(this, name, null);\n } else if (relationship.kind === 'hasMany') {\n var hasMany = this._relationships[relationship.name];\n if (hasMany) { hasMany.clear(); }\n }\n }, this);\n },\n\n /**\n @method updateRecordArrays\n @private\n */\n updateRecordArrays: function() {\n get(this, 'store').dataWasUpdated(this.constructor, this);\n },\n\n /**\n Returns an object, whose keys are changed properties, and value is\n an [oldProp, newProp] array.\n\n Example\n\n ```javascript\n App.Mascot = DS.Model.extend({\n name: attr('string')\n });\n\n var person = store.createRecord('person');\n person.changedAttributes(); // {}\n person.set('name', 'Tomster');\n person.changedAttributes(); // {name: [undefined, 'Tomster']}\n ```\n\n @method changedAttributes\n @return {Object} an object, whose keys are changed properties,\n and value is an [oldProp, newProp] array.\n */\n changedAttributes: function() {\n var oldData = get(this, '_data'),\n newData = get(this, '_attributes'),\n diffData = {},\n prop;\n\n for (prop in newData) {\n diffData[prop] = [oldData[prop], newData[prop]];\n }\n\n return diffData;\n },\n\n /**\n @method adapterWillCommit\n @private\n */\n adapterWillCommit: function() {\n this.send('willCommit');\n },\n\n /**\n If the adapter did not return a hash in response to a commit,\n merge the changed attributes and relationships into the existing\n saved data.\n\n @method adapterDidCommit\n */\n adapterDidCommit: function(data) {\n set(this, 'isError', false);\n\n if (data) {\n this._data = data;\n } else {\n Ember.mixin(this._data, this._inFlightAttributes);\n }\n\n this._inFlightAttributes = {};\n\n this.send('didCommit');\n this.updateRecordArraysLater();\n\n if (!data) { return; }\n\n this.suspendRelationshipObservers(function() {\n this.notifyPropertyChange('data');\n });\n },\n\n /**\n @method adapterDidDirty\n @private\n */\n adapterDidDirty: function() {\n this.send('becomeDirty');\n this.updateRecordArraysLater();\n },\n\n dataDidChange: Ember.observer(function() {\n this.reloadHasManys();\n }, 'data'),\n\n reloadHasManys: function() {\n var relationships = get(this.constructor, 'relationshipsByName');\n this.updateRecordArraysLater();\n relationships.forEach(function(name, relationship) {\n if (this._data.links && this._data.links[name]) { return; }\n if (relationship.kind === 'hasMany') {\n this.hasManyDidChange(relationship.key);\n }\n }, this);\n },\n\n hasManyDidChange: function(key) {\n var hasMany = this._relationships[key];\n\n if (hasMany) {\n var records = this._data[key] || [];\n\n set(hasMany, 'content', Ember.A(records));\n set(hasMany, 'isLoaded', true);\n hasMany.trigger('didLoad');\n }\n },\n\n /**\n @method updateRecordArraysLater\n @private\n */\n updateRecordArraysLater: function() {\n Ember.run.once(this, this.updateRecordArrays);\n },\n\n /**\n @method setupData\n @private\n @param {Object} data\n @param {Boolean} partial the data should be merged into\n the existing data, not replace it.\n */\n setupData: function(data, partial) {\n if (partial) {\n Ember.merge(this._data, data);\n } else {\n this._data = data;\n }\n\n var relationships = this._relationships;\n\n this.eachRelationship(function(name, rel) {\n if (data.links && data.links[name]) { return; }\n if (rel.options.async) { relationships[name] = null; }\n });\n\n if (data) { this.pushedData(); }\n\n this.suspendRelationshipObservers(function() {\n this.notifyPropertyChange('data');\n });\n },\n\n materializeId: function(id) {\n set(this, 'id', id);\n },\n\n materializeAttributes: function(attributes) {\n Ember.assert(\"Must pass a hash of attributes to materializeAttributes\", !!attributes);\n merge(this._data, attributes);\n },\n\n materializeAttribute: function(name, value) {\n this._data[name] = value;\n },\n\n /**\n @method updateHasMany\n @private\n @param {String} name\n @param {Array} records\n */\n updateHasMany: function(name, records) {\n this._data[name] = records;\n this.hasManyDidChange(name);\n },\n\n /**\n @method updateBelongsTo\n @private\n @param {String} name\n @param {DS.Model} record\n */\n updateBelongsTo: function(name, record) {\n this._data[name] = record;\n },\n\n /**\n If the model `isDirty` this function will which discard any unsaved\n changes\n\n Example\n\n ```javascript\n record.get('name'); // 'Untitled Document'\n record.set('name', 'Doc 1');\n record.get('name'); // 'Doc 1'\n record.rollback();\n record.get('name'); // 'Untitled Document'\n ```\n\n @method rollback\n */\n rollback: function() {\n this._attributes = {};\n\n if (get(this, 'isError')) {\n this._inFlightAttributes = {};\n set(this, 'isError', false);\n }\n\n if (!get(this, 'isValid')) {\n this._inFlightAttributes = {};\n }\n\n this.send('rolledBack');\n\n this.suspendRelationshipObservers(function() {\n this.notifyPropertyChange('data');\n });\n },\n\n toStringExtension: function() {\n return get(this, 'id');\n },\n\n /**\n The goal of this method is to temporarily disable specific observers\n that take action in response to application changes.\n\n This allows the system to make changes (such as materialization and\n rollback) that should not trigger secondary behavior (such as setting an\n inverse relationship or marking records as dirty).\n\n The specific implementation will likely change as Ember proper provides\n better infrastructure for suspending groups of observers, and if Array\n observation becomes more unified with regular observers.\n\n @method suspendRelationshipObservers\n @private\n @param callback\n @param binding\n */\n suspendRelationshipObservers: function(callback, binding) {\n var observers = get(this.constructor, 'relationshipNames').belongsTo;\n var self = this;\n\n try {\n this._suspendedRelationships = true;\n Ember._suspendObservers(self, observers, null, 'belongsToDidChange', function() {\n Ember._suspendBeforeObservers(self, observers, null, 'belongsToWillChange', function() {\n callback.call(binding || self);\n });\n });\n } finally {\n this._suspendedRelationships = false;\n }\n },\n\n /**\n Save the record and persist any changes to the record to an\n extenal source via the adapter.\n\n Example\n\n ```javascript\n record.set('name', 'Tomster');\n record.save().then(function(){\n // Success callback\n }, function() {\n // Error callback\n });\n ```\n @method save\n @return {Promise} a promise that will be resolved when the adapter returns\n successfully or rejected if the adapter returns with an error.\n */\n save: function() {\n var promiseLabel = \"DS: Model#save \" + this;\n var resolver = Ember.RSVP.defer(promiseLabel);\n\n this.get('store').scheduleSave(this, resolver);\n this._inFlightAttributes = this._attributes;\n this._attributes = {};\n\n return DS.PromiseObject.create({ promise: resolver.promise });\n },\n\n /**\n Reload the record from the adapter.\n\n This will only work if the record has already finished loading\n and has not yet been modified (`isLoaded` but not `isDirty`,\n or `isSaving`).\n\n Example\n\n ```javascript\n App.ModelViewRoute = Ember.Route.extend({\n actions: {\n reload: function() {\n this.get('model').reload();\n }\n }\n });\n ```\n\n @method reload\n @return {Promise} a promise that will be resolved with the record when the\n adapter returns successfully or rejected if the adapter returns\n with an error.\n */\n reload: function() {\n set(this, 'isReloading', true);\n\n var record = this;\n\n var promiseLabel = \"DS: Model#reload of \" + this;\n var promise = new Ember.RSVP.Promise(function(resolve){\n record.send('reloadRecord', resolve);\n }, promiseLabel).then(function() {\n record.set('isReloading', false);\n record.set('isError', false);\n return record;\n }, function(reason) {\n record.set('isError', true);\n throw reason;\n }, \"DS: Model#reload complete, update flags\");\n\n return DS.PromiseObject.create({ promise: promise });\n },\n\n // FOR USE DURING COMMIT PROCESS\n\n adapterDidUpdateAttribute: function(attributeName, value) {\n\n // If a value is passed in, update the internal attributes and clear\n // the attribute cache so it picks up the new value. Otherwise,\n // collapse the current value into the internal attributes because\n // the adapter has acknowledged it.\n if (value !== undefined) {\n this._data[attributeName] = value;\n this.notifyPropertyChange(attributeName);\n } else {\n this._data[attributeName] = this._inFlightAttributes[attributeName];\n }\n\n this.updateRecordArraysLater();\n },\n\n /**\n @method adapterDidInvalidate\n @private\n */\n adapterDidInvalidate: function(errors) {\n var recordErrors = get(this, 'errors');\n function addError(name) {\n if (errors[name]) {\n recordErrors.add(name, errors[name]);\n }\n }\n\n this.eachAttribute(addError);\n this.eachRelationship(addError);\n },\n\n /**\n @method adapterDidError\n @private\n */\n adapterDidError: function() {\n this.send('becameError');\n set(this, 'isError', true);\n },\n\n /**\n Override the default event firing from Ember.Evented to\n also call methods with the given name.\n\n @method trigger\n @private\n @param name\n */\n trigger: function(name) {\n Ember.tryInvoke(this, name, [].slice.call(arguments, 1));\n this._super.apply(this, arguments);\n },\n\n triggerLater: function() {\n this._deferredTriggers.push(arguments);\n once(this, '_triggerDeferredTriggers');\n },\n\n _triggerDeferredTriggers: function() {\n for (var i=0, l=this._deferredTriggers.length; i<l; i++) {\n this.trigger.apply(this, this._deferredTriggers[i]);\n }\n\n this._deferredTriggers = [];\n }\n});\n\nDS.Model.reopenClass({\n\n /**\n Alias DS.Model's `create` method to `_create`. This allows us to create DS.Model\n instances from within the store, but if end users accidentally call `create()`\n (instead of `createRecord()`), we can raise an error.\n\n @method _create\n @private\n @static\n */\n _create: DS.Model.create,\n\n /**\n Override the class' `create()` method to raise an error. This\n prevents end users from inadvertently calling `create()` instead\n of `createRecord()`. The store is still able to create instances\n by calling the `_create()` method. To create an instance of a\n `DS.Model` use [store.createRecord](DS.Store.html#method_createRecord).\n\n @method create\n @private\n @static\n */\n create: function() {\n throw new Ember.Error(\"You should not call `create` on a model. Instead, call `store.createRecord` with the attributes you would like to set.\");\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/model/model");minispade.register('ember-data/system/model/states', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\n/*\n This file encapsulates the various states that a record can transition\n through during its lifecycle.\n*/\n/**\n ### State\n\n Each record has a `currentState` property that explicitly tracks what\n state a record is in at any given time. For instance, if a record is\n newly created and has not yet been sent to the adapter to be saved,\n it would be in the `root.loaded.created.uncommitted` state. If a\n record has had local modifications made to it that are in the\n process of being saved, the record would be in the\n `root.loaded.updated.inFlight` state. (These state paths will be\n explained in more detail below.)\n\n Events are sent by the record or its store to the record's\n `currentState` property. How the state reacts to these events is\n dependent on which state it is in. In some states, certain events\n will be invalid and will cause an exception to be raised.\n\n States are hierarchical and every state is a substate of the\n `RootState`. For example, a record can be in the\n `root.deleted.uncommitted` state, then transition into the\n `root.deleted.inFlight` state. If a child state does not implement\n an event handler, the state manager will attempt to invoke the event\n on all parent states until the root state is reached. The state\n hierarchy of a record is described in terms of a path string. You\n can determine a record's current state by getting the state's\n `stateName` property:\n\n ```javascript\n record.get('currentState.stateName');\n //=> \"root.created.uncommitted\"\n ```\n\n The hierarchy of valid states that ship with ember data looks like\n this:\n\n ```text\n * root\n * deleted\n * saved\n * uncommitted\n * inFlight\n * empty\n * loaded\n * created\n * uncommitted\n * inFlight\n * saved\n * updated\n * uncommitted\n * inFlight\n * loading\n ```\n\n The `DS.Model` states are themselves stateless. What we mean is\n that, the hierarchical states that each of *those* points to is a\n shared data structure. For performance reasons, instead of each\n record getting its own copy of the hierarchy of states, each record\n points to this global, immutable shared instance. How does a state\n know which record it should be acting on? We pass the record\n instance into the state's event handlers as the first argument.\n\n The record passed as the first parameter is where you should stash\n state about the record if needed; you should never store data on the state\n object itself.\n\n ### Events and Flags\n\n A state may implement zero or more events and flags.\n\n #### Events\n\n Events are named functions that are invoked when sent to a record. The\n record will first look for a method with the given name on the\n current state. If no method is found, it will search the current\n state's parent, and then its grandparent, and so on until reaching\n the top of the hierarchy. If the root is reached without an event\n handler being found, an exception will be raised. This can be very\n helpful when debugging new features.\n\n Here's an example implementation of a state with a `myEvent` event handler:\n\n ```javascript\n aState: DS.State.create({\n myEvent: function(manager, param) {\n console.log(\"Received myEvent with\", param);\n }\n })\n ```\n\n To trigger this event:\n\n ```javascript\n record.send('myEvent', 'foo');\n //=> \"Received myEvent with foo\"\n ```\n\n Note that an optional parameter can be sent to a record's `send()` method,\n which will be passed as the second parameter to the event handler.\n\n Events should transition to a different state if appropriate. This can be\n done by calling the record's `transitionTo()` method with a path to the\n desired state. The state manager will attempt to resolve the state path\n relative to the current state. If no state is found at that path, it will\n attempt to resolve it relative to the current state's parent, and then its\n parent, and so on until the root is reached. For example, imagine a hierarchy\n like this:\n\n * created\n * uncommitted <-- currentState\n * inFlight\n * updated\n * inFlight\n\n If we are currently in the `uncommitted` state, calling\n `transitionTo('inFlight')` would transition to the `created.inFlight` state,\n while calling `transitionTo('updated.inFlight')` would transition to\n the `updated.inFlight` state.\n\n Remember that *only events* should ever cause a state transition. You should\n never call `transitionTo()` from outside a state's event handler. If you are\n tempted to do so, create a new event and send that to the state manager.\n\n #### Flags\n\n Flags are Boolean values that can be used to introspect a record's current\n state in a more user-friendly way than examining its state path. For example,\n instead of doing this:\n\n ```javascript\n var statePath = record.get('stateManager.currentPath');\n if (statePath === 'created.inFlight') {\n doSomething();\n }\n ```\n\n You can say:\n\n ```javascript\n if (record.get('isNew') && record.get('isSaving')) {\n doSomething();\n }\n ```\n\n If your state does not set a value for a given flag, the value will\n be inherited from its parent (or the first place in the state hierarchy\n where it is defined).\n\n The current set of flags are defined below. If you want to add a new flag,\n in addition to the area below, you will also need to declare it in the\n `DS.Model` class.\n\n\n * [isEmpty](DS.Model.html#property_isEmpty)\n * [isLoading](DS.Model.html#property_isLoading)\n * [isLoaded](DS.Model.html#property_isLoaded)\n * [isDirty](DS.Model.html#property_isDirty)\n * [isSaving](DS.Model.html#property_isSaving)\n * [isDeleted](DS.Model.html#property_isDeleted)\n * [isNew](DS.Model.html#property_isNew)\n * [isValid](DS.Model.html#property_isValid)\n\n @namespace DS\n @class RootState\n*/\n\nvar hasDefinedProperties = function(object) {\n // Ignore internal property defined by simulated `Ember.create`.\n var names = Ember.keys(object);\n var i, l, name;\n for (i = 0, l = names.length; i < l; i++ ) {\n name = names[i];\n if (object.hasOwnProperty(name) && object[name]) { return true; }\n }\n\n return false;\n};\n\nvar didSetProperty = function(record, context) {\n if (context.value === context.originalValue) {\n delete record._attributes[context.name];\n record.send('propertyWasReset', context.name);\n } else if (context.value !== context.oldValue) {\n record.send('becomeDirty');\n }\n\n record.updateRecordArraysLater();\n};\n\n// Implementation notes:\n//\n// Each state has a boolean value for all of the following flags:\n//\n// * isLoaded: The record has a populated `data` property. When a\n// record is loaded via `store.find`, `isLoaded` is false\n// until the adapter sets it. When a record is created locally,\n// its `isLoaded` property is always true.\n// * isDirty: The record has local changes that have not yet been\n// saved by the adapter. This includes records that have been\n// created (but not yet saved) or deleted.\n// * isSaving: The record has been committed, but\n// the adapter has not yet acknowledged that the changes have\n// been persisted to the backend.\n// * isDeleted: The record was marked for deletion. When `isDeleted`\n// is true and `isDirty` is true, the record is deleted locally\n// but the deletion was not yet persisted. When `isSaving` is\n// true, the change is in-flight. When both `isDirty` and\n// `isSaving` are false, the change has persisted.\n// * isError: The adapter reported that it was unable to save\n// local changes to the backend. This may also result in the\n// record having its `isValid` property become false if the\n// adapter reported that server-side validations failed.\n// * isNew: The record was created on the client and the adapter\n// did not yet report that it was successfully saved.\n// * isValid: No client-side validations have failed and the\n// adapter did not report any server-side validation failures.\n\n// The dirty state is a abstract state whose functionality is\n// shared between the `created` and `updated` states.\n//\n// The deleted state shares the `isDirty` flag with the\n// subclasses of `DirtyState`, but with a very different\n// implementation.\n//\n// Dirty states have three child states:\n//\n// `uncommitted`: the store has not yet handed off the record\n// to be saved.\n// `inFlight`: the store has handed off the record to be saved,\n// but the adapter has not yet acknowledged success.\n// `invalid`: the record has invalid information and cannot be\n// send to the adapter yet.\nvar DirtyState = {\n initialState: 'uncommitted',\n\n // FLAGS\n isDirty: true,\n\n // SUBSTATES\n\n // When a record first becomes dirty, it is `uncommitted`.\n // This means that there are local pending changes, but they\n // have not yet begun to be saved, and are not invalid.\n uncommitted: {\n // EVENTS\n didSetProperty: didSetProperty,\n\n propertyWasReset: function(record, name) {\n var stillDirty = false;\n\n for (var prop in record._attributes) {\n stillDirty = true;\n break;\n }\n\n if (!stillDirty) { record.send('rolledBack'); }\n },\n\n pushedData: Ember.K,\n\n becomeDirty: Ember.K,\n\n willCommit: function(record) {\n record.transitionTo('inFlight');\n },\n\n reloadRecord: function(record, resolve) {\n resolve(get(record, 'store').reloadRecord(record));\n },\n\n rolledBack: function(record) {\n record.transitionTo('loaded.saved');\n },\n\n becameInvalid: function(record) {\n record.transitionTo('invalid');\n },\n\n rollback: function(record) {\n record.rollback();\n }\n },\n\n // Once a record has been handed off to the adapter to be\n // saved, it is in the 'in flight' state. Changes to the\n // record cannot be made during this window.\n inFlight: {\n // FLAGS\n isSaving: true,\n\n // EVENTS\n didSetProperty: didSetProperty,\n becomeDirty: Ember.K,\n pushedData: Ember.K,\n\n // TODO: More robust semantics around save-while-in-flight\n willCommit: Ember.K,\n\n didCommit: function(record) {\n var dirtyType = get(this, 'dirtyType');\n\n record.transitionTo('saved');\n record.send('invokeLifecycleCallbacks', dirtyType);\n },\n\n becameInvalid: function(record) {\n record.transitionTo('invalid');\n record.send('invokeLifecycleCallbacks');\n },\n\n becameError: function(record) {\n record.transitionTo('uncommitted');\n record.triggerLater('becameError', record);\n }\n },\n\n // A record is in the `invalid` state when its client-side\n // invalidations have failed, or if the adapter has indicated\n // the the record failed server-side invalidations.\n invalid: {\n // FLAGS\n isValid: false,\n\n // EVENTS\n deleteRecord: function(record) {\n record.transitionTo('deleted.uncommitted');\n record.clearRelationships();\n },\n\n didSetProperty: function(record, context) {\n get(record, 'errors').remove(context.name);\n\n didSetProperty(record, context);\n },\n\n becomeDirty: Ember.K,\n\n rolledBack: function(record) {\n get(record, 'errors').clear();\n },\n\n becameValid: function(record) {\n record.transitionTo('uncommitted');\n },\n\n invokeLifecycleCallbacks: function(record) {\n record.triggerLater('becameInvalid', record);\n }\n }\n};\n\n// The created and updated states are created outside the state\n// chart so we can reopen their substates and add mixins as\n// necessary.\n\nfunction deepClone(object) {\n var clone = {}, value;\n\n for (var prop in object) {\n value = object[prop];\n if (value && typeof value === 'object') {\n clone[prop] = deepClone(value);\n } else {\n clone[prop] = value;\n }\n }\n\n return clone;\n}\n\nfunction mixin(original, hash) {\n for (var prop in hash) {\n original[prop] = hash[prop];\n }\n\n return original;\n}\n\nfunction dirtyState(options) {\n var newState = deepClone(DirtyState);\n return mixin(newState, options);\n}\n\nvar createdState = dirtyState({\n dirtyType: 'created',\n\n // FLAGS\n isNew: true\n});\n\ncreatedState.uncommitted.rolledBack = function(record) {\n record.transitionTo('deleted.saved');\n};\n\nvar updatedState = dirtyState({\n dirtyType: 'updated'\n});\n\ncreatedState.uncommitted.deleteRecord = function(record) {\n record.clearRelationships();\n record.transitionTo('deleted.saved');\n};\n\ncreatedState.uncommitted.rollback = function(record) {\n DirtyState.uncommitted.rollback.apply(this, arguments);\n record.transitionTo('deleted.saved');\n};\n\nupdatedState.uncommitted.deleteRecord = function(record) {\n record.transitionTo('deleted.uncommitted');\n record.clearRelationships();\n};\n\nvar RootState = {\n // FLAGS\n isEmpty: false,\n isLoading: false,\n isLoaded: false,\n isDirty: false,\n isSaving: false,\n isDeleted: false,\n isNew: false,\n isValid: true,\n\n // DEFAULT EVENTS\n\n // Trying to roll back if you're not in the dirty state\n // doesn't change your state. For example, if you're in the\n // in-flight state, rolling back the record doesn't move\n // you out of the in-flight state.\n rolledBack: Ember.K,\n\n propertyWasReset: Ember.K,\n\n // SUBSTATES\n\n // A record begins its lifecycle in the `empty` state.\n // If its data will come from the adapter, it will\n // transition into the `loading` state. Otherwise, if\n // the record is being created on the client, it will\n // transition into the `created` state.\n empty: {\n isEmpty: true,\n\n // EVENTS\n loadingData: function(record, promise) {\n record._loadingPromise = promise;\n record.transitionTo('loading');\n },\n\n loadedData: function(record) {\n record.transitionTo('loaded.created.uncommitted');\n\n record.suspendRelationshipObservers(function() {\n record.notifyPropertyChange('data');\n });\n },\n\n pushedData: function(record) {\n record.transitionTo('loaded.saved');\n record.triggerLater('didLoad');\n }\n },\n\n // A record enters this state when the store askes\n // the adapter for its data. It remains in this state\n // until the adapter provides the requested data.\n //\n // Usually, this process is asynchronous, using an\n // XHR to retrieve the data.\n loading: {\n // FLAGS\n isLoading: true,\n\n exit: function(record) {\n record._loadingPromise = null;\n },\n\n // EVENTS\n pushedData: function(record) {\n record.transitionTo('loaded.saved');\n record.triggerLater('didLoad');\n set(record, 'isError', false);\n },\n\n becameError: function(record) {\n record.triggerLater('becameError', record);\n },\n\n notFound: function(record) {\n record.transitionTo('empty');\n }\n },\n\n // A record enters this state when its data is populated.\n // Most of a record's lifecycle is spent inside substates\n // of the `loaded` state.\n loaded: {\n initialState: 'saved',\n\n // FLAGS\n isLoaded: true,\n\n // SUBSTATES\n\n // If there are no local changes to a record, it remains\n // in the `saved` state.\n saved: {\n setup: function(record) {\n var attrs = record._attributes,\n isDirty = false;\n\n for (var prop in attrs) {\n if (attrs.hasOwnProperty(prop)) {\n isDirty = true;\n break;\n }\n }\n\n if (isDirty) {\n record.adapterDidDirty();\n }\n },\n\n // EVENTS\n didSetProperty: didSetProperty,\n\n pushedData: Ember.K,\n\n becomeDirty: function(record) {\n record.transitionTo('updated.uncommitted');\n },\n\n willCommit: function(record) {\n record.transitionTo('updated.inFlight');\n },\n\n reloadRecord: function(record, resolve) {\n resolve(get(record, 'store').reloadRecord(record));\n },\n\n deleteRecord: function(record) {\n record.transitionTo('deleted.uncommitted');\n record.clearRelationships();\n },\n\n unloadRecord: function(record) {\n // clear relationships before moving to deleted state\n // otherwise it fails\n record.clearRelationships();\n record.transitionTo('deleted.saved');\n },\n\n didCommit: function(record) {\n record.send('invokeLifecycleCallbacks', get(record, 'lastDirtyType'));\n },\n\n // loaded.saved.notFound would be triggered by a failed\n // `reload()` on an unchanged record\n notFound: Ember.K\n\n },\n\n // A record is in this state after it has been locally\n // created but before the adapter has indicated that\n // it has been saved.\n created: createdState,\n\n // A record is in this state if it has already been\n // saved to the server, but there are new local changes\n // that have not yet been saved.\n updated: updatedState\n },\n\n // A record is in this state if it was deleted from the store.\n deleted: {\n initialState: 'uncommitted',\n dirtyType: 'deleted',\n\n // FLAGS\n isDeleted: true,\n isLoaded: true,\n isDirty: true,\n\n // TRANSITIONS\n setup: function(record) {\n record.updateRecordArrays();\n },\n\n // SUBSTATES\n\n // When a record is deleted, it enters the `start`\n // state. It will exit this state when the record\n // starts to commit.\n uncommitted: {\n\n // EVENTS\n\n willCommit: function(record) {\n record.transitionTo('inFlight');\n },\n\n rollback: function(record) {\n record.rollback();\n },\n\n becomeDirty: Ember.K,\n deleteRecord: Ember.K,\n\n rolledBack: function(record) {\n record.transitionTo('loaded.saved');\n }\n },\n\n // After a record starts committing, but\n // before the adapter indicates that the deletion\n // has saved to the server, a record is in the\n // `inFlight` substate of `deleted`.\n inFlight: {\n // FLAGS\n isSaving: true,\n\n // EVENTS\n\n // TODO: More robust semantics around save-while-in-flight\n willCommit: Ember.K,\n didCommit: function(record) {\n record.transitionTo('saved');\n\n record.send('invokeLifecycleCallbacks');\n },\n\n becameError: function(record) {\n record.transitionTo('uncommitted');\n record.triggerLater('becameError', record);\n }\n },\n\n // Once the adapter indicates that the deletion has\n // been saved, the record enters the `saved` substate\n // of `deleted`.\n saved: {\n // FLAGS\n isDirty: false,\n\n setup: function(record) {\n var store = get(record, 'store');\n store.dematerializeRecord(record);\n },\n\n invokeLifecycleCallbacks: function(record) {\n record.triggerLater('didDelete', record);\n record.triggerLater('didCommit', record);\n }\n }\n },\n\n invokeLifecycleCallbacks: function(record, dirtyType) {\n if (dirtyType === 'created') {\n record.triggerLater('didCreate', record);\n } else {\n record.triggerLater('didUpdate', record);\n }\n\n record.triggerLater('didCommit', record);\n }\n};\n\nfunction wireState(object, parent, name) {\n /*jshint proto:true*/\n // TODO: Use Object.create and copy instead\n object = mixin(parent ? Ember.create(parent) : {}, object);\n object.parentState = parent;\n object.stateName = name;\n\n for (var prop in object) {\n if (!object.hasOwnProperty(prop) || prop === 'parentState' || prop === 'stateName') { continue; }\n if (typeof object[prop] === 'object') {\n object[prop] = wireState(object[prop], object, name + \".\" + prop);\n }\n }\n\n return object;\n}\n\nRootState = wireState(RootState, null, \"root\");\n\nDS.RootState = RootState;\n\n})();\n//@ sourceURL=ember-data/system/model/states");minispade.register('ember-data/system/record_array_manager', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar once = Ember.run.once;\nvar forEach = Ember.EnumerableUtils.forEach;\n\n/**\n @class RecordArrayManager\n @namespace DS\n @private\n @extends Ember.Object\n*/\nDS.RecordArrayManager = Ember.Object.extend({\n init: function() {\n this.filteredRecordArrays = Ember.MapWithDefault.create({\n defaultValue: function() { return []; }\n });\n\n this.changedRecords = [];\n },\n\n recordDidChange: function(record) {\n this.changedRecords.push(record);\n once(this, this.updateRecordArrays);\n },\n\n recordArraysForRecord: function(record) {\n record._recordArrays = record._recordArrays || Ember.OrderedSet.create();\n return record._recordArrays;\n },\n\n /**\n This method is invoked whenever data is loaded into the store by the\n adapter or updated by the adapter, or when a record has changed.\n\n It updates all record arrays that a record belongs to.\n\n To avoid thrashing, it only runs at most once per run loop.\n\n @method updateRecordArrays\n @param {Class} type\n @param {Number|String} clientId\n */\n updateRecordArrays: function() {\n forEach(this.changedRecords, function(record) {\n if (get(record, 'isDeleted')) {\n this._recordWasDeleted(record);\n } else {\n this._recordWasChanged(record);\n }\n }, this);\n\n this.changedRecords = [];\n },\n\n _recordWasDeleted: function (record) {\n var recordArrays = record._recordArrays;\n\n if (!recordArrays) { return; }\n\n forEach(recordArrays, function(array) {\n array.removeRecord(record);\n });\n },\n\n _recordWasChanged: function (record) {\n var type = record.constructor,\n recordArrays = this.filteredRecordArrays.get(type),\n filter;\n\n forEach(recordArrays, function(array) {\n filter = get(array, 'filterFunction');\n this.updateRecordArray(array, filter, type, record);\n }, this);\n\n // loop through all manyArrays containing an unloaded copy of this\n // clientId and notify them that the record was loaded.\n var manyArrays = record._loadingRecordArrays;\n\n if (manyArrays) {\n for (var i=0, l=manyArrays.length; i<l; i++) {\n manyArrays[i].loadedRecord();\n }\n\n record._loadingRecordArrays = [];\n }\n },\n\n /**\n Update an individual filter.\n\n @method updateRecordArray\n @param {DS.FilteredRecordArray} array\n @param {Function} filter\n @param {Class} type\n @param {Number|String} clientId\n */\n updateRecordArray: function(array, filter, type, record) {\n var shouldBeInArray;\n\n if (!filter) {\n shouldBeInArray = true;\n } else {\n shouldBeInArray = filter(record);\n }\n\n var recordArrays = this.recordArraysForRecord(record);\n\n if (shouldBeInArray) {\n recordArrays.add(array);\n array.addRecord(record);\n } else if (!shouldBeInArray) {\n recordArrays.remove(array);\n array.removeRecord(record);\n }\n },\n\n /**\n This method is invoked if the `filterFunction` property is\n changed on a `DS.FilteredRecordArray`.\n\n It essentially re-runs the filter from scratch. This same\n method is invoked when the filter is created in th first place.\n\n @method updateFilter\n @param array\n @param type\n @param filter\n */\n updateFilter: function(array, type, filter) {\n var typeMap = this.store.typeMapFor(type),\n records = typeMap.records, record;\n\n for (var i=0, l=records.length; i<l; i++) {\n record = records[i];\n\n if (!get(record, 'isDeleted') && !get(record, 'isEmpty')) {\n this.updateRecordArray(array, filter, type, record);\n }\n }\n },\n\n /**\n Create a `DS.ManyArray` for a type and list of record references, and index\n the `ManyArray` under each reference. This allows us to efficiently remove\n records from `ManyArray`s when they are deleted.\n\n @method createManyArray\n @param {Class} type\n @param {Array} references\n @return {DS.ManyArray}\n */\n createManyArray: function(type, records) {\n var manyArray = DS.ManyArray.create({\n type: type,\n content: records,\n store: this.store\n });\n\n forEach(records, function(record) {\n var arrays = this.recordArraysForRecord(record);\n arrays.add(manyArray);\n }, this);\n\n return manyArray;\n },\n\n /**\n Create a `DS.RecordArray` for a type and register it for updates.\n\n @method createRecordArray\n @param {Class} type\n @return {DS.RecordArray}\n */\n createRecordArray: function(type) {\n var array = DS.RecordArray.create({\n type: type,\n content: Ember.A(),\n store: this.store,\n isLoaded: true\n });\n\n this.registerFilteredRecordArray(array, type);\n\n return array;\n },\n\n /**\n Create a `DS.FilteredRecordArray` for a type and register it for updates.\n\n @method createFilteredRecordArray\n @param {Class} type\n @param {Function} filter\n @return {DS.FilteredRecordArray}\n */\n createFilteredRecordArray: function(type, filter) {\n var array = DS.FilteredRecordArray.create({\n type: type,\n content: Ember.A(),\n store: this.store,\n manager: this,\n filterFunction: filter\n });\n\n this.registerFilteredRecordArray(array, type, filter);\n\n return array;\n },\n\n /**\n Create a `DS.AdapterPopulatedRecordArray` for a type with given query.\n\n @method createAdapterPopulatedRecordArray\n @param {Class} type\n @param {Object} query\n @return {DS.AdapterPopulatedRecordArray}\n */\n createAdapterPopulatedRecordArray: function(type, query) {\n return DS.AdapterPopulatedRecordArray.create({\n type: type,\n query: query,\n content: Ember.A(),\n store: this.store\n });\n },\n\n /**\n Register a RecordArray for a given type to be backed by\n a filter function. This will cause the array to update\n automatically when records of that type change attribute\n values or states.\n\n @method registerFilteredRecordArray\n @param {DS.RecordArray} array\n @param {Class} type\n @param {Function} filter\n */\n registerFilteredRecordArray: function(array, type, filter) {\n var recordArrays = this.filteredRecordArrays.get(type);\n recordArrays.push(array);\n\n this.updateFilter(array, type, filter);\n },\n\n // Internally, we maintain a map of all unloaded IDs requested by\n // a ManyArray. As the adapter loads data into the store, the\n // store notifies any interested ManyArrays. When the ManyArray's\n // total number of loading records drops to zero, it becomes\n // `isLoaded` and fires a `didLoad` event.\n registerWaitingRecordArray: function(record, array) {\n var loadingRecordArrays = record._loadingRecordArrays || [];\n loadingRecordArrays.push(array);\n record._loadingRecordArrays = loadingRecordArrays;\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/record_array_manager");minispade.register('ember-data/system/record_arrays', "(function() {/**\n @module ember-data\n*/\nminispade.require('ember-data/system/record_arrays/record_array');\nminispade.require('ember-data/system/record_arrays/filtered_record_array');\nminispade.require('ember-data/system/record_arrays/adapter_populated_record_array');\nminispade.require('ember-data/system/record_arrays/many_array');\n\n})();\n//@ sourceURL=ember-data/system/record_arrays");minispade.register('ember-data/system/record_arrays/adapter_populated_record_array', "(function() {minispade.require(\"ember-data/system/record_arrays/record_array\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n Represents an ordered list of records whose order and membership is\n determined by the adapter. For example, a query sent to the adapter\n may trigger a search on the server, whose results would be loaded\n into an instance of the `AdapterPopulatedRecordArray`.\n\n @class AdapterPopulatedRecordArray\n @namespace DS\n @extends DS.RecordArray\n*/\nDS.AdapterPopulatedRecordArray = DS.RecordArray.extend({\n query: null,\n\n replace: function() {\n var type = get(this, 'type').toString();\n throw new Error(\"The result of a server query (on \" + type + \") is immutable.\");\n },\n\n /**\n @method load\n @private\n @param {Array} data\n */\n load: function(data) {\n var store = get(this, 'store'),\n type = get(this, 'type'),\n records = store.pushMany(type, data),\n meta = store.metadataFor(type);\n\n this.setProperties({\n content: Ember.A(records),\n isLoaded: true,\n meta: meta\n });\n\n // TODO: does triggering didLoad event should be the last action of the runLoop?\n Ember.run.once(this, 'trigger', 'didLoad');\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/adapter_populated_record_array");minispade.register('ember-data/system/record_arrays/filtered_record_array', "(function() {minispade.require(\"ember-data/system/record_arrays/record_array\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get;\n\n/**\n Represents a list of records whose membership is determined by the\n store. As records are created, loaded, or modified, the store\n evaluates them to determine if they should be part of the record\n array.\n\n @class FilteredRecordArray\n @namespace DS\n @extends DS.RecordArray\n*/\nDS.FilteredRecordArray = DS.RecordArray.extend({\n /**\n The filterFunction is a function used to test records from the store to\n determine if they should be part of the record array.\n\n Example\n\n ```javascript\n var allPeople = store.all('person');\n allPeople.mapBy('name'); // [\"Tom Dale\", \"Yehuda Katz\", \"Trek Glowacki\"]\n\n var people = store.filter('person', function(person) {\n if (person.get('name').match(/Katz$/)) { return true; }\n });\n people.mapBy('name'); // [\"Yehuda Katz\"]\n\n var notKatzFilter = function(person) {\n return !person.get('name').match(/Katz$/);\n };\n people.set('filterFunction', notKatzFilter);\n people.mapBy('name'); // [\"Tom Dale\", \"Trek Glowacki\"]\n ```\n\n @method filterFunction\n @param {DS.Model} record\n @return {Boolean} `true` if the record should be in the array\n */\n filterFunction: null,\n isLoaded: true,\n\n replace: function() {\n var type = get(this, 'type').toString();\n throw new Error(\"The result of a client-side filter (on \" + type + \") is immutable.\");\n },\n\n /**\n @method updateFilter\n @private\n */\n updateFilter: Ember.observer(function() {\n var manager = get(this, 'manager');\n manager.updateFilter(this, get(this, 'type'), get(this, 'filterFunction'));\n }, 'filterFunction')\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/filtered_record_array");minispade.register('ember-data/system/record_arrays/many_array', "(function() {minispade.require(\"ember-data/system/record_arrays/record_array\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar map = Ember.EnumerableUtils.map;\n\n/**\n A `ManyArray` is a `RecordArray` that represents the contents of a has-many\n relationship.\n\n The `ManyArray` is instantiated lazily the first time the relationship is\n requested.\n\n ### Inverses\n\n Often, the relationships in Ember Data applications will have\n an inverse. For example, imagine the following models are\n defined:\n\n ```javascript\n App.Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n App.Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n ```\n\n If you created a new instance of `App.Post` and added\n a `App.Comment` record to its `comments` has-many\n relationship, you would expect the comment's `post`\n property to be set to the post that contained\n the has-many.\n\n We call the record to which a relationship belongs the\n relationship's _owner_.\n\n @class ManyArray\n @namespace DS\n @extends DS.RecordArray\n*/\nDS.ManyArray = DS.RecordArray.extend({\n init: function() {\n this._super.apply(this, arguments);\n this._changesToSync = Ember.OrderedSet.create();\n },\n\n /**\n The property name of the relationship\n\n @property {String} name\n @private\n */\n name: null,\n\n /**\n The record to which this relationship belongs.\n\n @property {DS.Model} owner\n @private\n */\n owner: null,\n\n /**\n `true` if the relationship is polymorphic, `false` otherwise.\n\n @property {Boolean} isPolymorphic\n @private\n */\n isPolymorphic: false,\n\n // LOADING STATE\n\n isLoaded: false,\n\n /**\n Used for async `hasMany` arrays\n to keep track of when they will resolve.\n\n @property {Ember.RSVP.Promise} promise\n @private\n */\n promise: null,\n\n /**\n @method loadingRecordsCount\n @param {Number} count\n @private\n */\n loadingRecordsCount: function(count) {\n this.loadingRecordsCount = count;\n },\n\n /**\n @method loadedRecord\n @private\n */\n loadedRecord: function() {\n this.loadingRecordsCount--;\n if (this.loadingRecordsCount === 0) {\n set(this, 'isLoaded', true);\n this.trigger('didLoad');\n }\n },\n\n /**\n @method fetch\n @private\n */\n fetch: function() {\n var records = get(this, 'content'),\n store = get(this, 'store'),\n owner = get(this, 'owner'),\n resolver = Ember.RSVP.defer(\"DS: ManyArray#fetch \" + get(this, 'type'));\n\n var unloadedRecords = records.filterProperty('isEmpty', true);\n store.fetchMany(unloadedRecords, owner, resolver);\n },\n\n // Overrides Ember.Array's replace method to implement\n replaceContent: function(index, removed, added) {\n // Map the array of record objects into an array of client ids.\n added = map(added, function(record) {\n Ember.assert(\"You cannot add '\" + record.constructor.typeKey + \"' records to this relationship (only '\" + this.type.typeKey + \"' allowed)\", !this.type || record instanceof this.type);\n return record;\n }, this);\n\n this._super(index, removed, added);\n },\n\n arrangedContentDidChange: function() {\n Ember.run.once(this, 'fetch');\n },\n\n arrayContentWillChange: function(index, removed, added) {\n var owner = get(this, 'owner'),\n name = get(this, 'name');\n\n if (!owner._suspendedRelationships) {\n // This code is the first half of code that continues inside\n // of arrayContentDidChange. It gets or creates a change from\n // the child object, adds the current owner as the old\n // parent if this is the first time the object was removed\n // from a ManyArray, and sets `newParent` to null.\n //\n // Later, if the object is added to another ManyArray,\n // the `arrayContentDidChange` will set `newParent` on\n // the change.\n for (var i=index; i<index+removed; i++) {\n var record = get(this, 'content').objectAt(i);\n\n var change = DS.RelationshipChange.createChange(owner, record, get(this, 'store'), {\n parentType: owner.constructor,\n changeType: \"remove\",\n kind: \"hasMany\",\n key: name\n });\n\n this._changesToSync.add(change);\n }\n }\n\n return this._super.apply(this, arguments);\n },\n\n arrayContentDidChange: function(index, removed, added) {\n this._super.apply(this, arguments);\n\n var owner = get(this, 'owner'),\n name = get(this, 'name'),\n store = get(this, 'store');\n\n if (!owner._suspendedRelationships) {\n // This code is the second half of code that started in\n // `arrayContentWillChange`. It gets or creates a change\n // from the child object, and adds the current owner as\n // the new parent.\n for (var i=index; i<index+added; i++) {\n var record = get(this, 'content').objectAt(i);\n\n var change = DS.RelationshipChange.createChange(owner, record, store, {\n parentType: owner.constructor,\n changeType: \"add\",\n kind:\"hasMany\",\n key: name\n });\n change.hasManyName = name;\n\n this._changesToSync.add(change);\n }\n\n // We wait until the array has finished being\n // mutated before syncing the OneToManyChanges created\n // in arrayContentWillChange, so that the array\n // membership test in the sync() logic operates\n // on the final results.\n this._changesToSync.forEach(function(change) {\n change.sync();\n });\n\n this._changesToSync.clear();\n }\n },\n\n /**\n Create a child record within the owner\n\n @method createRecord\n @private\n @param {Object} hash\n @return {DS.Model} record\n */\n createRecord: function(hash) {\n var owner = get(this, 'owner'),\n store = get(owner, 'store'),\n type = get(this, 'type'),\n record;\n\n Ember.assert(\"You cannot add '\" + type.typeKey + \"' records to this polymorphic relationship.\", !get(this, 'isPolymorphic'));\n\n record = store.createRecord.call(store, type, hash);\n this.pushObject(record);\n\n return record;\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/many_array");minispade.register('ember-data/system/record_arrays/record_array', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n A record array is an array that contains records of a certain type. The record\n array materializes records as needed when they are retrieved for the first\n time. You should not create record arrays yourself. Instead, an instance of\n `DS.RecordArray` or its subclasses will be returned by your application's store\n in response to queries.\n\n @class RecordArray\n @namespace DS\n @extends Ember.ArrayProxy\n @uses Ember.Evented\n*/\n\nDS.RecordArray = Ember.ArrayProxy.extend(Ember.Evented, {\n /**\n The model type contained by this record array.\n\n @property type\n @type DS.Model\n */\n type: null,\n\n /**\n The array of client ids backing the record array. When a\n record is requested from the record array, the record\n for the client id at the same index is materialized, if\n necessary, by the store.\n\n @property content\n @private\n @type Ember.Array\n */\n content: null,\n\n /**\n The flag to signal a `RecordArray` is currently loading data.\n\n Example\n\n ```javascript\n var people = store.all(App.Person);\n people.get('isLoaded'); // true\n ```\n\n @property isLoaded\n @type Boolean\n */\n isLoaded: false,\n /**\n The flag to signal a `RecordArray` is currently loading data.\n\n Example\n\n ```javascript\n var people = store.all(App.Person);\n people.get('isUpdating'); // false\n people.update();\n people.get('isUpdating'); // true\n ```\n\n @property isUpdating\n @type Boolean\n */\n isUpdating: false,\n\n /**\n The store that created this record array.\n\n @property store\n @private\n @type DS.Store\n */\n store: null,\n\n /**\n Retrieves an object from the content by index.\n\n @method objectAtContent\n @private\n @param {Number} index\n @return {DS.Model} record\n */\n objectAtContent: function(index) {\n var content = get(this, 'content');\n\n return content.objectAt(index);\n },\n\n /**\n Used to get the latest version of all of the records in this array\n from the adapter.\n\n Example\n\n ```javascript\n var people = store.all(App.Person);\n people.get('isUpdating'); // false\n people.update();\n people.get('isUpdating'); // true\n ```\n\n @method update\n */\n update: function() {\n if (get(this, 'isUpdating')) { return; }\n\n var store = get(this, 'store'),\n type = get(this, 'type');\n\n store.fetchAll(type, this);\n },\n\n /**\n Adds a record to the `RecordArray`.\n\n @method addRecord\n @private\n @param {DS.Model} record\n */\n addRecord: function(record) {\n get(this, 'content').addObject(record);\n },\n\n /**\n Removes a record to the `RecordArray`.\n\n @method removeRecord\n @private\n @param {DS.Model} record\n */\n removeRecord: function(record) {\n get(this, 'content').removeObject(record);\n },\n\n /**\n Saves all of the records in the `RecordArray`.\n\n Example\n\n ```javascript\n var messages = store.all(App.Message);\n messages.forEach(function(message) {\n message.set('hasBeenSeen', true);\n });\n messages.save();\n ```\n\n @method save\n @return {DS.PromiseArray} promise\n */\n save: function() {\n var promiseLabel = \"DS: RecordArray#save \" + get(this, 'type');\n var promise = Ember.RSVP.all(this.invoke(\"save\"), promiseLabel).then(function(array) {\n return Ember.A(array);\n }, null, \"DS: RecordArray#save apply Ember.NativeArray\");\n\n return DS.PromiseArray.create({ promise: promise });\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/record_array");minispade.register('ember-data/system/relationships', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/system/relationships/belongs_to\");\nminispade.require(\"ember-data/system/relationships/has_many\");\nminispade.require(\"ember-data/system/relationships/ext\");\n\n})();\n//@ sourceURL=ember-data/system/relationships");minispade.register('ember-data/system/relationships/belongs_to', "(function() {var get = Ember.get, set = Ember.set,\n isNone = Ember.isNone;\n\n/**\n @module ember-data\n*/\n\nfunction asyncBelongsTo(type, options, meta) {\n return Ember.computed(function(key, value) {\n var data = get(this, 'data'),\n store = get(this, 'store'),\n promiseLabel = \"DS: Async belongsTo \" + this + \" : \" + key;\n\n if (arguments.length === 2) {\n Ember.assert(\"You can only add a '\" + type + \"' record to this relationship\", !value || value instanceof store.modelFor(type));\n return value === undefined ? null : DS.PromiseObject.create({ promise: Ember.RSVP.resolve(value, promiseLabel) });\n }\n\n var link = data.links && data.links[key],\n belongsTo = data[key];\n\n if(!isNone(belongsTo)) {\n var promise = store.fetchRecord(belongsTo) || Ember.RSVP.resolve(belongsTo, promiseLabel);\n return DS.PromiseObject.create({ promise: promise});\n } else if (link) {\n var resolver = Ember.RSVP.defer(\"DS: Async belongsTo (link) \" + this + \" : \" + key);\n store.findBelongsTo(this, link, meta, resolver);\n return DS.PromiseObject.create({ promise: resolver.promise });\n } else {\n return null;\n }\n }).property('data').meta(meta);\n}\n\n/**\n `DS.belongsTo` is used to define One-To-One and One-To-Many\n relationships on a [DS.Model](DS.Model.html).\n\n\n `DS.belongsTo` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `async`: A boolean value used to explicitly declare this to be an async relationship.\n - `inverse`: A string used to identify the inverse property on a\n related model in a One-To-Many relationship. See [Explicit Inverses](#toc_explicit-inverses)\n\n #### One-To-One\n To declare a one-to-one relationship between two models, use\n `DS.belongsTo`:\n\n ```javascript\n App.User = DS.Model.extend({\n profile: DS.belongsTo('profile')\n });\n\n App.Profile = DS.Model.extend({\n user: DS.belongsTo('user')\n });\n ```\n\n #### One-To-Many\n To declare a one-to-many relationship between two models, use\n `DS.belongsTo` in combination with `DS.hasMany`, like this:\n\n ```javascript\n App.Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n App.Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n ```\n\n @namespace\n @method belongsTo\n @for DS\n @param {String or DS.Model} type the model type of the relationship\n @param {Object} options a hash of options\n @return {Ember.computed} relationship\n*/\nDS.belongsTo = function(type, options) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n } else {\n Ember.assert(\"The first argument DS.belongsTo must be a model type or string, like DS.belongsTo(App.Person)\", !!type && (typeof type === 'string' || DS.Model.detect(type)));\n }\n\n options = options || {};\n\n var meta = { type: type, isRelationship: true, options: options, kind: 'belongsTo' };\n\n if (options.async) {\n return asyncBelongsTo(type, options, meta);\n }\n\n return Ember.computed(function(key, value) {\n var data = get(this, 'data'),\n store = get(this, 'store'), belongsTo, typeClass;\n\n if (typeof type === 'string') {\n typeClass = store.modelFor(type);\n } else {\n typeClass = type;\n }\n\n if (arguments.length === 2) {\n Ember.assert(\"You can only add a '\" + type + \"' record to this relationship\", !value || value instanceof typeClass);\n return value === undefined ? null : value;\n }\n\n belongsTo = data[key];\n\n if (isNone(belongsTo)) { return null; }\n\n store.fetchRecord(belongsTo);\n\n return belongsTo;\n }).property('data').meta(meta);\n};\n\n/**\n These observers observe all `belongsTo` relationships on the record. See\n `relationships/ext` to see how these observers get their dependencies.\n\n @class Model\n @namespace DS\n*/\nDS.Model.reopen({\n\n /**\n @method belongsToWillChange\n @private\n @static\n @param record\n @param key\n */\n belongsToWillChange: Ember.beforeObserver(function(record, key) {\n if (get(record, 'isLoaded')) {\n var oldParent = get(record, key);\n\n if (oldParent) {\n var store = get(record, 'store'),\n change = DS.RelationshipChange.createChange(record, oldParent, store, { key: key, kind: \"belongsTo\", changeType: \"remove\" });\n\n change.sync();\n this._changesToSync[key] = change;\n }\n }\n }),\n\n /**\n @method belongsToDidChange\n @private\n @static\n @param record\n @param key\n */\n belongsToDidChange: Ember.immediateObserver(function(record, key) {\n if (get(record, 'isLoaded')) {\n var newParent = get(record, key);\n\n if (newParent) {\n var store = get(record, 'store'),\n change = DS.RelationshipChange.createChange(record, newParent, store, { key: key, kind: \"belongsTo\", changeType: \"add\" });\n\n change.sync();\n }\n }\n\n delete this._changesToSync[key];\n })\n});\n\n})();\n//@ sourceURL=ember-data/system/relationships/belongs_to");minispade.register('ember-data/system/relationships/ext', "(function() {minispade.require(\"ember-inflector/system\");\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n @module ember-data\n*/\n\n/*\n This file defines several extensions to the base `DS.Model` class that\n add support for one-to-many relationships.\n*/\n\n/**\n @class Model\n @namespace DS\n*/\nDS.Model.reopen({\n\n /**\n This Ember.js hook allows an object to be notified when a property\n is defined.\n\n In this case, we use it to be notified when an Ember Data user defines a\n belongs-to relationship. In that case, we need to set up observers for\n each one, allowing us to track relationship changes and automatically\n reflect changes in the inverse has-many array.\n\n This hook passes the class being set up, as well as the key and value\n being defined. So, for example, when the user does this:\n\n ```javascript\n DS.Model.extend({\n parent: DS.belongsTo('user')\n });\n ```\n\n This hook would be called with \"parent\" as the key and the computed\n property returned by `DS.belongsTo` as the value.\n\n @method didDefineProperty\n @param proto\n @param key\n @param value\n */\n didDefineProperty: function(proto, key, value) {\n // Check if the value being set is a computed property.\n if (value instanceof Ember.Descriptor) {\n\n // If it is, get the metadata for the relationship. This is\n // populated by the `DS.belongsTo` helper when it is creating\n // the computed property.\n var meta = value.meta();\n\n if (meta.isRelationship && meta.kind === 'belongsTo') {\n Ember.addObserver(proto, key, null, 'belongsToDidChange');\n Ember.addBeforeObserver(proto, key, null, 'belongsToWillChange');\n }\n\n meta.parentType = proto.constructor;\n }\n }\n});\n\n/*\n These DS.Model extensions add class methods that provide relationship\n introspection abilities about relationships.\n\n A note about the computed properties contained here:\n\n **These properties are effectively sealed once called for the first time.**\n To avoid repeatedly doing expensive iteration over a model's fields, these\n values are computed once and then cached for the remainder of the runtime of\n your application.\n\n If your application needs to modify a class after its initial definition\n (for example, using `reopen()` to add additional attributes), make sure you\n do it before using your model with the store, which uses these properties\n extensively.\n*/\n\nDS.Model.reopenClass({\n /**\n For a given relationship name, returns the model type of the relationship.\n\n For example, if you define a model like this:\n\n ```javascript\n App.Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n ```\n\n Calling `App.Post.typeForRelationship('comments')` will return `App.Comment`.\n\n @method typeForRelationship\n @static\n @param {String} name the name of the relationship\n @return {subclass of DS.Model} the type of the relationship, or undefined\n */\n typeForRelationship: function(name) {\n var relationship = get(this, 'relationshipsByName').get(name);\n return relationship && relationship.type;\n },\n\n inverseFor: function(name) {\n var inverseType = this.typeForRelationship(name);\n\n if (!inverseType) { return null; }\n\n var options = this.metaForProperty(name).options;\n\n if (options.inverse === null) { return null; }\n \n var inverseName, inverseKind;\n\n if (options.inverse) {\n inverseName = options.inverse;\n inverseKind = Ember.get(inverseType, 'relationshipsByName').get(inverseName).kind;\n } else {\n var possibleRelationships = findPossibleInverses(this, inverseType);\n\n if (possibleRelationships.length === 0) { return null; }\n\n Ember.assert(\"You defined the '\" + name + \"' relationship on \" + this + \", but multiple possible inverse relationships of type \" + this + \" were found on \" + inverseType + \". Look at http://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses\", possibleRelationships.length === 1);\n\n inverseName = possibleRelationships[0].name;\n inverseKind = possibleRelationships[0].kind;\n }\n\n function findPossibleInverses(type, inverseType, possibleRelationships) {\n possibleRelationships = possibleRelationships || [];\n\n var relationshipMap = get(inverseType, 'relationships');\n if (!relationshipMap) { return; }\n\n var relationships = relationshipMap.get(type);\n if (relationships) {\n possibleRelationships.push.apply(possibleRelationships, relationshipMap.get(type));\n }\n\n if (type.superclass) {\n findPossibleInverses(type.superclass, inverseType, possibleRelationships);\n }\n\n return possibleRelationships;\n }\n\n return {\n type: inverseType,\n name: inverseName,\n kind: inverseKind\n };\n },\n\n /**\n The model's relationships as a map, keyed on the type of the\n relationship. The value of each entry is an array containing a descriptor\n for each relationship with that type, describing the name of the relationship\n as well as the type.\n\n For example, given the following model definition:\n\n ```javascript\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n posts: DS.hasMany('post')\n });\n ```\n\n This computed property would return a map describing these\n relationships, like this:\n\n ```javascript\n var relationships = Ember.get(App.Blog, 'relationships');\n relationships.get(App.User);\n //=> [ { name: 'users', kind: 'hasMany' },\n // { name: 'owner', kind: 'belongsTo' } ]\n relationships.get(App.Post);\n //=> [ { name: 'posts', kind: 'hasMany' } ]\n ```\n\n @property relationships\n @static\n @type Ember.Map\n @readOnly\n */\n relationships: Ember.computed(function() {\n var map = new Ember.MapWithDefault({\n defaultValue: function() { return []; }\n });\n\n // Loop through each computed property on the class\n this.eachComputedProperty(function(name, meta) {\n\n // If the computed property is a relationship, add\n // it to the map.\n if (meta.isRelationship) {\n if (typeof meta.type === 'string') {\n meta.type = this.store.modelFor(meta.type);\n }\n\n var relationshipsForType = map.get(meta.type);\n\n relationshipsForType.push({ name: name, kind: meta.kind });\n }\n });\n\n return map;\n }),\n\n /**\n A hash containing lists of the model's relationships, grouped\n by the relationship kind. For example, given a model with this\n definition:\n\n ```javascript\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n\n posts: DS.hasMany('post')\n });\n ```\n\n This property would contain the following:\n\n ```javascript\n var relationshipNames = Ember.get(App.Blog, 'relationshipNames');\n relationshipNames.hasMany;\n //=> ['users', 'posts']\n relationshipNames.belongsTo;\n //=> ['owner']\n ```\n\n @property relationshipNames\n @static\n @type Object\n @readOnly\n */\n relationshipNames: Ember.computed(function() {\n var names = { hasMany: [], belongsTo: [] };\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n names[meta.kind].push(name);\n }\n });\n\n return names;\n }),\n\n /**\n An array of types directly related to a model. Each type will be\n included once, regardless of the number of relationships it has with\n the model.\n\n For example, given a model with this definition:\n\n ```javascript\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n\n posts: DS.hasMany('post')\n });\n ```\n\n This property would contain the following:\n\n ```javascript\n var relatedTypes = Ember.get(App.Blog, 'relatedTypes');\n //=> [ App.User, App.Post ]\n ```\n\n @property relatedTypes\n @static\n @type Ember.Array\n @readOnly\n */\n relatedTypes: Ember.computed(function() {\n var type,\n types = Ember.A();\n\n // Loop through each computed property on the class,\n // and create an array of the unique types involved\n // in relationships\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n type = meta.type;\n\n if (typeof type === 'string') {\n type = get(this, type, false) || this.store.modelFor(type);\n }\n\n Ember.assert(\"You specified a hasMany (\" + meta.type + \") on \" + meta.parentType + \" but \" + meta.type + \" was not found.\", type);\n\n if (!types.contains(type)) {\n Ember.assert(\"Trying to sideload \" + name + \" on \" + this.toString() + \" but the type doesn't exist.\", !!type);\n types.push(type);\n }\n }\n });\n\n return types;\n }),\n\n /**\n A map whose keys are the relationships of a model and whose values are\n relationship descriptors.\n\n For example, given a model with this\n definition:\n\n ```javascript\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n\n posts: DS.hasMany('post')\n });\n ```\n\n This property would contain the following:\n\n ```javascript\n var relationshipsByName = Ember.get(App.Blog, 'relationshipsByName');\n relationshipsByName.get('users');\n //=> { key: 'users', kind: 'hasMany', type: App.User }\n relationshipsByName.get('owner');\n //=> { key: 'owner', kind: 'belongsTo', type: App.User }\n ```\n\n @property relationshipsByName\n @static\n @type Ember.Map\n @readOnly\n */\n relationshipsByName: Ember.computed(function() {\n var map = Ember.Map.create(), type;\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n meta.key = name;\n type = meta.type;\n\n if (!type && meta.kind === 'hasMany') {\n type = Ember.String.singularize(name);\n } else if (!type) {\n type = name;\n }\n\n if (typeof type === 'string') {\n meta.type = this.store.modelFor(type);\n }\n\n map.set(name, meta);\n }\n });\n\n return map;\n }),\n\n /**\n A map whose keys are the fields of the model and whose values are strings\n describing the kind of the field. A model's fields are the union of all of its\n attributes and relationships.\n\n For example:\n\n ```javascript\n\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n\n posts: DS.hasMany('post'),\n\n title: DS.attr('string')\n });\n\n var fields = Ember.get(App.Blog, 'fields');\n fields.forEach(function(field, kind) {\n console.log(field, kind);\n });\n\n // prints:\n // users, hasMany\n // owner, belongsTo\n // posts, hasMany\n // title, attribute\n ```\n\n @property fields\n @static\n @type Ember.Map\n @readOnly\n */\n fields: Ember.computed(function() {\n var map = Ember.Map.create();\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n map.set(name, meta.kind);\n } else if (meta.isAttribute) {\n map.set(name, 'attribute');\n }\n });\n\n return map;\n }),\n\n /**\n Given a callback, iterates over each of the relationships in the model,\n invoking the callback with the name of each relationship and its relationship\n descriptor.\n\n @method eachRelationship\n @static\n @param {Function} callback the callback to invoke\n @param {any} binding the value to which the callback's `this` should be bound\n */\n eachRelationship: function(callback, binding) {\n get(this, 'relationshipsByName').forEach(function(name, relationship) {\n callback.call(binding, name, relationship);\n });\n },\n\n /**\n Given a callback, iterates over each of the types related to a model,\n invoking the callback with the related type's class. Each type will be\n returned just once, regardless of how many different relationships it has\n with a model.\n\n @method eachRelatedType\n @static\n @param {Function} callback the callback to invoke\n @param {any} binding the value to which the callback's `this` should be bound\n */\n eachRelatedType: function(callback, binding) {\n get(this, 'relatedTypes').forEach(function(type) {\n callback.call(binding, type);\n });\n }\n});\n\nDS.Model.reopen({\n /**\n Given a callback, iterates over each of the relationships in the model,\n invoking the callback with the name of each relationship and its relationship\n descriptor.\n\n @method eachRelationship\n @param {Function} callback the callback to invoke\n @param {any} binding the value to which the callback's `this` should be bound\n */\n eachRelationship: function(callback, binding) {\n this.constructor.eachRelationship(callback, binding);\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/relationships/ext");minispade.register('ember-data/system/relationships/has_many', "(function() {minispade.require(\"ember-data/system/model/model\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set, setProperties = Ember.setProperties;\n\nfunction asyncHasMany(type, options, meta) {\n return Ember.computed(function(key, value) {\n var relationship = this._relationships[key],\n promiseLabel = \"DS: Async hasMany \" + this + \" : \" + key;\n\n if (!relationship) {\n var resolver = Ember.RSVP.defer(promiseLabel);\n relationship = buildRelationship(this, key, options, function(store, data) {\n var link = data.links && data.links[key];\n var rel;\n if (link) {\n rel = store.findHasMany(this, link, meta, resolver);\n } else {\n rel = store.findMany(this, data[key], meta.type, resolver);\n }\n // cache the promise so we can use it\n // when we come back and don't need to rebuild\n // the relationship.\n set(rel, 'promise', resolver.promise);\n return rel;\n });\n }\n\n var promise = relationship.get('promise').then(function() {\n return relationship;\n }, null, \"DS: Async hasMany records received\");\n\n return DS.PromiseArray.create({ promise: promise });\n }).property('data').meta(meta);\n}\n\nfunction buildRelationship(record, key, options, callback) {\n var rels = record._relationships;\n\n if (rels[key]) { return rels[key]; }\n\n var data = get(record, 'data'),\n store = get(record, 'store');\n\n var relationship = rels[key] = callback.call(record, store, data);\n\n return setProperties(relationship, {\n owner: record, name: key, isPolymorphic: options.polymorphic\n });\n}\n\nfunction hasRelationship(type, options) {\n options = options || {};\n\n var meta = { type: type, isRelationship: true, options: options, kind: 'hasMany' };\n\n if (options.async) {\n return asyncHasMany(type, options, meta);\n }\n\n return Ember.computed(function(key, value) {\n return buildRelationship(this, key, options, function(store, data) {\n var records = data[key];\n Ember.assert(\"You looked up the '\" + key + \"' relationship on '\" + this + \"' but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)\", Ember.A(records).everyProperty('isEmpty', false));\n return store.findMany(this, data[key], meta.type);\n });\n }).property('data').meta(meta);\n}\n\n/**\n `DS.hasMany` is used to define One-To-Many and Many-To-Many\n relationships on a [DS.Model](DS.Model.html).\n\n `DS.hasMany` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `async`: A boolean value used to explicitly declare this to be an async relationship.\n - `inverse`: A string used to identify the inverse property on a related model.\n\n #### One-To-Many\n To declare a one-to-many relationship between two models, use\n `DS.belongsTo` in combination with `DS.hasMany`, like this:\n\n ```javascript\n App.Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n App.Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n ```\n\n #### Many-To-Many\n To declare a many-to-many relationship between two models, use\n `DS.hasMany`:\n\n ```javascript\n App.Post = DS.Model.extend({\n tags: DS.hasMany('tag')\n });\n\n App.Tag = DS.Model.extend({\n posts: DS.hasMany('post')\n });\n ```\n\n #### Explicit Inverses\n\n Ember Data will do its best to discover which relationships map to\n one another. In the one-to-many code above, for example, Ember Data\n can figure out that changing the `comments` relationship should update\n the `post` relationship on the inverse because post is the only\n relationship to that model.\n\n However, sometimes you may have multiple `belongsTo`/`hasManys` for the\n same type. You can specify which property on the related model is\n the inverse using `DS.hasMany`'s `inverse` option:\n\n ```javascript\n var belongsTo = DS.belongsTo,\n hasMany = DS.hasMany;\n\n App.Comment = DS.Model.extend({\n onePost: belongsTo('post'),\n twoPost: belongsTo('post'),\n redPost: belongsTo('post'),\n bluePost: belongsTo('post')\n });\n\n App.Post = DS.Model.extend({\n comments: hasMany('comment', {\n inverse: 'redPost'\n })\n });\n ```\n\n You can also specify an inverse on a `belongsTo`, which works how\n you'd expect.\n\n @namespace\n @method hasMany\n @for DS\n @param {String or DS.Model} type the model type of the relationship\n @param {Object} options a hash of options\n @return {Ember.computed} relationship\n*/\nDS.hasMany = function(type, options) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n }\n return hasRelationship(type, options);\n};\n\n})();\n//@ sourceURL=ember-data/system/relationships/has_many");minispade.register('ember-data/system/store', "(function() {/*globals Ember*/\n/*jshint eqnull:true*/\nminispade.require(\"ember-data/system/record_arrays\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar once = Ember.run.once;\nvar isNone = Ember.isNone;\nvar forEach = Ember.EnumerableUtils.forEach;\nvar indexOf = Ember.EnumerableUtils.indexOf;\nvar map = Ember.EnumerableUtils.map;\nvar resolve = Ember.RSVP.resolve;\nvar copy = Ember.copy;\n\n// Implementors Note:\n//\n// The variables in this file are consistently named according to the following\n// scheme:\n//\n// * +id+ means an identifier managed by an external source, provided inside\n// the data provided by that source. These are always coerced to be strings\n// before being used internally.\n// * +clientId+ means a transient numerical identifier generated at runtime by\n// the data store. It is important primarily because newly created objects may\n// not yet have an externally generated id.\n// * +reference+ means a record reference object, which holds metadata about a\n// record, even if it has not yet been fully materialized.\n// * +type+ means a subclass of DS.Model.\n\n// Used by the store to normalize IDs entering the store. Despite the fact\n// that developers may provide IDs as numbers (e.g., `store.find(Person, 1)`),\n// it is important that internally we use strings, since IDs may be serialized\n// and lose type information. For example, Ember's router may put a record's\n// ID into the URL, and if we later try to deserialize that URL and find the\n// corresponding record, we will not know if it is a string or a number.\nvar coerceId = function(id) {\n return id == null ? null : id+'';\n};\n\n/**\n The store contains all of the data for records loaded from the server.\n It is also responsible for creating instances of `DS.Model` that wrap\n the individual data for a record, so that they can be bound to in your\n Handlebars templates.\n\n Define your application's store like this:\n\n ```javascript\n MyApp.Store = DS.Store.extend();\n ```\n\n Most Ember.js applications will only have a single `DS.Store` that is\n automatically created by their `Ember.Application`.\n\n You can retrieve models from the store in several ways. To retrieve a record\n for a specific id, use `DS.Store`'s `find()` method:\n\n ```javascript\n var person = store.find('person', 123);\n ```\n\n If your application has multiple `DS.Store` instances (an unusual case), you can\n specify which store should be used:\n\n ```javascript\n var person = store.find(App.Person, 123);\n ```\n\n By default, the store will talk to your backend using a standard\n REST mechanism. You can customize how the store talks to your\n backend by specifying a custom adapter:\n\n ```javascript\n MyApp.store = DS.Store.create({\n adapter: 'MyApp.CustomAdapter'\n });\n ```\n\n You can learn more about writing a custom adapter by reading the `DS.Adapter`\n documentation.\n\n @class Store\n @namespace DS\n @extends Ember.Object\n*/\nDS.Store = Ember.Object.extend({\n\n /**\n @method init\n @private\n */\n init: function() {\n // internal bookkeeping; not observable\n this.typeMaps = {};\n this.recordArrayManager = DS.RecordArrayManager.create({\n store: this\n });\n this._relationshipChanges = {};\n this._pendingSave = [];\n },\n\n /**\n The adapter to use to communicate to a backend server or other persistence layer.\n\n This can be specified as an instance, class, or string.\n\n If you want to specify `App.CustomAdapter` as a string, do:\n\n ```js\n adapter: 'custom'\n ```\n\n @property adapter\n @default DS.RESTAdapter\n @type {DS.Adapter|String}\n */\n adapter: '_rest',\n\n /**\n Returns a JSON representation of the record using a custom\n type-specific serializer, if one exists.\n\n The available options are:\n\n * `includeId`: `true` if the record's ID should be included in\n the JSON representation\n\n @method serialize\n @private\n @param {DS.Model} record the record to serialize\n @param {Object} options an options hash\n */\n serialize: function(record, options) {\n return this.serializerFor(record.constructor.typeKey).serialize(record, options);\n },\n\n /**\n This property returns the adapter, after resolving a possible\n string key.\n\n If the supplied `adapter` was a class, or a String property\n path resolved to a class, this property will instantiate the\n class.\n\n This property is cacheable, so the same instance of a specified\n adapter class should be used for the lifetime of the store.\n\n @property defaultAdapter\n @private\n @returns DS.Adapter\n */\n defaultAdapter: Ember.computed('adapter', function() {\n var adapter = get(this, 'adapter');\n\n Ember.assert('You tried to set `adapter` property to an instance of `DS.Adapter`, where it should be a name or a factory', !(adapter instanceof DS.Adapter));\n\n if (typeof adapter === 'string') {\n adapter = this.container.lookup('adapter:' + adapter) || this.container.lookup('adapter:application') || this.container.lookup('adapter:_rest');\n }\n\n if (DS.Adapter.detect(adapter)) {\n adapter = adapter.create({ container: this.container });\n }\n\n return adapter;\n }),\n\n // .....................\n // . CREATE NEW RECORD .\n // .....................\n\n /**\n Create a new record in the current store. The properties passed\n to this method are set on the newly created record.\n\n To create a new instance of `App.Post`:\n\n ```js\n store.createRecord('post', {\n title: \"Rails is omakase\"\n });\n ```\n\n @method createRecord\n @param {String} type\n @param {Object} properties a hash of properties to set on the\n newly created record.\n @returns {DS.Model} record\n */\n createRecord: function(type, properties) {\n type = this.modelFor(type);\n\n properties = copy(properties) || {};\n\n // If the passed properties do not include a primary key,\n // give the adapter an opportunity to generate one. Typically,\n // client-side ID generators will use something like uuid.js\n // to avoid conflicts.\n\n if (isNone(properties.id)) {\n properties.id = this._generateId(type);\n }\n\n // Coerce ID to a string\n properties.id = coerceId(properties.id);\n\n var record = this.buildRecord(type, properties.id);\n\n // Move the record out of its initial `empty` state into\n // the `loaded` state.\n record.loadedData();\n\n // Set the properties specified on the record.\n record.setProperties(properties);\n\n return record;\n },\n\n /**\n If possible, this method asks the adapter to generate an ID for\n a newly created record.\n\n @method _generateId\n @private\n @param {String} type\n @returns {String} if the adapter can generate one, an ID\n */\n _generateId: function(type) {\n var adapter = this.adapterFor(type);\n\n if (adapter && adapter.generateIdForRecord) {\n return adapter.generateIdForRecord(this);\n }\n\n return null;\n },\n\n // .................\n // . DELETE RECORD .\n // .................\n\n /**\n For symmetry, a record can be deleted via the store.\n\n Example\n\n ```javascript\n var post = store.createRecord('post', {\n title: \"Rails is omakase\"\n });\n\n store.deletedRecord(post);\n ```\n\n @method deleteRecord\n @param {DS.Model} record\n */\n deleteRecord: function(record) {\n record.deleteRecord();\n },\n\n /**\n For symmetry, a record can be unloaded via the store. Only\n non-dirty records can be unloaded.\n\n Example\n\n ```javascript\n store.find('post', 1).then(function(post) {\n store.unloadRecord(post);\n });\n ```\n\n @method unloadRecord\n @param {DS.Model} record\n */\n unloadRecord: function(record) {\n record.unloadRecord();\n },\n\n // ................\n // . FIND RECORDS .\n // ................\n\n /**\n This is the main entry point into finding records. The first parameter to\n this method is the model's name as a string.\n\n ---\n\n To find a record by ID, pass the `id` as the second parameter:\n\n ```javascript\n store.find('person', 1);\n ```\n\n The `find` method will always return a **promise** that will be resolved\n with the record. If the record was already in the store, the promise will\n be resolved immediately. Otherwise, the store will ask the adapter's `find`\n method to find the necessary data.\n\n The `find` method will always resolve its promise with the same object for\n a given type and `id`.\n\n ---\n\n To find all records for a type, call `find` with no additional parameters:\n\n ```javascript\n store.find('person');\n ```\n\n This will ask the adapter's `findAll` method to find the records for the\n given type, and return a promise that will be resolved once the server\n returns the values.\n\n ---\n\n To find a record by a query, call `find` with a hash as the second\n parameter:\n\n ```javascript\n store.find(App.Person, { page: 1 });\n ```\n\n This will ask the adapter's `findQuery` method to find the records for\n the query, and return a promise that will be resolved once the server\n responds.\n\n @method find\n @param {String or subclass of DS.Model} type\n @param {Object|String|Integer|null} id\n @return {Promise} promise\n */\n find: function(type, id) {\n if (id === undefined) {\n return this.findAll(type);\n }\n\n // We are passed a query instead of an id.\n if (Ember.typeOf(id) === 'object') {\n return this.findQuery(type, id);\n }\n\n return this.findById(type, coerceId(id));\n },\n\n /**\n This method returns a record for a given type and id combination.\n\n @method findById\n @private\n @param {String or subclass of DS.Model} type\n @param {String|Integer} id\n @return {Promise} promise\n */\n findById: function(type, id) {\n type = this.modelFor(type);\n\n var record = this.recordForId(type, id);\n\n var promise = this.fetchRecord(record) || resolve(record, \"DS: Store#findById \" + type + \" with id: \" + id);\n return promiseObject(promise);\n },\n\n /**\n This method makes a series of requests to the adapter's `find` method\n and returns a promise that resolves once they are all loaded.\n\n @private\n @method findByIds\n @param {String} type\n @param {Array} ids\n @returns {Promise} promise\n */\n findByIds: function(type, ids) {\n var store = this;\n var promiseLabel = \"DS: Store#findByIds \" + type;\n return promiseArray(Ember.RSVP.all(map(ids, function(id) {\n return store.findById(type, id);\n })).then(Ember.A, null, \"DS: Store#findByIds of \" + type + \" complete\"));\n },\n\n /**\n This method is called by `findById` if it discovers that a particular\n type/id pair hasn't been loaded yet to kick off a request to the\n adapter.\n\n @method fetchRecord\n @private\n @param {DS.Model} record\n @returns {Promise} promise\n */\n fetchRecord: function(record) {\n if (isNone(record)) { return null; }\n if (record._loadingPromise) { return record._loadingPromise; }\n if (!get(record, 'isEmpty')) { return null; }\n\n var type = record.constructor,\n id = get(record, 'id');\n\n var adapter = this.adapterFor(type);\n\n Ember.assert(\"You tried to find a record but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to find a record but your adapter (for \" + type + \") does not implement 'find'\", adapter.find);\n\n var promise = _find(adapter, this, type, id);\n record.loadingData(promise);\n return promise;\n },\n\n /**\n Get a record by a given type and ID without triggering a fetch.\n\n This method will synchronously return the record if it's available.\n Otherwise, it will return null.\n\n ```js\n var post = store.getById('post', 1);\n ```\n\n @method getById\n @param {String or subclass of DS.Model} type\n @param {String|Integer} id\n @param {DS.Model} record\n */\n getById: function(type, id) {\n if (this.hasRecordForId(type, id)) {\n return this.recordForId(type, id);\n } else {\n return null;\n }\n },\n\n /**\n This method is called by the record's `reload` method.\n\n This method calls the adapter's `find` method, which returns a promise. When\n **that** promise resolves, `reloadRecord` will resolve the promise returned\n by the record's `reload`.\n\n @method reloadRecord\n @private\n @param {DS.Model} record\n @return {Promise} promise\n */\n reloadRecord: function(record) {\n var type = record.constructor,\n adapter = this.adapterFor(type),\n id = get(record, 'id');\n\n Ember.assert(\"You cannot reload a record without an ID\", id);\n Ember.assert(\"You tried to reload a record but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to reload a record but your adapter does not implement `find`\", adapter.find);\n\n return _find(adapter, this, type, id);\n },\n\n /**\n This method takes a list of records, groups the records by type,\n converts the records into IDs, and then invokes the adapter's `findMany`\n method.\n\n The records are grouped by type to invoke `findMany` on adapters\n for each unique type in records.\n\n It is used both by a brand new relationship (via the `findMany`\n method) or when the data underlying an existing relationship\n changes.\n\n @method fetchMany\n @private\n @param {Array} records\n @param {DS.Model} owner\n @param {Resolver} resolver\n */\n fetchMany: function(records, owner, resolver) {\n if (!records.length) { return; }\n\n // Group By Type\n var recordsByTypeMap = Ember.MapWithDefault.create({\n defaultValue: function() { return Ember.A(); }\n });\n\n forEach(records, function(record) {\n recordsByTypeMap.get(record.constructor).push(record);\n });\n\n forEach(recordsByTypeMap, function(type, records) {\n var ids = records.mapProperty('id'),\n adapter = this.adapterFor(type);\n\n Ember.assert(\"You tried to load many records but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to load many records but your adapter does not implement `findMany`\", adapter.findMany);\n\n resolver.resolve(_findMany(adapter, this, type, ids, owner));\n }, this);\n },\n\n /**\n Returns true if a record for a given type and ID is already loaded.\n\n @method hasRecordForId\n @param {String or subclass of DS.Model} type\n @param {String|Integer} id\n @returns {Boolean}\n */\n hasRecordForId: function(type, id) {\n id = coerceId(id);\n type = this.modelFor(type);\n return !!this.typeMapFor(type).idToRecord[id];\n },\n\n /**\n Returns id record for a given type and ID. If one isn't already loaded,\n it builds a new record and leaves it in the `empty` state.\n\n @method recordForId\n @private\n @param {String or subclass of DS.Model} type\n @param {String|Integer} id\n @returns {DS.Model} record\n */\n recordForId: function(type, id) {\n type = this.modelFor(type);\n\n id = coerceId(id);\n\n var record = this.typeMapFor(type).idToRecord[id];\n\n if (!record) {\n record = this.buildRecord(type, id);\n }\n\n return record;\n },\n\n /**\n @method findMany\n @private\n @param {DS.Model} owner\n @param {Array} records\n @param {String or subclass of DS.Model} type\n @param {Resolver} resolver\n @return {DS.ManyArray} records\n */\n findMany: function(owner, records, type, resolver) {\n type = this.modelFor(type);\n\n records = Ember.A(records);\n\n var unloadedRecords = records.filterProperty('isEmpty', true),\n manyArray = this.recordArrayManager.createManyArray(type, records);\n\n forEach(unloadedRecords, function(record) {\n record.loadingData();\n });\n\n manyArray.loadingRecordsCount = unloadedRecords.length;\n\n if (unloadedRecords.length) {\n forEach(unloadedRecords, function(record) {\n this.recordArrayManager.registerWaitingRecordArray(record, manyArray);\n }, this);\n\n this.fetchMany(unloadedRecords, owner, resolver);\n } else {\n if (resolver) { resolver.resolve(); }\n manyArray.set('isLoaded', true);\n Ember.run.once(manyArray, 'trigger', 'didLoad');\n }\n\n return manyArray;\n },\n\n /**\n If a relationship was originally populated by the adapter as a link\n (as opposed to a list of IDs), this method is called when the\n relationship is fetched.\n\n The link (which is usually a URL) is passed through unchanged, so the\n adapter can make whatever request it wants.\n\n The usual use-case is for the server to register a URL as a link, and\n then use that URL in the future to make a request for the relationship.\n\n @method findHasMany\n @private\n @param {DS.Model} owner\n @param {any} link\n @param {String or subclass of DS.Model} type\n @param {Resolver} resolver\n @return {DS.ManyArray}\n */\n findHasMany: function(owner, link, relationship, resolver) {\n var adapter = this.adapterFor(owner.constructor);\n\n Ember.assert(\"You tried to load a hasMany relationship but you have no adapter (for \" + owner.constructor + \")\", adapter);\n Ember.assert(\"You tried to load a hasMany relationship from a specified `link` in the original payload but your adapter does not implement `findHasMany`\", adapter.findHasMany);\n\n var records = this.recordArrayManager.createManyArray(relationship.type, Ember.A([]));\n resolver.resolve(_findHasMany(adapter, this, owner, link, relationship));\n return records;\n },\n\n /**\n @method findBelongsTo\n @private\n @param {DS.Model} owner\n @param {any} link\n @param {Relationship} relationship\n @param {Resolver} resolver\n */\n findBelongsTo: function(owner, link, relationship, resolver) {\n var adapter = this.adapterFor(owner.constructor);\n\n Ember.assert(\"You tried to load a belongsTo relationship but you have no adapter (for \" + owner.constructor + \")\", adapter);\n Ember.assert(\"You tried to load a belongsTo relationship from a specified `link` in the original payload but your adapter does not implement `findBelongsTo`\", adapter.findBelongsTo);\n\n resolver.resolve(_findBelongsTo(adapter, this, owner, link, relationship));\n },\n\n /**\n This method delegates a query to the adapter. This is the one place where\n adapter-level semantics are exposed to the application.\n\n Exposing queries this way seems preferable to creating an abstract query\n language for all server-side queries, and then require all adapters to\n implement them.\n\n This method returns a promise, which is resolved with a `RecordArray`\n once the server returns.\n\n @method findQuery\n @private\n @param {String or subclass of DS.Model} type\n @param {any} query an opaque query to be used by the adapter\n @return {Promise} promise\n */\n findQuery: function(type, query) {\n type = this.modelFor(type);\n\n var array = this.recordArrayManager\n .createAdapterPopulatedRecordArray(type, query);\n\n var adapter = this.adapterFor(type),\n promiseLabel = \"DS: Store#findQuery \" + type,\n resolver = Ember.RSVP.defer(promiseLabel);\n\n Ember.assert(\"You tried to load a query but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to load a query but your adapter does not implement `findQuery`\", adapter.findQuery);\n\n resolver.resolve(_findQuery(adapter, this, type, query, array));\n\n return promiseArray(resolver.promise);\n },\n\n /**\n This method returns an array of all records adapter can find.\n It triggers the adapter's `findAll` method to give it an opportunity to populate\n the array with records of that type.\n\n @method findAll\n @private\n @param {String or subclass of DS.Model} type\n @return {DS.AdapterPopulatedRecordArray}\n */\n findAll: function(type) {\n type = this.modelFor(type);\n\n return this.fetchAll(type, this.all(type));\n },\n\n /**\n @method fetchAll\n @private\n @param {DS.Model} type\n @param {DS.RecordArray} array\n @returns {Promise} promise\n */\n fetchAll: function(type, array) {\n var adapter = this.adapterFor(type),\n sinceToken = this.typeMapFor(type).metadata.since;\n\n set(array, 'isUpdating', true);\n\n Ember.assert(\"You tried to load all records but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to load all records but your adapter does not implement `findAll`\", adapter.findAll);\n\n return promiseArray(_findAll(adapter, this, type, sinceToken));\n },\n\n /**\n @method didUpdateAll\n @param {DS.Model} type\n */\n didUpdateAll: function(type) {\n var findAllCache = this.typeMapFor(type).findAllCache;\n set(findAllCache, 'isUpdating', false);\n },\n\n /**\n This method returns a filtered array that contains all of the known records\n for a given type.\n\n Note that because it's just a filter, it will have any locally\n created records of the type.\n\n Also note that multiple calls to `all` for a given type will always\n return the same RecordArray.\n\n Example\n\n ```javascript\n var local_posts = store.all(App.Post);\n ```\n\n @method all\n @param {String or subclass of DS.Model} type\n @return {DS.RecordArray}\n */\n all: function(type) {\n type = this.modelFor(type);\n\n var typeMap = this.typeMapFor(type),\n findAllCache = typeMap.findAllCache;\n\n if (findAllCache) { return findAllCache; }\n\n var array = this.recordArrayManager.createRecordArray(type);\n\n typeMap.findAllCache = array;\n return array;\n },\n\n\n /**\n This method unloads all of the known records for a given type.\n\n ```javascript\n store.unloadAll(App.Post);\n ```\n\n @method unloadAll\n @param {String or subclass of DS.Model} type\n */\n unloadAll: function(type) {\n type = this.modelFor(type);\n\n var typeMap = this.typeMapFor(type),\n records = typeMap.records, record;\n\n while(record = records.pop()) {\n record.unloadRecord();\n }\n\n typeMap.findAllCache = null;\n },\n\n /**\n Takes a type and filter function, and returns a live RecordArray that\n remains up to date as new records are loaded into the store or created\n locally.\n\n The callback function takes a materialized record, and returns true\n if the record should be included in the filter and false if it should\n not.\n\n The filter function is called once on all records for the type when\n it is created, and then once on each newly loaded or created record.\n\n If any of a record's properties change, or if it changes state, the\n filter function will be invoked again to determine whether it should\n still be in the array.\n\n Optionally you can pass a query which will be triggered at first. The\n results returned by the server could then appear in the filter if they\n match the filter function.\n\n Example\n\n ```javascript\n store.filter(App.Post, {unread: true}, function(post) {\n return post.get('unread');\n }).then(function(unreadPosts) {\n unreadPosts.get('length'); // 5\n var unreadPost = unreadPosts.objectAt(0);\n unreadPosts.set('unread', false);\n unreadPosts.get('length'); // 4\n });\n ```\n\n @method filter\n @param {String or subclass of DS.Model} type\n @param {Object} query optional query\n @param {Function} filter\n @return {DS.PromiseArray}\n */\n filter: function(type, query, filter) {\n var promise;\n\n // allow an optional server query\n if (arguments.length === 3) {\n promise = this.findQuery(type, query);\n } else if (arguments.length === 2) {\n filter = query;\n }\n\n type = this.modelFor(type);\n\n var array = this.recordArrayManager\n .createFilteredRecordArray(type, filter);\n promise = promise || resolve(array);\n\n return promiseArray(promise.then(function() {\n return array;\n }, null, \"DS: Store#filter of \" + type));\n },\n\n /**\n This method returns if a certain record is already loaded\n in the store. Use this function to know beforehand if a find()\n will result in a request or that it will be a cache hit.\n\n Example\n\n ```javascript\n store.recordIsLoaded(App.Post, 1); // false\n store.find(App.Post, 1).then(function() {\n store.recordIsLoaded(App.Post, 1); // true\n });\n ```\n\n @method recordIsLoaded\n @param {String or subclass of DS.Model} type\n @param {string} id\n @return {boolean}\n */\n recordIsLoaded: function(type, id) {\n if (!this.hasRecordForId(type, id)) { return false; }\n return !get(this.recordForId(type, id), 'isEmpty');\n },\n\n /**\n This method returns the metadata for a specific type.\n\n @method metadataFor\n @param {String or subclass of DS.Model} type\n @return {object}\n */\n metadataFor: function(type) {\n type = this.modelFor(type);\n return this.typeMapFor(type).metadata;\n },\n\n // ............\n // . UPDATING .\n // ............\n\n /**\n If the adapter updates attributes or acknowledges creation\n or deletion, the record will notify the store to update its\n membership in any filters.\n To avoid thrashing, this method is invoked only once per\n\n run loop per record.\n\n @method dataWasUpdated\n @private\n @param {Class} type\n @param {DS.Model} record\n */\n dataWasUpdated: function(type, record) {\n this.recordArrayManager.recordDidChange(record);\n },\n\n // ..............\n // . PERSISTING .\n // ..............\n\n /**\n This method is called by `record.save`, and gets passed a\n resolver for the promise that `record.save` returns.\n\n It schedules saving to happen at the end of the run loop.\n\n @method scheduleSave\n @private\n @param {DS.Model} record\n @param {Resolver} resolver\n */\n scheduleSave: function(record, resolver) {\n record.adapterWillCommit();\n this._pendingSave.push([record, resolver]);\n once(this, 'flushPendingSave');\n },\n\n /**\n This method is called at the end of the run loop, and\n flushes any records passed into `scheduleSave`\n\n @method flushPendingSave\n @private\n */\n flushPendingSave: function() {\n var pending = this._pendingSave.slice();\n this._pendingSave = [];\n\n forEach(pending, function(tuple) {\n var record = tuple[0], resolver = tuple[1],\n adapter = this.adapterFor(record.constructor),\n operation;\n\n if (get(record, 'isNew')) {\n operation = 'createRecord';\n } else if (get(record, 'isDeleted')) {\n operation = 'deleteRecord';\n } else {\n operation = 'updateRecord';\n }\n\n resolver.resolve(_commit(adapter, this, operation, record));\n }, this);\n },\n\n /**\n This method is called once the promise returned by an\n adapter's `createRecord`, `updateRecord` or `deleteRecord`\n is resolved.\n\n If the data provides a server-generated ID, it will\n update the record and the store's indexes.\n\n @method didSaveRecord\n @private\n @param {DS.Model} record the in-flight record\n @param {Object} data optional data (see above)\n */\n didSaveRecord: function(record, data) {\n if (data) {\n // normalize relationship IDs into records\n data = normalizeRelationships(this, record.constructor, data, record);\n\n this.updateId(record, data);\n }\n\n record.adapterDidCommit(data);\n },\n\n /**\n This method is called once the promise returned by an\n adapter's `createRecord`, `updateRecord` or `deleteRecord`\n is rejected with a `DS.InvalidError`.\n\n @method recordWasInvalid\n @private\n @param {DS.Model} record\n @param {Object} errors\n */\n recordWasInvalid: function(record, errors) {\n record.adapterDidInvalidate(errors);\n },\n\n /**\n This method is called once the promise returned by an\n adapter's `createRecord`, `updateRecord` or `deleteRecord`\n is rejected (with anything other than a `DS.InvalidError`).\n\n @method recordWasError\n @private\n @param {DS.Model} record\n */\n recordWasError: function(record) {\n record.adapterDidError();\n },\n\n /**\n When an adapter's `createRecord`, `updateRecord` or `deleteRecord`\n resolves with data, this method extracts the ID from the supplied\n data.\n\n @method updateId\n @private\n @param {DS.Model} record\n @param {Object} data\n */\n updateId: function(record, data) {\n var oldId = get(record, 'id'),\n id = coerceId(data.id);\n\n Ember.assert(\"An adapter cannot assign a new id to a record that already has an id. \" + record + \" had id: \" + oldId + \" and you tried to update it with \" + id + \". This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.\", oldId === null || id === oldId);\n\n this.typeMapFor(record.constructor).idToRecord[id] = record;\n\n set(record, 'id', id);\n },\n\n /**\n Returns a map of IDs to client IDs for a given type.\n\n @method typeMapFor\n @private\n @param type\n @return {Object} typeMap\n */\n typeMapFor: function(type) {\n var typeMaps = get(this, 'typeMaps'),\n guid = Ember.guidFor(type),\n typeMap;\n\n typeMap = typeMaps[guid];\n\n if (typeMap) { return typeMap; }\n\n typeMap = {\n idToRecord: {},\n records: [],\n metadata: {}\n };\n\n typeMaps[guid] = typeMap;\n\n return typeMap;\n },\n\n // ................\n // . LOADING DATA .\n // ................\n\n /**\n This internal method is used by `push`.\n\n @method _load\n @private\n @param {String or subclass of DS.Model} type\n @param {Object} data\n @param {Boolean} partial the data should be merged into\n the existing data, not replace it.\n */\n _load: function(type, data, partial) {\n var id = coerceId(data.id),\n record = this.recordForId(type, id);\n\n record.setupData(data, partial);\n this.recordArrayManager.recordDidChange(record);\n\n return record;\n },\n\n /**\n Returns a model class for a particular key. Used by\n methods that take a type key (like `find`, `createRecord`,\n etc.)\n\n @method modelFor\n @param {String or subclass of DS.Model} key\n @returns {subclass of DS.Model}\n */\n modelFor: function(key) {\n var factory;\n\n\n if (typeof key === 'string') {\n var normalizedKey = this.container.normalize('model:' + key);\n\n factory = this.container.lookupFactory(normalizedKey);\n if (!factory) { throw new Ember.Error(\"No model was found for '\" + key + \"'\"); }\n factory.typeKey = normalizedKey.split(':', 2)[1];\n } else {\n // A factory already supplied.\n factory = key;\n }\n\n factory.store = this;\n return factory;\n },\n\n /**\n Push some data for a given type into the store.\n\n This method expects normalized data:\n\n * The ID is a key named `id` (an ID is mandatory)\n * The names of attributes are the ones you used in\n your model's `DS.attr`s.\n * Your relationships must be:\n * represented as IDs or Arrays of IDs\n * represented as model instances\n * represented as URLs, under the `links` key\n\n For this model:\n\n ```js\n App.Person = DS.Model.extend({\n firstName: DS.attr(),\n lastName: DS.attr(),\n\n children: DS.hasMany('person')\n });\n ```\n\n To represent the children as IDs:\n\n ```js\n {\n id: 1,\n firstName: \"Tom\",\n lastName: \"Dale\",\n children: [1, 2, 3]\n }\n ```\n\n To represent the children relationship as a URL:\n\n ```js\n {\n id: 1,\n firstName: \"Tom\",\n lastName: \"Dale\",\n links: {\n children: \"/people/1/children\"\n }\n }\n ```\n\n If you're streaming data or implementing an adapter,\n make sure that you have converted the incoming data\n into this form.\n\n This method can be used both to push in brand new\n records, as well as to update existing records.\n\n @method push\n @param {String or subclass of DS.Model} type\n @param {Object} data\n @returns {DS.Model} the record that was created or\n updated.\n */\n push: function(type, data, _partial) {\n // _partial is an internal param used by `update`.\n // If passed, it means that the data should be\n // merged into the existing data, not replace it.\n\n Ember.assert(\"You must include an `id` in a hash passed to `push`\", data.id != null);\n\n type = this.modelFor(type);\n\n // normalize relationship IDs into records\n data = normalizeRelationships(this, type, data);\n\n this._load(type, data, _partial);\n\n return this.recordForId(type, data.id);\n },\n\n /**\n Push some raw data into the store.\n\n The data will be automatically deserialized using the\n serializer for the `type` param.\n\n This method can be used both to push in brand new\n records, as well as to update existing records.\n\n You can push in more than one type of object at once.\n All objects should be in the format expected by the\n serializer.\n\n ```js\n App.ApplicationSerializer = DS.ActiveModelSerializer;\n\n var pushData = {\n posts: [\n {id: 1, post_title: \"Great post\", comment_ids: [2]}\n ],\n comments: [\n {id: 2, comment_body: \"Insightful comment\"}\n ]\n }\n\n store.pushPayload('post', pushData);\n ```\n\n @method pushPayload\n @param {String} type\n @param {Object} payload\n @return {DS.Model} the record that was created or updated.\n */\n pushPayload: function (type, payload) {\n var serializer;\n if (!payload) {\n payload = type;\n serializer = defaultSerializer(this.container);\n Ember.assert(\"You cannot use `store#pushPayload` without a type unless your default serializer defines `pushPayload`\", serializer.pushPayload);\n } else {\n serializer = this.serializerFor(type);\n }\n serializer.pushPayload(this, payload);\n },\n\n update: function(type, data) {\n Ember.assert(\"You must include an `id` in a hash passed to `update`\", data.id != null);\n\n return this.push(type, data, true);\n },\n\n /**\n If you have an Array of normalized data to push,\n you can call `pushMany` with the Array, and it will\n call `push` repeatedly for you.\n\n @method pushMany\n @param {String or subclass of DS.Model} type\n @param {Array} datas\n @return {Array}\n */\n pushMany: function(type, datas) {\n return map(datas, function(data) {\n return this.push(type, data);\n }, this);\n },\n\n /**\n If you have some metadata to set for a type\n you can call `metaForType`.\n\n @method metaForType\n @param {String or subclass of DS.Model} type\n @param {Object} metadata\n */\n metaForType: function(type, metadata) {\n type = this.modelFor(type);\n\n Ember.merge(this.typeMapFor(type).metadata, metadata);\n },\n\n /**\n Build a brand new record for a given type, ID, and\n initial data.\n\n @method buildRecord\n @private\n @param {subclass of DS.Model} type\n @param {String} id\n @param {Object} data\n @returns {DS.Model} record\n */\n buildRecord: function(type, id, data) {\n var typeMap = this.typeMapFor(type),\n idToRecord = typeMap.idToRecord;\n\n Ember.assert('The id ' + id + ' has already been used with another record of type ' + type.toString() + '.', !id || !idToRecord[id]);\n\n // lookupFactory should really return an object that creates\n // instances with the injections applied\n var record = type._create({\n id: id,\n store: this,\n container: this.container\n });\n\n if (data) {\n record.setupData(data);\n }\n\n // if we're creating an item, this process will be done\n // later, once the object has been persisted.\n if (id) {\n idToRecord[id] = record;\n }\n\n typeMap.records.push(record);\n\n return record;\n },\n\n // ...............\n // . DESTRUCTION .\n // ...............\n\n /**\n When a record is destroyed, this un-indexes it and\n removes it from any record arrays so it can be GCed.\n\n @method dematerializeRecord\n @private\n @param {DS.Model} record\n */\n dematerializeRecord: function(record) {\n var type = record.constructor,\n typeMap = this.typeMapFor(type),\n id = get(record, 'id');\n\n record.updateRecordArrays();\n\n if (id) {\n delete typeMap.idToRecord[id];\n }\n\n var loc = indexOf(typeMap.records, record);\n typeMap.records.splice(loc, 1);\n },\n\n // ........................\n // . RELATIONSHIP CHANGES .\n // ........................\n\n addRelationshipChangeFor: function(childRecord, childKey, parentRecord, parentKey, change) {\n var clientId = childRecord.clientId,\n parentClientId = parentRecord ? parentRecord : parentRecord;\n var key = childKey + parentKey;\n var changes = this._relationshipChanges;\n if (!(clientId in changes)) {\n changes[clientId] = {};\n }\n if (!(parentClientId in changes[clientId])) {\n changes[clientId][parentClientId] = {};\n }\n if (!(key in changes[clientId][parentClientId])) {\n changes[clientId][parentClientId][key] = {};\n }\n changes[clientId][parentClientId][key][change.changeType] = change;\n },\n\n removeRelationshipChangeFor: function(clientRecord, childKey, parentRecord, parentKey, type) {\n var clientId = clientRecord.clientId,\n parentClientId = parentRecord ? parentRecord.clientId : parentRecord;\n var changes = this._relationshipChanges;\n var key = childKey + parentKey;\n if (!(clientId in changes) || !(parentClientId in changes[clientId]) || !(key in changes[clientId][parentClientId])){\n return;\n }\n delete changes[clientId][parentClientId][key][type];\n },\n\n relationshipChangePairsFor: function(record){\n var toReturn = [];\n\n if( !record ) { return toReturn; }\n\n //TODO(Igor) What about the other side\n var changesObject = this._relationshipChanges[record.clientId];\n for (var objKey in changesObject){\n if(changesObject.hasOwnProperty(objKey)){\n for (var changeKey in changesObject[objKey]){\n if(changesObject[objKey].hasOwnProperty(changeKey)){\n toReturn.push(changesObject[objKey][changeKey]);\n }\n }\n }\n }\n return toReturn;\n },\n\n // ......................\n // . PER-TYPE ADAPTERS\n // ......................\n\n /**\n Returns the adapter for a given type.\n\n @method adapterFor\n @private\n @param {subclass of DS.Model} type\n @returns DS.Adapter\n */\n adapterFor: function(type) {\n var container = this.container, adapter;\n\n if (container) {\n adapter = container.lookup('adapter:' + type.typeKey) || container.lookup('adapter:application');\n }\n\n return adapter || get(this, 'defaultAdapter');\n },\n\n // ..............................\n // . RECORD CHANGE NOTIFICATION .\n // ..............................\n\n /**\n Returns an instance of the serializer for a given type. For\n example, `serializerFor('person')` will return an instance of\n `App.PersonSerializer`.\n\n If no `App.PersonSerializer` is found, this method will look\n for an `App.ApplicationSerializer` (the default serializer for\n your entire application).\n\n If no `App.ApplicationSerializer` is found, it will fall back\n to an instance of `DS.JSONSerializer`.\n\n @method serializerFor\n @private\n @param {String} type the record to serialize\n @return {DS.Serializer}\n */\n serializerFor: function(type) {\n type = this.modelFor(type);\n var adapter = this.adapterFor(type);\n\n return serializerFor(this.container, type.typeKey, adapter && adapter.defaultSerializer);\n }\n});\n\nfunction normalizeRelationships(store, type, data, record) {\n type.eachRelationship(function(key, relationship) {\n // A link (usually a URL) was already provided in\n // normalized form\n if (data.links && data.links[key]) {\n if (record && relationship.options.async) { record._relationships[key] = null; }\n return;\n }\n\n var kind = relationship.kind,\n value = data[key];\n\n if (value == null) { return; }\n\n if (kind === 'belongsTo') {\n deserializeRecordId(store, data, key, relationship, value);\n } else if (kind === 'hasMany') {\n deserializeRecordIds(store, data, key, relationship, value);\n addUnsavedRecords(record, key, value);\n }\n });\n\n return data;\n}\n\nfunction deserializeRecordId(store, data, key, relationship, id) {\n if (isNone(id) || id instanceof DS.Model) {\n return;\n }\n\n var type;\n\n if (typeof id === 'number' || typeof id === 'string') {\n type = typeFor(relationship, key, data);\n data[key] = store.recordForId(type, id);\n } else if (typeof id === 'object') {\n // polymorphic\n data[key] = store.recordForId(id.type, id.id);\n }\n}\n\nfunction typeFor(relationship, key, data) {\n if (relationship.options.polymorphic) {\n return data[key + \"Type\"];\n } else {\n return relationship.type;\n }\n}\n\nfunction deserializeRecordIds(store, data, key, relationship, ids) {\n for (var i=0, l=ids.length; i<l; i++) {\n deserializeRecordId(store, ids, i, relationship, ids[i]);\n }\n}\n\n// If there are any unsaved records that are in a hasMany they won't be\n// in the payload, so add them back in manually.\nfunction addUnsavedRecords(record, key, data) {\n if(record) {\n data.pushObjects(record.get(key).filterBy('isNew'));\n }\n}\n\n// Delegation to the adapter and promise management\n/**\n A `PromiseArray` is an object that acts like both an `Ember.Array`\n and a promise. When the promise is resolved the the resulting value\n will be set to the `PromiseArray`'s `content` property. This makes\n it easy to create data bindings with the `PromiseArray` that will be\n updated when the promise resolves.\n\n For more information see the [Ember.PromiseProxyMixin\n documentation](/api/classes/Ember.PromiseProxyMixin.html).\n\n Example\n\n ```javascript\n var promiseArray = DS.PromiseArray.create({\n promise: $.getJSON('/some/remote/data.json')\n });\n\n promiseArray.get('length'); // 0\n\n promiseArray.then(function() {\n promiseArray.get('length'); // 100\n });\n ```\n\n @class PromiseArray\n @namespace DS\n @extends Ember.ArrayProxy\n @uses Ember.PromiseProxyMixin\n*/\nDS.PromiseArray = Ember.ArrayProxy.extend(Ember.PromiseProxyMixin);\n/**\n A `PromiseObject` is an object that acts like both an `Ember.Object`\n and a promise. When the promise is resolved the the resulting value\n will be set to the `PromiseObject`'s `content` property. This makes\n it easy to create data bindings with the `PromiseObject` that will\n be updated when the promise resolves.\n\n For more information see the [Ember.PromiseProxyMixin\n documentation](/api/classes/Ember.PromiseProxyMixin.html).\n\n Example\n\n ```javascript\n var promiseObject = DS.PromiseObject.create({\n promise: $.getJSON('/some/remote/data.json')\n });\n\n promiseObject.get('name'); // null\n\n promiseObject.then(function() {\n promiseObject.get('name'); // 'Tomster'\n });\n ```\n\n @class PromiseObject\n @namespace DS\n @extends Ember.ObjectProxy\n @uses Ember.PromiseProxyMixin\n*/\nDS.PromiseObject = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin);\n\nfunction promiseObject(promise) {\n return DS.PromiseObject.create({ promise: promise });\n}\n\nfunction promiseArray(promise) {\n return DS.PromiseArray.create({ promise: promise });\n}\n\nfunction isThenable(object) {\n return object && typeof object.then === 'function';\n}\n\nfunction serializerFor(container, type, defaultSerializer) {\n return container.lookup('serializer:'+type) ||\n container.lookup('serializer:application') ||\n container.lookup('serializer:' + defaultSerializer) ||\n container.lookup('serializer:_default');\n}\n\nfunction defaultSerializer(container) {\n return container.lookup('serializer:application') ||\n container.lookup('serializer:_default');\n}\n\nfunction serializerForAdapter(adapter, type) {\n var serializer = adapter.serializer,\n defaultSerializer = adapter.defaultSerializer,\n container = adapter.container;\n\n if (container && serializer === undefined) {\n serializer = serializerFor(container, type.typeKey, defaultSerializer);\n }\n\n if (serializer === null || serializer === undefined) {\n serializer = {\n extract: function(store, type, payload) { return payload; }\n };\n }\n\n return serializer;\n}\n\nfunction _find(adapter, store, type, id) {\n var promise = adapter.find(store, type, id),\n serializer = serializerForAdapter(adapter, type);\n\n return resolve(promise, \"DS: Handle Adapter#find of \" + type + \" with id: \" + id).then(function(payload) {\n Ember.assert(\"You made a request for a \" + type.typeKey + \" with id \" + id + \", but the adapter's response did not have any data\", payload);\n payload = serializer.extract(store, type, payload, id, 'find');\n\n return store.push(type, payload);\n }, function(error) {\n var record = store.getById(type, id);\n record.notFound();\n throw error;\n }, \"DS: Extract payload of '\" + type + \"'\");\n}\n\nfunction _findMany(adapter, store, type, ids, owner) {\n var promise = adapter.findMany(store, type, ids, owner),\n serializer = serializerForAdapter(adapter, type);\n\n return resolve(promise, \"DS: Handle Adapter#findMany of \" + type).then(function(payload) {\n payload = serializer.extract(store, type, payload, null, 'findMany');\n\n Ember.assert(\"The response from a findMany must be an Array, not \" + Ember.inspect(payload), Ember.typeOf(payload) === 'array');\n\n store.pushMany(type, payload);\n }, null, \"DS: Extract payload of \" + type);\n}\n\nfunction _findHasMany(adapter, store, record, link, relationship) {\n var promise = adapter.findHasMany(store, record, link, relationship),\n serializer = serializerForAdapter(adapter, relationship.type);\n\n return resolve(promise, \"DS: Handle Adapter#findHasMany of \" + record + \" : \" + relationship.type).then(function(payload) {\n payload = serializer.extract(store, relationship.type, payload, null, 'findHasMany');\n\n Ember.assert(\"The response from a findHasMany must be an Array, not \" + Ember.inspect(payload), Ember.typeOf(payload) === 'array');\n\n var records = store.pushMany(relationship.type, payload);\n record.updateHasMany(relationship.key, records);\n }, null, \"DS: Extract payload of \" + record + \" : hasMany \" + relationship.type);\n}\n\nfunction _findBelongsTo(adapter, store, record, link, relationship) {\n var promise = adapter.findBelongsTo(store, record, link, relationship),\n serializer = serializerForAdapter(adapter, relationship.type);\n\n return resolve(promise, \"DS: Handle Adapter#findBelongsTo of \" + record + \" : \" + relationship.type).then(function(payload) {\n payload = serializer.extract(store, relationship.type, payload, null, 'findBelongsTo');\n\n var record = store.push(relationship.type, payload);\n record.updateBelongsTo(relationship.key, record);\n return record;\n }, null, \"DS: Extract payload of \" + record + \" : \" + relationship.type);\n}\n\nfunction _findAll(adapter, store, type, sinceToken) {\n var promise = adapter.findAll(store, type, sinceToken),\n serializer = serializerForAdapter(adapter, type);\n\n return resolve(promise, \"DS: Handle Adapter#findAll of \" + type).then(function(payload) {\n payload = serializer.extract(store, type, payload, null, 'findAll');\n\n Ember.assert(\"The response from a findAll must be an Array, not \" + Ember.inspect(payload), Ember.typeOf(payload) === 'array');\n\n store.pushMany(type, payload);\n store.didUpdateAll(type);\n return store.all(type);\n }, null, \"DS: Extract payload of findAll \" + type);\n}\n\nfunction _findQuery(adapter, store, type, query, recordArray) {\n var promise = adapter.findQuery(store, type, query, recordArray),\n serializer = serializerForAdapter(adapter, type);\n\n return resolve(promise, \"DS: Handle Adapter#findQuery of \" + type).then(function(payload) {\n payload = serializer.extract(store, type, payload, null, 'findQuery');\n\n Ember.assert(\"The response from a findQuery must be an Array, not \" + Ember.inspect(payload), Ember.typeOf(payload) === 'array');\n\n recordArray.load(payload);\n return recordArray;\n }, null, \"DS: Extract payload of findQuery \" + type);\n}\n\nfunction _commit(adapter, store, operation, record) {\n var type = record.constructor,\n promise = adapter[operation](store, type, record),\n serializer = serializerForAdapter(adapter, type);\n\n Ember.assert(\"Your adapter's '\" + operation + \"' method must return a promise, but it returned \" + promise, isThenable(promise));\n\n return promise.then(function(payload) {\n if (payload) { payload = serializer.extract(store, type, payload, get(record, 'id'), operation); }\n store.didSaveRecord(record, payload);\n return record;\n }, function(reason) {\n if (reason instanceof DS.InvalidError) {\n store.recordWasInvalid(record, reason.errors);\n } else {\n store.recordWasError(record, reason);\n }\n\n throw reason;\n }, \"DS: Extract and notify about \" + operation + \" completion of \" + record);\n}\n\n})();\n//@ sourceURL=ember-data/system/store");minispade.register('ember-data/transforms/base', "(function() {/**\n The `DS.Transform` class is used to serialize and deserialize model\n attributes when they are saved or loaded from an\n adapter. Subclassing `DS.Transform` is useful for creating custom\n attributes. All subclasses of `DS.Transform` must implement a\n `serialize` and a `deserialize` method.\n\n Example\n\n ```javascript\n App.RawTransform = DS.Transform.extend({\n deserialize: function(serialized) {\n return serialized;\n },\n serialize: function(deserialized) {\n return deserialized;\n }\n });\n ```\n\n Usage\n\n ```javascript\n var attr = DS.attr;\n App.Requirement = DS.Model.extend({\n name: attr('string'),\n optionsArray: attr('raw')\n });\n ```\n\n @class Transform\n @namespace DS\n */\nDS.Transform = Ember.Object.extend({\n /**\n When given a deserialized value from a record attribute this\n method must return the serialized value.\n\n Example\n\n ```javascript\n serialize: function(deserialized) {\n return Ember.isEmpty(deserialized) ? null : Number(deserialized);\n }\n ```\n\n @method serialize\n @param deserialized The deserialized value\n @return The serialized value\n */\n serialize: Ember.required(),\n\n /**\n When given a serialize value from a JSON object this method must\n return the deserialized value for the record attribute.\n\n Example\n\n ```javascript\n deserialize: function(serialized) {\n return empty(serialized) ? null : Number(serialized);\n }\n ```\n\n @method deserialize\n @param serialized The serialized value\n @return The deserialized value\n */\n deserialize: Ember.required()\n\n});\n\n})();\n//@ sourceURL=ember-data/transforms/base");minispade.register('ember-data/transforms/boolean', "(function() {\n/**\n The `DS.BooleanTransform` class is used to serialize and deserialize\n boolean attributes on Ember Data record objects. This transform is\n used when `boolean` is passed as the type parameter to the\n [DS.attr](../../data#method_attr) function.\n\n Usage\n\n ```javascript\n var attr = DS.attr;\n App.User = DS.Model.extend({\n isAdmin: attr('boolean'),\n name: attr('string'),\n email: attr('string')\n });\n ```\n\n @class BooleanTransform\n @extends DS.Transform\n @namespace DS\n */\nDS.BooleanTransform = DS.Transform.extend({\n deserialize: function(serialized) {\n var type = typeof serialized;\n\n if (type === \"boolean\") {\n return serialized;\n } else if (type === \"string\") {\n return serialized.match(/^true$|^t$|^1$/i) !== null;\n } else if (type === \"number\") {\n return serialized === 1;\n } else {\n return false;\n }\n },\n\n serialize: function(deserialized) {\n return Boolean(deserialized);\n }\n});\n\n})();\n//@ sourceURL=ember-data/transforms/boolean");minispade.register('ember-data/transforms/date', "(function() {/**\n The `DS.DateTransform` class is used to serialize and deserialize\n date attributes on Ember Data record objects. This transform is used\n when `date` is passed as the type parameter to the\n [DS.attr](../../data#method_attr) function.\n\n ```javascript\n var attr = DS.attr;\n App.Score = DS.Model.extend({\n value: attr('number'),\n player: DS.belongsTo('player'),\n date: attr('date')\n });\n ```\n\n @class DateTransform\n @extends DS.Transform\n @namespace DS\n */\nDS.DateTransform = DS.Transform.extend({\n\n deserialize: function(serialized) {\n var type = typeof serialized;\n\n if (type === \"string\") {\n return new Date(Ember.Date.parse(serialized));\n } else if (type === \"number\") {\n return new Date(serialized);\n } else if (serialized === null || serialized === undefined) {\n // if the value is not present in the data,\n // return undefined, not null.\n return serialized;\n } else {\n return null;\n }\n },\n\n serialize: function(date) {\n if (date instanceof Date) {\n var days = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n var months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\n var pad = function(num) {\n return num < 10 ? \"0\"+num : \"\"+num;\n };\n\n var utcYear = date.getUTCFullYear(),\n utcMonth = date.getUTCMonth(),\n utcDayOfMonth = date.getUTCDate(),\n utcDay = date.getUTCDay(),\n utcHours = date.getUTCHours(),\n utcMinutes = date.getUTCMinutes(),\n utcSeconds = date.getUTCSeconds();\n\n\n var dayOfWeek = days[utcDay];\n var dayOfMonth = pad(utcDayOfMonth);\n var month = months[utcMonth];\n\n return dayOfWeek + \", \" + dayOfMonth + \" \" + month + \" \" + utcYear + \" \" +\n pad(utcHours) + \":\" + pad(utcMinutes) + \":\" + pad(utcSeconds) + \" GMT\";\n } else {\n return null;\n }\n } \n\n});\n\n})();\n//@ sourceURL=ember-data/transforms/date");minispade.register('ember-data/transforms/index', "(function() {minispade.require('ember-data/transforms/base');\nminispade.require('ember-data/transforms/boolean');\nminispade.require('ember-data/transforms/date');\nminispade.require('ember-data/transforms/number');\nminispade.require('ember-data/transforms/string');\n})();\n//@ sourceURL=ember-data/transforms/index");minispade.register('ember-data/transforms/number', "(function() {var empty = Ember.isEmpty;\n/**\n The `DS.NumberTransform` class is used to serialize and deserialize\n numeric attributes on Ember Data record objects. This transform is\n used when `number` is passed as the type parameter to the\n [DS.attr](../../data#method_attr) function.\n\n Usage\n\n ```javascript\n var attr = DS.attr;\n App.Score = DS.Model.extend({\n value: attr('number'),\n player: DS.belongsTo('player'),\n date: attr('date')\n });\n ```\n\n @class NumberTransform\n @extends DS.Transform\n @namespace DS\n */\nDS.NumberTransform = DS.Transform.extend({\n\n deserialize: function(serialized) {\n return empty(serialized) ? null : Number(serialized);\n },\n\n serialize: function(deserialized) {\n return empty(deserialized) ? null : Number(deserialized);\n }\n});\n\n})();\n//@ sourceURL=ember-data/transforms/number");minispade.register('ember-data/transforms/string', "(function() {var none = Ember.isNone;\n\n/**\n The `DS.StringTransform` class is used to serialize and deserialize\n string attributes on Ember Data record objects. This transform is\n used when `string` is passed as the type parameter to the\n [DS.attr](../../data#method_attr) function.\n\n Usage\n\n ```javascript\n var attr = DS.attr;\n App.User = DS.Model.extend({\n isAdmin: attr('boolean'),\n name: attr('string'),\n email: attr('string')\n });\n ```\n\n @class StringTransform\n @extends DS.Transform\n @namespace DS\n */\nDS.StringTransform = DS.Transform.extend({\n\n deserialize: function(serialized) {\n return none(serialized) ? null : String(serialized);\n },\n\n serialize: function(deserialized) {\n return none(deserialized) ? null : String(deserialized);\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/transforms/string");minispade.register('ember-inflector/ext/string', "(function() {minispade.require('ember-inflector/system/string');\n\nif (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) {\n /**\n See {{#crossLink \"Ember.String/pluralize\"}}{{/crossLink}}\n\n @method pluralize\n @for String\n */\n String.prototype.pluralize = function() {\n return Ember.String.pluralize(this);\n };\n\n /**\n See {{#crossLink \"Ember.String/singularize\"}}{{/crossLink}}\n\n @method singularize\n @for String\n */\n String.prototype.singularize = function() {\n return Ember.String.singularize(this);\n };\n}\n\n})();\n//@ sourceURL=ember-inflector/ext/string");minispade.register('ember-inflector', "(function() {minispade.require('ember-inflector/system');\n\n})();\n//@ sourceURL=ember-inflector");minispade.register('ember-inflector/system', "(function() {minispade.require('ember-inflector/system/string');\r\nminispade.require('ember-inflector/system/inflector');\r\nminispade.require('ember-inflector/system/inflections');\r\nminispade.require('ember-inflector/ext/string');\r\n\r\nEmber.Inflector.inflector = new Ember.Inflector(Ember.Inflector.defaultRules);\r\n\n})();\n//@ sourceURL=ember-inflector/system");minispade.register('ember-inflector/system/inflections', "(function() {Ember.Inflector.defaultRules = {\n plurals: [\n [/$/, 's'],\n [/s$/i, 's'],\n [/^(ax|test)is$/i, '$1es'],\n [/(octop|vir)us$/i, '$1i'],\n [/(octop|vir)i$/i, '$1i'],\n [/(alias|status)$/i, '$1es'],\n [/(bu)s$/i, '$1ses'],\n [/(buffal|tomat)o$/i, '$1oes'],\n [/([ti])um$/i, '$1a'],\n [/([ti])a$/i, '$1a'],\n [/sis$/i, 'ses'],\n [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'],\n [/(hive)$/i, '$1s'],\n [/([^aeiouy]|qu)y$/i, '$1ies'],\n [/(x|ch|ss|sh)$/i, '$1es'],\n [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'],\n [/^(m|l)ouse$/i, '$1ice'],\n [/^(m|l)ice$/i, '$1ice'],\n [/^(ox)$/i, '$1en'],\n [/^(oxen)$/i, '$1'],\n [/(quiz)$/i, '$1zes']\n ],\n\n singular: [\n [/s$/i, ''],\n [/(ss)$/i, '$1'],\n [/(n)ews$/i, '$1ews'],\n [/([ti])a$/i, '$1um'],\n [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'],\n [/(^analy)(sis|ses)$/i, '$1sis'],\n [/([^f])ves$/i, '$1fe'],\n [/(hive)s$/i, '$1'],\n [/(tive)s$/i, '$1'],\n [/([lr])ves$/i, '$1f'],\n [/([^aeiouy]|qu)ies$/i, '$1y'],\n [/(s)eries$/i, '$1eries'],\n [/(m)ovies$/i, '$1ovie'],\n [/(x|ch|ss|sh)es$/i, '$1'],\n [/^(m|l)ice$/i, '$1ouse'],\n [/(bus)(es)?$/i, '$1'],\n [/(o)es$/i, '$1'],\n [/(shoe)s$/i, '$1'],\n [/(cris|test)(is|es)$/i, '$1is'],\n [/^(a)x[ie]s$/i, '$1xis'],\n [/(octop|vir)(us|i)$/i, '$1us'],\n [/(alias|status)(es)?$/i, '$1'],\n [/^(ox)en/i, '$1'],\n [/(vert|ind)ices$/i, '$1ex'],\n [/(matr)ices$/i, '$1ix'],\n [/(quiz)zes$/i, '$1'],\n [/(database)s$/i, '$1']\n ],\n\n irregularPairs: [\n ['person', 'people'],\n ['man', 'men'],\n ['child', 'children'],\n ['sex', 'sexes'],\n ['move', 'moves'],\n ['cow', 'kine'],\n ['zombie', 'zombies']\n ],\n\n uncountable: [\n 'equipment',\n 'information',\n 'rice',\n 'money',\n 'species',\n 'series',\n 'fish',\n 'sheep',\n 'jeans',\n 'police'\n ]\n};\n\n})();\n//@ sourceURL=ember-inflector/system/inflections");minispade.register('ember-inflector/system/inflector', "(function() {var BLANK_REGEX = /^\\s*$/;\n\nfunction loadUncountable(rules, uncountable) {\n for (var i = 0, length = uncountable.length; i < length; i++) {\n rules.uncountable[uncountable[i].toLowerCase()] = true;\n }\n}\n\nfunction loadIrregular(rules, irregularPairs) {\n var pair;\n\n for (var i = 0, length = irregularPairs.length; i < length; i++) {\n pair = irregularPairs[i];\n\n rules.irregular[pair[0].toLowerCase()] = pair[1];\n rules.irregularInverse[pair[1].toLowerCase()] = pair[0];\n }\n}\n\n/**\n Inflector.Ember provides a mechanism for supplying inflection rules for your\n application. Ember includes a default set of inflection rules, and provides an\n API for providing additional rules.\n\n Examples:\n\n Creating an inflector with no rules.\n\n ```js\n var inflector = new Ember.Inflector();\n ```\n\n Creating an inflector with the default ember ruleset.\n\n ```js\n var inflector = new Ember.Inflector(Ember.Inflector.defaultRules);\n\n inflector.pluralize('cow') //=> 'kine'\n inflector.singularize('kine') //=> 'cow'\n ```\n\n Creating an inflector and adding rules later.\n\n ```javascript\n var inflector = Ember.Inflector.inflector;\n\n inflector.pluralize('advice') // => 'advices'\n inflector.uncountable('advice');\n inflector.pluralize('advice') // => 'advice'\n\n inflector.pluralize('formula') // => 'formulas'\n inflector.irregular('formula', 'formulae');\n inflector.pluralize('formula') // => 'formulae'\n\n // you would not need to add these as they are the default rules\n inflector.plural(/$/, 's');\n inflector.singular(/s$/i, '');\n ```\n\n Creating an inflector with a nondefault ruleset.\n\n ```javascript\n var rules = {\n plurals: [ /$/, 's' ],\n singular: [ /\\s$/, '' ],\n irregularPairs: [\n [ 'cow', 'kine' ]\n ],\n uncountable: [ 'fish' ]\n };\n\n var inflector = new Ember.Inflector(rules);\n ```\n\n @class Inflector\n @namespace Ember\n*/\nfunction Inflector(ruleSet) {\n ruleSet = ruleSet || {};\n ruleSet.uncountable = ruleSet.uncountable || {};\n ruleSet.irregularPairs = ruleSet.irregularPairs || {};\n\n var rules = this.rules = {\n plurals: ruleSet.plurals || [],\n singular: ruleSet.singular || [],\n irregular: {},\n irregularInverse: {},\n uncountable: {}\n };\n\n loadUncountable(rules, ruleSet.uncountable);\n loadIrregular(rules, ruleSet.irregularPairs);\n}\n\nInflector.prototype = {\n /**\n @method plural\n @param {RegExp} regex\n @param {String} string\n */\n plural: function(regex, string) {\n this.rules.plurals.push([regex, string.toLowerCase()]);\n },\n\n /**\n @method singular\n @param {RegExp} regex\n @param {String} string\n */\n singular: function(regex, string) {\n this.rules.singular.push([regex, string.toLowerCase()]);\n },\n\n /**\n @method uncountable\n @param {String} regex\n */\n uncountable: function(string) {\n loadUncountable(this.rules, [string.toLowerCase()]);\n },\n\n /**\n @method irregular\n @param {String} singular\n @param {String} plural\n */\n irregular: function (singular, plural) {\n loadIrregular(this.rules, [[singular, plural]]);\n },\n\n /**\n @method pluralize\n @param {String} word\n */\n pluralize: function(word) {\n return this.inflect(word, this.rules.plurals, this.rules.irregular);\n },\n\n /**\n @method singularize\n @param {String} word\n */\n singularize: function(word) {\n return this.inflect(word, this.rules.singular, this.rules.irregularInverse);\n },\n\n /**\n @protected\n\n @method inflect\n @param {String} word\n @param {Object} typeRules\n @param {Object} irregular\n */\n inflect: function(word, typeRules, irregular) {\n var inflection, substitution, result, lowercase, isBlank,\n isUncountable, isIrregular, isIrregularInverse, rule;\n\n isBlank = BLANK_REGEX.test(word);\n\n if (isBlank) {\n return word;\n }\n\n lowercase = word.toLowerCase();\n\n isUncountable = this.rules.uncountable[lowercase];\n\n if (isUncountable) {\n return word;\n }\n\n isIrregular = irregular && irregular[lowercase];\n\n if (isIrregular) {\n return isIrregular;\n }\n\n for (var i = typeRules.length, min = 0; i > min; i--) {\n inflection = typeRules[i-1];\n rule = inflection[0];\n\n if (rule.test(word)) {\n break;\n }\n }\n\n inflection = inflection || [];\n\n rule = inflection[0];\n substitution = inflection[1];\n\n result = word.replace(rule, substitution);\n\n return result;\n }\n};\n\nEmber.Inflector = Inflector;\n\n})();\n//@ sourceURL=ember-inflector/system/inflector");minispade.register('ember-inflector/system/string', "(function() {Ember.String.pluralize = function(word) {\n return Ember.Inflector.inflector.pluralize(word);\n};\n\nEmber.String.singularize = function(word) {\n return Ember.Inflector.inflector.singularize(word);\n};\n\n})();\n//@ sourceURL=ember-inflector/system/string");
48
+ minispade.register('activemodel-adapter/initializers', "(function() {minispade.require(\"ember-data/system/container_proxy\");\n\nEmber.onLoad('Ember.Application', function(Application) {\n Application.initializer({\n name: \"activeModelAdapter\",\n\n initialize: function(container, application) {\n var proxy = new DS.ContainerProxy(container);\n proxy.registerDeprecations([\n {deprecated: 'serializer:_ams', valid: 'serializer:-active-model'},\n {deprecated: 'adapter:_ams', valid: 'adapter:-active-model'}\n ]);\n\n application.register('serializer:-active-model', DS.ActiveModelSerializer);\n application.register('adapter:-active-model', DS.ActiveModelAdapter);\n }\n });\n});\n\n})();\n//@ sourceURL=activemodel-adapter/initializers");minispade.register('activemodel-adapter', "(function() {minispade.require('activemodel-adapter/system');\nminispade.require('activemodel-adapter/initializers');\n\n})();\n//@ sourceURL=activemodel-adapter");minispade.register('activemodel-adapter/system', "(function() {minispade.require('activemodel-adapter/system/active_model_adapter');\n})();\n//@ sourceURL=activemodel-adapter/system");minispade.register('activemodel-adapter/system/active_model_adapter', "(function() {minispade.require('ember-data/adapters/rest_adapter');\nminispade.require('activemodel-adapter/system/active_model_serializer');\nminispade.require('activemodel-adapter/system/embedded_records_mixin');\n\n/**\n @module ember-data\n*/\n\nvar forEach = Ember.EnumerableUtils.forEach;\nvar decamelize = Ember.String.decamelize,\n underscore = Ember.String.underscore,\n pluralize = Ember.String.pluralize;\n\n/**\n The ActiveModelAdapter is a subclass of the RESTAdapter designed to integrate\n with a JSON API that uses an underscored naming convention instead of camelcasing.\n It has been designed to work out of the box with the\n [active_model_serializers](http://github.com/rails-api/active_model_serializers)\n Ruby gem.\n\n This adapter extends the DS.RESTAdapter by making consistent use of the camelization,\n decamelization and pluralization methods to normalize the serialized JSON into a\n format that is compatible with a conventional Rails backend and Ember Data.\n\n ## JSON Structure\n\n The ActiveModelAdapter expects the JSON returned from your server to follow\n the REST adapter conventions substituting underscored keys for camelcased ones.\n\n ### Conventional Names\n\n Attribute names in your JSON payload should be the underscored versions of\n the attributes in your Ember.js models.\n\n For example, if you have a `Person` model:\n\n ```js\n App.FamousPerson = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n occupation: DS.attr('string')\n });\n ```\n\n The JSON returned should look like this:\n\n ```js\n {\n \"famous_person\": {\n \"first_name\": \"Barack\",\n \"last_name\": \"Obama\",\n \"occupation\": \"President\"\n }\n }\n ```\n\n @class ActiveModelAdapter\n @constructor\n @namespace DS\n @extends DS.Adapter\n**/\n\nDS.ActiveModelAdapter = DS.RESTAdapter.extend({\n defaultSerializer: '-active-model',\n /**\n The ActiveModelAdapter overrides the `pathForType` method to build\n underscored URLs by decamelizing and pluralizing the object type name.\n\n ```js\n this.pathForType(\"famousPerson\");\n //=> \"famous_people\"\n ```\n\n @method pathForType\n @param {String} type\n @returns String\n */\n pathForType: function(type) {\n var decamelized = decamelize(type);\n var underscored = underscore(decamelized);\n return pluralize(underscored);\n },\n\n /**\n The ActiveModelAdapter overrides the `ajaxError` method\n to return a DS.InvalidError for all 422 Unprocessable Entity\n responses.\n\n A 422 HTTP response from the server generally implies that the request\n was well formed but the API was unable to process it because the\n content was not semantically correct or meaningful per the API.\n\n For more information on 422 HTTP Error code see 11.2 WebDAV RFC 4918\n https://tools.ietf.org/html/rfc4918#section-11.2\n\n @method ajaxError\n @param jqXHR\n @returns error\n */\n ajaxError: function(jqXHR) {\n var error = this._super(jqXHR);\n\n if (jqXHR && jqXHR.status === 422) {\n var response = Ember.$.parseJSON(jqXHR.responseText),\n errors = {};\n\n if (response.errors !== undefined) {\n var jsonErrors = response.errors;\n\n forEach(Ember.keys(jsonErrors), function(key) {\n errors[Ember.String.camelize(key)] = jsonErrors[key];\n });\n }\n\n return new DS.InvalidError(errors);\n } else {\n return error;\n }\n }\n});\n\n})();\n//@ sourceURL=activemodel-adapter/system/active_model_adapter");minispade.register('activemodel-adapter/system/active_model_serializer', "(function() {minispade.require('ember-data/serializers/rest_serializer');\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get,\n forEach = Ember.EnumerableUtils.forEach,\n camelize = Ember.String.camelize,\n capitalize = Ember.String.capitalize,\n decamelize = Ember.String.decamelize,\n singularize = Ember.String.singularize,\n underscore = Ember.String.underscore;\n\nDS.ActiveModelSerializer = DS.RESTSerializer.extend({\n // SERIALIZE\n\n /**\n Converts camelcased attributes to underscored when serializing.\n\n @method keyForAttribute\n @param {String} attribute\n @returns String\n */\n keyForAttribute: function(attr) {\n return decamelize(attr);\n },\n\n /**\n Underscores relationship names and appends \"_id\" or \"_ids\" when serializing\n relationship keys.\n\n @method keyForRelationship\n @param {String} key\n @param {String} kind\n @returns String\n */\n keyForRelationship: function(key, kind) {\n key = decamelize(key);\n if (kind === \"belongsTo\") {\n return key + \"_id\";\n } else if (kind === \"hasMany\") {\n return singularize(key) + \"_ids\";\n } else {\n return key;\n }\n },\n\n /**\n Does not serialize hasMany relationships by default.\n */\n serializeHasMany: Ember.K,\n\n /**\n Underscores the JSON root keys when serializing.\n\n @method serializeIntoHash\n @param {Object} hash\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @param {Object} options\n */\n serializeIntoHash: function(data, type, record, options) {\n var root = underscore(decamelize(type.typeKey));\n data[root] = this.serialize(record, options);\n },\n\n /**\n Serializes a polymorphic type as a fully capitalized model name.\n\n @method serializePolymorphicType\n @param {DS.Model} record\n @param {Object} json\n @param relationship\n */\n serializePolymorphicType: function(record, json, relationship) {\n var key = relationship.key,\n belongsTo = get(record, key);\n key = this.keyForAttribute(key);\n json[key + \"_type\"] = capitalize(camelize(belongsTo.constructor.typeKey));\n },\n\n // EXTRACT\n\n /**\n Extracts the model typeKey from underscored root objects.\n\n @method typeForRoot\n @param {String} root\n @returns String the model's typeKey\n */\n typeForRoot: function(root) {\n var camelized = camelize(root);\n return singularize(camelized);\n },\n\n /**\n Add extra step to `DS.RESTSerializer.normalize` so links are\n normalized.\n\n If your payload looks like this\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"links\": { \"flagged_comments\": \"api/comments/flagged\" }\n }\n }\n ```\n The normalized version would look like this\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"links\": { \"flaggedComments\": \"api/comments/flagged\" }\n }\n }\n ```\n\n @method normalize\n @param {subclass of DS.Model} type\n @param {Object} hash\n @param {String} prop\n @returns Object\n */\n\n normalize: function(type, hash, prop) {\n this.normalizeLinks(hash);\n\n return this._super(type, hash, prop);\n },\n\n /**\n Convert `snake_cased` links to `camelCase`\n\n @method normalizeLinks\n @param {Object} hash\n */\n\n normalizeLinks: function(data){\n if (data.links) {\n var links = data.links;\n\n for (var link in links) {\n var camelizedLink = camelize(link);\n\n if (camelizedLink !== link) {\n links[camelizedLink] = links[link];\n delete links[link];\n }\n }\n }\n },\n\n /**\n Normalize the polymorphic type from the JSON.\n\n Normalize:\n ```js\n {\n id: \"1\"\n minion: { type: \"evil_minion\", id: \"12\"}\n }\n ```\n\n To:\n ```js\n {\n id: \"1\"\n minion: { type: \"evilMinion\", id: \"12\"}\n }\n ```\n\n @method normalizeRelationships\n @private\n */\n normalizeRelationships: function(type, hash) {\n var payloadKey, payload;\n\n if (this.keyForRelationship) {\n type.eachRelationship(function(key, relationship) {\n if (relationship.options.polymorphic) {\n payloadKey = this.keyForAttribute(key);\n payload = hash[payloadKey];\n if (payload && payload.type) {\n payload.type = this.typeForRoot(payload.type);\n } else if (payload && relationship.kind === \"hasMany\") {\n var self = this;\n forEach(payload, function(single) {\n single.type = self.typeForRoot(single.type);\n });\n }\n } else {\n payloadKey = this.keyForRelationship(key, relationship.kind);\n payload = hash[payloadKey];\n }\n\n hash[key] = payload;\n\n if (key !== payloadKey) {\n delete hash[payloadKey];\n }\n }, this);\n }\n }\n});\n\n})();\n//@ sourceURL=activemodel-adapter/system/active_model_serializer");minispade.register('activemodel-adapter/system/embedded_records_mixin', "(function() {var get = Ember.get;\nvar forEach = Ember.EnumerableUtils.forEach;\n\n/**\n The EmbeddedRecordsMixin allows you to add embedded record support to your\n serializers.\n To set up embedded records, you include the mixin into the serializer and then\n define your embedded relations.\n\n ```js\n App.PostSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n comments: {embedded: 'always'}\n }\n })\n ```\n\n Currently only `{embedded: 'always'}` records are supported.\n\n @class EmbeddedRecordsMixin\n @namespace DS\n*/\nDS.EmbeddedRecordsMixin = Ember.Mixin.create({\n\n /**\n Serialize has-may relationship when it is configured as embedded objects.\n\n @method serializeHasMany\n */\n serializeHasMany: function(record, json, relationship) {\n var key = relationship.key,\n attrs = get(this, 'attrs'),\n embed = attrs && attrs[key] && attrs[key].embedded === 'always';\n\n if (embed) {\n json[this.keyForAttribute(key)] = get(record, key).map(function(relation) {\n var data = relation.serialize(),\n primaryKey = get(this, 'primaryKey');\n\n data[primaryKey] = get(relation, primaryKey);\n\n return data;\n }, this);\n }\n },\n\n /**\n Extract embedded objects out of the payload for a single object\n and add them as sideloaded objects instead.\n\n @method extractSingle\n */\n extractSingle: function(store, primaryType, payload, recordId, requestType) {\n var root = this.keyForAttribute(primaryType.typeKey),\n partial = payload[root];\n\n updatePayloadWithEmbedded(store, this, primaryType, partial, payload);\n\n return this._super(store, primaryType, payload, recordId, requestType);\n },\n\n /**\n Extract embedded objects out of a standard payload\n and add them as sideloaded objects instead.\n\n @method extractArray\n */\n extractArray: function(store, type, payload) {\n var root = this.keyForAttribute(type.typeKey),\n partials = payload[Ember.String.pluralize(root)];\n\n forEach(partials, function(partial) {\n updatePayloadWithEmbedded(store, this, type, partial, payload);\n }, this);\n\n return this._super(store, type, payload);\n }\n});\n\nfunction updatePayloadWithEmbedded(store, serializer, type, partial, payload) {\n var attrs = get(serializer, 'attrs');\n\n if (!attrs) {\n return;\n }\n\n type.eachRelationship(function(key, relationship) {\n var expandedKey, embeddedTypeKey, attribute, ids,\n config = attrs[key],\n serializer = store.serializerFor(relationship.type.typeKey),\n primaryKey = get(serializer, \"primaryKey\");\n\n if (relationship.kind !== \"hasMany\") {\n return;\n }\n\n if (config && (config.embedded === 'always' || config.embedded === 'load')) {\n // underscore forces the embedded records to be side loaded.\n // it is needed when main type === relationship.type\n embeddedTypeKey = '_' + Ember.String.pluralize(relationship.type.typeKey);\n expandedKey = this.keyForRelationship(key, relationship.kind);\n attribute = this.keyForAttribute(key);\n ids = [];\n\n if (!partial[attribute]) {\n return;\n }\n\n payload[embeddedTypeKey] = payload[embeddedTypeKey] || [];\n\n forEach(partial[attribute], function(data) {\n var embeddedType = store.modelFor(relationship.type.typeKey);\n updatePayloadWithEmbedded(store, serializer, embeddedType, data, payload);\n ids.push(data[primaryKey]);\n payload[embeddedTypeKey].push(data);\n });\n\n partial[expandedKey] = ids;\n delete partial[attribute];\n }\n }, serializer);\n}\n})();\n//@ sourceURL=activemodel-adapter/system/embedded_records_mixin");minispade.register('ember-data/adapters', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/adapters/fixture_adapter\");\nminispade.require(\"ember-data/adapters/rest_adapter\");\n\n})();\n//@ sourceURL=ember-data/adapters");minispade.register('ember-data/adapters/fixture_adapter', "(function() {minispade.require(\"ember-data/core\");\nminispade.require(\"ember-data/system/adapter\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, fmt = Ember.String.fmt,\n indexOf = Ember.EnumerableUtils.indexOf;\n\nvar counter = 0;\n\n/**\n `DS.FixtureAdapter` is an adapter that loads records from memory.\n Its primarily used for development and testing. You can also use\n `DS.FixtureAdapter` while working on the API but are not ready to\n integrate yet. It is a fully functioning adapter. All CRUD methods\n are implemented. You can also implement query logic that a remote\n system would do. Its possible to do develop your entire application\n with `DS.FixtureAdapter`.\n\n For information on how to use the `FixtureAdapter` in your\n application please see the [FixtureAdapter\n guide](/guides/models/the-fixture-adapter/).\n\n @class FixtureAdapter\n @namespace DS\n @extends DS.Adapter\n*/\nDS.FixtureAdapter = DS.Adapter.extend({\n // by default, fixtures are already in normalized form\n serializer: null,\n\n /**\n If `simulateRemoteResponse` is `true` the `FixtureAdapter` will\n wait a number of milliseconds before resolving promises with the\n fixture values. The wait time can be configured via the `latency`\n property.\n\n @property simulateRemoteResponse\n @type {Boolean}\n @default true\n */\n simulateRemoteResponse: true,\n\n /**\n By default the `FixtureAdapter` will simulate a wait of the\n `latency` milliseconds before resolving promises with the fixture\n values. This behavior can be turned off via the\n `simulateRemoteResponse` property.\n\n @property latency\n @type {Number}\n @default 50\n */\n latency: 50,\n\n /**\n Implement this method in order to provide data associated with a type\n\n @method fixturesForType\n @param {Subclass of DS.Model} type\n @return {Array}\n */\n fixturesForType: function(type) {\n if (type.FIXTURES) {\n var fixtures = Ember.A(type.FIXTURES);\n return fixtures.map(function(fixture){\n var fixtureIdType = typeof fixture.id;\n if(fixtureIdType !== \"number\" && fixtureIdType !== \"string\"){\n throw new Error(fmt('the id property must be defined as a number or string for fixture %@', [fixture]));\n }\n fixture.id = fixture.id + '';\n return fixture;\n });\n }\n return null;\n },\n\n /**\n Implement this method in order to query fixtures data\n\n @method queryFixtures\n @param {Array} fixture\n @param {Object} query\n @param {Subclass of DS.Model} type\n @return {Promise|Array}\n */\n queryFixtures: function(fixtures, query, type) {\n Ember.assert('Not implemented: You must override the DS.FixtureAdapter::queryFixtures method to support querying the fixture store.');\n },\n\n /**\n @method updateFixtures\n @param {Subclass of DS.Model} type\n @param {Array} fixture\n */\n updateFixtures: function(type, fixture) {\n if(!type.FIXTURES) {\n type.FIXTURES = [];\n }\n\n var fixtures = type.FIXTURES;\n\n this.deleteLoadedFixture(type, fixture);\n\n fixtures.push(fixture);\n },\n\n /**\n Implement this method in order to provide json for CRUD methods\n\n @method mockJSON\n @param {Subclass of DS.Model} type\n @param {DS.Model} record\n */\n mockJSON: function(store, type, record) {\n return store.serializerFor(type).serialize(record, { includeId: true });\n },\n\n /**\n @method generateIdForRecord\n @param {DS.Store} store\n @param {DS.Model} record\n @return {String} id\n */\n generateIdForRecord: function(store) {\n return \"fixture-\" + counter++;\n },\n\n /**\n @method find\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} id\n @return {Promise} promise\n */\n find: function(store, type, id) {\n var fixtures = this.fixturesForType(type),\n fixture;\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), fixtures);\n\n if (fixtures) {\n fixture = Ember.A(fixtures).findProperty('id', id);\n }\n\n if (fixture) {\n return this.simulateRemoteCall(function() {\n return fixture;\n }, this);\n }\n },\n\n /**\n @method findMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Array} ids\n @return {Promise} promise\n */\n findMany: function(store, type, ids) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), fixtures);\n\n if (fixtures) {\n fixtures = fixtures.filter(function(item) {\n return indexOf(ids, item.id) !== -1;\n });\n }\n\n if (fixtures) {\n return this.simulateRemoteCall(function() {\n return fixtures;\n }, this);\n }\n },\n\n /**\n @private\n @method findAll\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} sinceToken\n @return {Promise} promise\n */\n findAll: function(store, type) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), fixtures);\n\n return this.simulateRemoteCall(function() {\n return fixtures;\n }, this);\n },\n\n /**\n @private\n @method findQuery\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} query\n @param {DS.AdapterPopulatedRecordArray} recordArray\n @return {Promise} promise\n */\n findQuery: function(store, type, query, array) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), fixtures);\n\n fixtures = this.queryFixtures(fixtures, query, type);\n\n if (fixtures) {\n return this.simulateRemoteCall(function() {\n return fixtures;\n }, this);\n }\n },\n\n /**\n @method createRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @return {Promise} promise\n */\n createRecord: function(store, type, record) {\n var fixture = this.mockJSON(store, type, record);\n\n this.updateFixtures(type, fixture);\n\n return this.simulateRemoteCall(function() {\n return fixture;\n }, this);\n },\n\n /**\n @method updateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @return {Promise} promise\n */\n updateRecord: function(store, type, record) {\n var fixture = this.mockJSON(store, type, record);\n\n this.updateFixtures(type, fixture);\n\n return this.simulateRemoteCall(function() {\n return fixture;\n }, this);\n },\n\n /**\n @method deleteRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @return {Promise} promise\n */\n deleteRecord: function(store, type, record) {\n var fixture = this.mockJSON(store, type, record);\n\n this.deleteLoadedFixture(type, fixture);\n\n return this.simulateRemoteCall(function() {\n // no payload in a deletion\n return null;\n });\n },\n\n /*\n @method deleteLoadedFixture\n @private\n @param type\n @param record\n */\n deleteLoadedFixture: function(type, record) {\n var existingFixture = this.findExistingFixture(type, record);\n\n if(existingFixture) {\n var index = indexOf(type.FIXTURES, existingFixture);\n type.FIXTURES.splice(index, 1);\n return true;\n }\n },\n\n /*\n @method findExistingFixture\n @private\n @param type\n @param record\n */\n findExistingFixture: function(type, record) {\n var fixtures = this.fixturesForType(type);\n var id = get(record, 'id');\n\n return this.findFixtureById(fixtures, id);\n },\n\n /*\n @method findFixtureById\n @private\n @param fixtures\n @param id\n */\n findFixtureById: function(fixtures, id) {\n return Ember.A(fixtures).find(function(r) {\n if(''+get(r, 'id') === ''+id) {\n return true;\n } else {\n return false;\n }\n });\n },\n\n /*\n @method simulateRemoteCall\n @private\n @param callback\n @param context\n */\n simulateRemoteCall: function(callback, context) {\n var adapter = this;\n\n return new Ember.RSVP.Promise(function(resolve) {\n if (get(adapter, 'simulateRemoteResponse')) {\n // Schedule with setTimeout\n Ember.run.later(function() {\n resolve(callback.call(context));\n }, get(adapter, 'latency'));\n } else {\n // Asynchronous, but at the of the runloop with zero latency\n Ember.run.schedule('actions', null, function() {\n resolve(callback.call(context));\n });\n }\n }, \"DS: FixtureAdapter#simulateRemoteCall\");\n }\n});\n\n})();\n//@ sourceURL=ember-data/adapters/fixture_adapter");minispade.register('ember-data/adapters/rest_adapter', "(function() {minispade.require(\"ember-data/core\");\nminispade.require('ember-data/system/adapter');\nminispade.require('ember-data/serializers/rest_serializer');\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar forEach = Ember.ArrayPolyfills.forEach;\n\n/**\n The REST adapter allows your store to communicate with an HTTP server by\n transmitting JSON via XHR. Most Ember.js apps that consume a JSON API\n should use the REST adapter.\n\n This adapter is designed around the idea that the JSON exchanged with\n the server should be conventional.\n\n ## JSON Structure\n\n The REST adapter expects the JSON returned from your server to follow\n these conventions.\n\n ### Object Root\n\n The JSON payload should be an object that contains the record inside a\n root property. For example, in response to a `GET` request for\n `/posts/1`, the JSON should look like this:\n\n ```js\n {\n \"post\": {\n \"title\": \"I'm Running to Reform the W3C's Tag\",\n \"author\": \"Yehuda Katz\"\n }\n }\n ```\n\n ### Conventional Names\n\n Attribute names in your JSON payload should be the camelCased versions of\n the attributes in your Ember.js models.\n\n For example, if you have a `Person` model:\n\n ```js\n App.Person = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n occupation: DS.attr('string')\n });\n ```\n\n The JSON returned should look like this:\n\n ```js\n {\n \"person\": {\n \"firstName\": \"Barack\",\n \"lastName\": \"Obama\",\n \"occupation\": \"President\"\n }\n }\n ```\n\n ## Customization\n\n ### Endpoint path customization\n\n Endpoint paths can be prefixed with a `namespace` by setting the namespace\n property on the adapter:\n\n ```js\n DS.RESTAdapter.reopen({\n namespace: 'api/1'\n });\n ```\n Requests for `App.Person` would now target `/api/1/people/1`.\n\n ### Host customization\n\n An adapter can target other hosts by setting the `host` property.\n\n ```js\n DS.RESTAdapter.reopen({\n host: 'https://api.example.com'\n });\n ```\n\n ### Headers customization\n\n Some APIs require HTTP headers, e.g. to provide an API key. An array of\n headers can be added to the adapter which are passed with every request:\n\n ```js\n DS.RESTAdapter.reopen({\n headers: {\n \"API_KEY\": \"secret key\",\n \"ANOTHER_HEADER\": \"Some header value\"\n }\n });\n ```\n\n @class RESTAdapter\n @constructor\n @namespace DS\n @extends DS.Adapter\n*/\nDS.RESTAdapter = DS.Adapter.extend({\n defaultSerializer: '-rest',\n\n\n /**\n Endpoint paths can be prefixed with a `namespace` by setting the namespace\n property on the adapter:\n\n ```javascript\n DS.RESTAdapter.reopen({\n namespace: 'api/1'\n });\n ```\n\n Requests for `App.Post` would now target `/api/1/post/`.\n\n @property namespace\n @type {String}\n */\n\n /**\n An adapter can target other hosts by setting the `host` property.\n\n ```javascript\n DS.RESTAdapter.reopen({\n host: 'https://api.example.com'\n });\n ```\n\n Requests for `App.Post` would now target `https://api.example.com/post/`.\n\n @property host\n @type {String}\n */\n\n /**\n Some APIs require HTTP headers, e.g. to provide an API key. An array of\n headers can be added to the adapter which are passed with every request:\n\n ```javascript\n DS.RESTAdapter.reopen({\n headers: {\n \"API_KEY\": \"secret key\",\n \"ANOTHER_HEADER\": \"Some header value\"\n }\n });\n ```\n\n @property headers\n @type {Object}\n */\n\n /**\n Called by the store in order to fetch the JSON for a given\n type and ID.\n\n The `find` method makes an Ajax request to a URL computed by `buildURL`, and returns a\n promise for the resulting payload.\n\n This method performs an HTTP `GET` request with the id provided as part of the query string.\n\n @method find\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} id\n @returns {Promise} promise\n */\n find: function(store, type, id) {\n return this.ajax(this.buildURL(type.typeKey, id), 'GET');\n },\n\n /**\n Called by the store in order to fetch a JSON array for all\n of the records for a given type.\n\n The `findAll` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a\n promise for the resulting payload.\n\n @private\n @method findAll\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} sinceToken\n @returns {Promise} promise\n */\n findAll: function(store, type, sinceToken) {\n var query;\n\n if (sinceToken) {\n query = { since: sinceToken };\n }\n\n return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query });\n },\n\n /**\n Called by the store in order to fetch a JSON array for\n the records that match a particular query.\n\n The `findQuery` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a\n promise for the resulting payload.\n\n The `query` argument is a simple JavaScript object that will be passed directly\n to the server as parameters.\n\n @private\n @method findQuery\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} query\n @returns {Promise} promise\n */\n findQuery: function(store, type, query) {\n return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query });\n },\n\n /**\n Called by the store in order to fetch a JSON array for\n the unloaded records in a has-many relationship that were originally\n specified as IDs.\n\n For example, if the original payload looks like:\n\n ```js\n {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"comments\": [ 1, 2, 3 ]\n }\n ```\n\n The IDs will be passed as a URL-encoded Array of IDs, in this form:\n\n ```\n ids[]=1&ids[]=2&ids[]=3\n ```\n\n Many servers, such as Rails and PHP, will automatically convert this URL-encoded array\n into an Array for you on the server-side. If you want to encode the\n IDs, differently, just override this (one-line) method.\n\n The `findMany` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a\n promise for the resulting payload.\n\n @method findMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Array} ids\n @returns {Promise} promise\n */\n findMany: function(store, type, ids) {\n return this.ajax(this.buildURL(type.typeKey), 'GET', { data: { ids: ids } });\n },\n\n /**\n Called by the store in order to fetch a JSON array for\n the unloaded records in a has-many relationship that were originally\n specified as a URL (inside of `links`).\n\n For example, if your original payload looks like this:\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"links\": { \"comments\": \"/posts/1/comments\" }\n }\n }\n ```\n\n This method will be called with the parent record and `/posts/1/comments`.\n\n The `findHasMany` method will make an Ajax (HTTP GET) request to the originally specified URL.\n If the URL is host-relative (starting with a single slash), the\n request will use the host specified on the adapter (if any).\n\n @method findHasMany\n @param {DS.Store} store\n @param {DS.Model} record\n @param {String} url\n @returns {Promise} promise\n */\n findHasMany: function(store, record, url) {\n var host = get(this, 'host'),\n id = get(record, 'id'),\n type = record.constructor.typeKey;\n\n if (host && url.charAt(0) === '/' && url.charAt(1) !== '/') {\n url = host + url;\n }\n\n return this.ajax(this.urlPrefix(url, this.buildURL(type, id)), 'GET');\n },\n\n /**\n Called by the store in order to fetch a JSON array for\n the unloaded records in a belongs-to relationship that were originally\n specified as a URL (inside of `links`).\n\n For example, if your original payload looks like this:\n\n ```js\n {\n \"person\": {\n \"id\": 1,\n \"name\": \"Tom Dale\",\n \"links\": { \"group\": \"/people/1/group\" }\n }\n }\n ```\n\n This method will be called with the parent record and `/people/1/group`.\n\n The `findBelongsTo` method will make an Ajax (HTTP GET) request to the originally specified URL.\n\n @method findBelongsTo\n @param {DS.Store} store\n @param {DS.Model} record\n @param {String} url\n @returns {Promise} promise\n */\n findBelongsTo: function(store, record, url) {\n var id = get(record, 'id'),\n type = record.constructor.typeKey;\n\n return this.ajax(this.urlPrefix(url, this.buildURL(type, id)), 'GET');\n },\n\n /**\n Called by the store when a newly created record is\n saved via the `save` method on a model record instance.\n\n The `createRecord` method serializes the record and makes an Ajax (HTTP POST) request\n to a URL computed by `buildURL`.\n\n See `serialize` for information on how to customize the serialized form\n of a record.\n\n @method createRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @returns {Promise} promise\n */\n createRecord: function(store, type, record) {\n var data = {};\n var serializer = store.serializerFor(type.typeKey);\n\n serializer.serializeIntoHash(data, type, record, { includeId: true });\n\n return this.ajax(this.buildURL(type.typeKey), \"POST\", { data: data });\n },\n\n /**\n Called by the store when an existing record is saved\n via the `save` method on a model record instance.\n\n The `updateRecord` method serializes the record and makes an Ajax (HTTP PUT) request\n to a URL computed by `buildURL`.\n\n See `serialize` for information on how to customize the serialized form\n of a record.\n\n @method updateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @returns {Promise} promise\n */\n updateRecord: function(store, type, record) {\n var data = {};\n var serializer = store.serializerFor(type.typeKey);\n\n serializer.serializeIntoHash(data, type, record);\n\n var id = get(record, 'id');\n\n return this.ajax(this.buildURL(type.typeKey, id), \"PUT\", { data: data });\n },\n\n /**\n Called by the store when a record is deleted.\n\n The `deleteRecord` method makes an Ajax (HTTP DELETE) request to a URL computed by `buildURL`.\n\n @method deleteRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @returns {Promise} promise\n */\n deleteRecord: function(store, type, record) {\n var id = get(record, 'id');\n\n return this.ajax(this.buildURL(type.typeKey, id), \"DELETE\");\n },\n\n /**\n Builds a URL for a given type and optional ID.\n\n By default, it pluralizes the type's name (for example, 'post'\n becomes 'posts' and 'person' becomes 'people'). To override the\n pluralization see [pathForType](#method_pathForType).\n\n If an ID is specified, it adds the ID to the path generated\n for the type, separated by a `/`.\n\n @method buildURL\n @param {String} type\n @param {String} id\n @returns {String} url\n */\n buildURL: function(type, id) {\n var url = [],\n host = get(this, 'host'),\n prefix = this.urlPrefix();\n\n if (type) { url.push(this.pathForType(type)); }\n if (id) { url.push(id); }\n\n if (prefix) { url.unshift(prefix); }\n\n url = url.join('/');\n if (!host && url) { url = '/' + url; }\n\n return url;\n },\n\n /**\n @method urlPrefix\n @private\n @param {String} path\n @param {String} parentUrl\n @return {String} urlPrefix\n */\n urlPrefix: function(path, parentURL) {\n var host = get(this, 'host'),\n namespace = get(this, 'namespace'),\n url = [];\n\n if (path) {\n // Absolute path\n if (path.charAt(0) === '/') {\n if (host) {\n path = path.slice(1);\n url.push(host);\n }\n // Relative path\n } else if (!/^http(s)?:\\/\\//.test(path)) {\n url.push(parentURL);\n }\n } else {\n if (host) { url.push(host); }\n if (namespace) { url.push(namespace); }\n }\n\n if (path) {\n url.push(path);\n }\n\n return url.join('/');\n },\n\n /**\n Determines the pathname for a given type.\n\n By default, it pluralizes the type's name (for example,\n 'post' becomes 'posts' and 'person' becomes 'people').\n\n ### Pathname customization\n\n For example if you have an object LineItem with an\n endpoint of \"/line_items/\".\n\n ```js\n DS.RESTAdapter.reopen({\n pathForType: function(type) {\n var decamelized = Ember.String.decamelize(type);\n return Ember.String.pluralize(decamelized);\n };\n });\n ```\n\n @method pathForType\n @param {String} type\n @returns {String} path\n **/\n pathForType: function(type) {\n var camelized = Ember.String.camelize(type);\n return Ember.String.pluralize(camelized);\n },\n\n /**\n Takes an ajax response, and returns a relevant error.\n\n Returning a `DS.InvalidError` from this method will cause the\n record to transition into the `invalid` state and make the\n `errors` object available on the record.\n\n ```javascript\n App.ApplicationAdapter = DS.RESTAdapter.extend({\n ajaxError: function(jqXHR) {\n var error = this._super(jqXHR);\n\n if (jqXHR && jqXHR.status === 422) {\n var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)[\"errors\"];\n\n return new DS.InvalidError(jsonErrors);\n } else {\n return error;\n }\n }\n });\n ```\n\n Note: As a correctness optimization, the default implementation of\n the `ajaxError` method strips out the `then` method from jquery's\n ajax response (jqXHR). This is important because the jqXHR's\n `then` method fulfills the promise with itself resulting in a\n circular \"thenable\" chain which may cause problems for some\n promise libraries.\n\n @method ajaxError\n @param {Object} jqXHR\n @return {Object} jqXHR\n */\n ajaxError: function(jqXHR) {\n if (jqXHR) {\n jqXHR.then = null;\n }\n\n return jqXHR;\n },\n\n /**\n Takes a URL, an HTTP method and a hash of data, and makes an\n HTTP request.\n\n When the server responds with a payload, Ember Data will call into `extractSingle`\n or `extractArray` (depending on whether the original query was for one record or\n many records).\n\n By default, `ajax` method has the following behavior:\n\n * It sets the response `dataType` to `\"json\"`\n * If the HTTP method is not `\"GET\"`, it sets the `Content-Type` to be\n `application/json; charset=utf-8`\n * If the HTTP method is not `\"GET\"`, it stringifies the data passed in. The\n data is the serialized record in the case of a save.\n * Registers success and failure handlers.\n\n @method ajax\n @private\n @param {String} url\n @param {String} type The request type GET, POST, PUT, DELETE etc.\n @param {Object} hash\n @return {Promise} promise\n */\n ajax: function(url, type, hash) {\n var adapter = this;\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n hash = adapter.ajaxOptions(url, type, hash);\n\n hash.success = function(json) {\n Ember.run(null, resolve, json);\n };\n\n hash.error = function(jqXHR, textStatus, errorThrown) {\n Ember.run(null, reject, adapter.ajaxError(jqXHR));\n };\n\n Ember.$.ajax(hash);\n }, \"DS: RestAdapter#ajax \" + type + \" to \" + url);\n },\n\n /**\n @method ajaxOptions\n @private\n @param {String} url\n @param {String} type The request type GET, POST, PUT, DELETE etc.\n @param {Object} hash\n @return {Object} hash\n */\n ajaxOptions: function(url, type, hash) {\n hash = hash || {};\n hash.url = url;\n hash.type = type;\n hash.dataType = 'json';\n hash.context = this;\n\n if (hash.data && type !== 'GET') {\n hash.contentType = 'application/json; charset=utf-8';\n hash.data = JSON.stringify(hash.data);\n }\n\n if (this.headers !== undefined) {\n var headers = this.headers;\n hash.beforeSend = function (xhr) {\n forEach.call(Ember.keys(headers), function(key) {\n xhr.setRequestHeader(key, headers[key]);\n });\n };\n }\n\n\n return hash;\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/adapters/rest_adapter");minispade.register('ember-data/core', "(function() {/**\n @module ember-data\n*/\n\n/**\n All Ember Data methods and functions are defined inside of this namespace.\n\n @class DS\n @static\n*/\nvar DS;\nif ('undefined' === typeof DS) {\n /**\n @property VERSION\n @type String\n @default '1.0.0-beta.6'\n @static\n */\n DS = Ember.Namespace.create({\n VERSION: '1.0.0-beta.6'\n });\n\n if ('undefined' !== typeof window) {\n window.DS = DS;\n }\n\n if (Ember.libraries) {\n Ember.libraries.registerCoreLibrary('Ember Data', DS.VERSION);\n }\n}\n\n})();\n//@ sourceURL=ember-data/core");minispade.register('ember-data/ext', "(function() {minispade.require('ember-data/ext/date');\n\n})();\n//@ sourceURL=ember-data/ext");minispade.register('ember-data/ext/date', "(function() {/**\n @module ember-data\n*/\n\n/**\n Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>\n\n © 2011 Colin Snover <http://zetafleet.com>\n\n Released under MIT license.\n\n @class Date\n @namespace Ember\n @static\n*/\nEmber.Date = Ember.Date || {};\n\nvar origParse = Date.parse, numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ];\n\n/**\n @method parse\n @param date\n*/\nEmber.Date.parse = function (date) {\n var timestamp, struct, minutesOffset = 0;\n\n // ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string\n // before falling back to any implementation-specific date parsing, so that’s what we do, even if native\n // implementations could be faster\n // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm\n if ((struct = /^(\\d{4}|[+\\-]\\d{6})(?:-(\\d{2})(?:-(\\d{2}))?)?(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(?:(Z)|([+\\-])(\\d{2})(?::(\\d{2}))?)?)?$/.exec(date))) {\n // avoid NaN timestamps caused by “undefined” values being passed to Date.UTC\n for (var i = 0, k; (k = numericKeys[i]); ++i) {\n struct[k] = +struct[k] || 0;\n }\n\n // allow undefined days and months\n struct[2] = (+struct[2] || 1) - 1;\n struct[3] = +struct[3] || 1;\n\n if (struct[8] !== 'Z' && struct[9] !== undefined) {\n minutesOffset = struct[10] * 60 + struct[11];\n\n if (struct[9] === '+') {\n minutesOffset = 0 - minutesOffset;\n }\n }\n\n timestamp = Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]);\n }\n else {\n timestamp = origParse ? origParse(date) : NaN;\n }\n\n return timestamp;\n};\n\nif (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Date) {\n Date.parse = Ember.Date.parse;\n}\n\n})();\n//@ sourceURL=ember-data/ext/date");minispade.register('ember-data/initializers', "(function() {minispade.require(\"ember-data/system/container_proxy\");\nminispade.require(\"ember-data/serializers/json_serializer\");\nminispade.require(\"ember-data/system/debug/debug_adapter\");\nminispade.require(\"ember-data/transforms/index\");\n\n/**\n @module ember-data\n*/\n\nvar set = Ember.set;\n\n/*\n This code registers an injection for Ember.Application.\n\n If an Ember.js developer defines a subclass of DS.Store on their application,\n this code will automatically instantiate it and make it available on the\n router.\n\n Additionally, after an application's controllers have been injected, they will\n each have the store made available to them.\n\n For example, imagine an Ember.js application with the following classes:\n\n App.Store = DS.Store.extend({\n adapter: 'custom'\n });\n\n App.PostsController = Ember.ArrayController.extend({\n // ...\n });\n\n When the application is initialized, `App.Store` will automatically be\n instantiated, and the instance of `App.PostsController` will have its `store`\n property set to that instance.\n\n Note that this code will only be run if the `ember-application` package is\n loaded. If Ember Data is being used in an environment other than a\n typical application (e.g., node.js where only `ember-runtime` is available),\n this code will be ignored.\n*/\n\nEmber.onLoad('Ember.Application', function(Application) {\n Application.initializer({\n name: \"store\",\n\n initialize: function(container, application) {\n application.register('store:main', application.Store || DS.Store);\n\n // allow older names to be looked up\n\n var proxy = new DS.ContainerProxy(container);\n proxy.registerDeprecations([\n {deprecated: 'serializer:_default', valid: 'serializer:-default'},\n {deprecated: 'serializer:_rest', valid: 'serializer:-rest'},\n {deprecated: 'adapter:_rest', valid: 'adapter:-rest'}\n ]);\n\n // new go forward paths\n application.register('serializer:-default', DS.JSONSerializer);\n application.register('serializer:-rest', DS.RESTSerializer);\n application.register('adapter:-rest', DS.RESTAdapter);\n\n // Eagerly generate the store so defaultStore is populated.\n // TODO: Do this in a finisher hook\n container.lookup('store:main');\n }\n });\n\n Application.initializer({\n name: \"transforms\",\n before: \"store\",\n\n initialize: function(container, application) {\n application.register('transform:boolean', DS.BooleanTransform);\n application.register('transform:date', DS.DateTransform);\n application.register('transform:number', DS.NumberTransform);\n application.register('transform:string', DS.StringTransform);\n }\n });\n\n Application.initializer({\n name: \"data-adapter\",\n before: \"store\",\n\n initialize: function(container, application) {\n application.register('data-adapter:main', DS.DebugAdapter);\n }\n });\n\n Application.initializer({\n name: \"injectStore\",\n before: \"store\",\n\n initialize: function(container, application) {\n application.inject('controller', 'store', 'store:main');\n application.inject('route', 'store', 'store:main');\n application.inject('serializer', 'store', 'store:main');\n application.inject('data-adapter', 'store', 'store:main');\n }\n });\n\n});\n\n})();\n//@ sourceURL=ember-data/initializers");minispade.register('ember-data', "(function() {/**\n Ember Data\n\n @module ember-data\n @main ember-data\n*/\nminispade.require(\"ember-data/core\");\nminispade.require(\"ember-data/initializers\");\nminispade.require(\"ember-data/ext\");\nminispade.require(\"ember-data/system/store\");\nminispade.require(\"ember-data/system/model\");\nminispade.require(\"ember-data/system/changes\");\nminispade.require(\"ember-data/system/relationships\");\nminispade.require(\"ember-data/system/record_arrays\");\nminispade.require(\"ember-data/system/record_array_manager\");\nminispade.require(\"ember-data/system/adapter\");\nminispade.require(\"ember-data/adapters\");\nminispade.require(\"ember-data/system/debug\");\n\n})();\n//@ sourceURL=ember-data");minispade.register('ember-data/serializers/json_serializer', "(function() {var get = Ember.get, set = Ember.set, isNone = Ember.isNone;\n\n// Simple dispatcher to support overriding the aliased\n// method in subclasses.\nfunction aliasMethod(methodName) {\n return function() {\n return this[methodName].apply(this, arguments);\n };\n}\n\n/**\n In Ember Data a Serializer is used to serialize and deserialize\n records when they are transferred in and out of an external source.\n This process involves normalizing property names, transforming\n attribute values and serializing relationships.\n\n For maximum performance Ember Data recommends you use the\n [RESTSerializer](DS.RESTSerializer.html) or one of its subclasses.\n\n `JSONSerializer` is useful for simpler or legacy backends that may\n not support the http://jsonapi.org/ spec.\n\n @class JSONSerializer\n @namespace DS\n*/\nDS.JSONSerializer = Ember.Object.extend({\n /**\n The primaryKey is used when serializing and deserializing\n data. Ember Data always uses the `id` property to store the id of\n the record. The external source may not always follow this\n convention. In these cases it is useful to override the\n primaryKey property to match the primaryKey of your external\n store.\n\n Example\n\n ```javascript\n App.ApplicationSerializer = DS.JSONSerializer.extend({\n primaryKey: '_id'\n });\n ```\n\n @property primaryKey\n @type {String}\n @default 'id'\n */\n primaryKey: 'id',\n\n /**\n Given a subclass of `DS.Model` and a JSON object this method will\n iterate through each attribute of the `DS.Model` and invoke the\n `DS.Transform#deserialize` method on the matching property of the\n JSON object. This method is typically called after the\n serializer's `normalize` method.\n\n @method applyTransforms\n @private\n @param {subclass of DS.Model} type\n @param {Object} data The data to transform\n @return {Object} data The transformed data object\n */\n applyTransforms: function(type, data) {\n type.eachTransformedAttribute(function(key, type) {\n var transform = this.transformFor(type);\n data[key] = transform.deserialize(data[key]);\n }, this);\n\n return data;\n },\n\n /**\n Normalizes a part of the JSON payload returned by\n the server. You should override this method, munge the hash\n and call super if you have generic normalization to do.\n\n It takes the type of the record that is being normalized\n (as a DS.Model class), the property where the hash was\n originally found, and the hash to normalize.\n\n You can use this method, for example, to normalize underscored keys to camelized\n or other general-purpose normalizations.\n\n Example\n\n ```javascript\n App.ApplicationSerializer = DS.JSONSerializer.extend({\n normalize: function(type, hash) {\n var fields = Ember.get(type, 'fields');\n fields.forEach(function(field) {\n var payloadField = Ember.String.underscore(field);\n if (field === payloadField) { return; }\n\n hash[field] = hash[payloadField];\n delete hash[payloadField];\n });\n return this._super.apply(this, arguments);\n }\n });\n ```\n\n @method normalize\n @param {subclass of DS.Model} type\n @param {Object} hash\n @return {Object}\n */\n normalize: function(type, hash) {\n if (!hash) { return hash; }\n\n this.applyTransforms(type, hash);\n return hash;\n },\n\n // SERIALIZE\n /**\n Called when a record is saved in order to convert the\n record into JSON.\n\n By default, it creates a JSON object with a key for\n each attribute and belongsTo relationship.\n\n For example, consider this model:\n\n ```javascript\n App.Comment = DS.Model.extend({\n title: DS.attr(),\n body: DS.attr(),\n\n author: DS.belongsTo('user')\n });\n ```\n\n The default serialization would create a JSON object like:\n\n ```javascript\n {\n \"title\": \"Rails is unagi\",\n \"body\": \"Rails? Omakase? O_O\",\n \"author\": 12\n }\n ```\n\n By default, attributes are passed through as-is, unless\n you specified an attribute type (`DS.attr('date')`). If\n you specify a transform, the JavaScript value will be\n serialized when inserted into the JSON hash.\n\n By default, belongs-to relationships are converted into\n IDs when inserted into the JSON hash.\n\n ## IDs\n\n `serialize` takes an options hash with a single option:\n `includeId`. If this option is `true`, `serialize` will,\n by default include the ID in the JSON object it builds.\n\n The adapter passes in `includeId: true` when serializing\n a record for `createRecord`, but not for `updateRecord`.\n\n ## Customization\n\n Your server may expect a different JSON format than the\n built-in serialization format.\n\n In that case, you can implement `serialize` yourself and\n return a JSON hash of your choosing.\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n serialize: function(post, options) {\n var json = {\n POST_TTL: post.get('title'),\n POST_BDY: post.get('body'),\n POST_CMS: post.get('comments').mapProperty('id')\n }\n\n if (options.includeId) {\n json.POST_ID_ = post.get('id');\n }\n\n return json;\n }\n });\n ```\n\n ## Customizing an App-Wide Serializer\n\n If you want to define a serializer for your entire\n application, you'll probably want to use `eachAttribute`\n and `eachRelationship` on the record.\n\n ```javascript\n App.ApplicationSerializer = DS.JSONSerializer.extend({\n serialize: function(record, options) {\n var json = {};\n\n record.eachAttribute(function(name) {\n json[serverAttributeName(name)] = record.get(name);\n })\n\n record.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'hasMany') {\n json[serverHasManyName(name)] = record.get(name).mapBy('id');\n }\n });\n\n if (options.includeId) {\n json.ID_ = record.get('id');\n }\n\n return json;\n }\n });\n\n function serverAttributeName(attribute) {\n return attribute.underscore().toUpperCase();\n }\n\n function serverHasManyName(name) {\n return serverAttributeName(name.singularize()) + \"_IDS\";\n }\n ```\n\n This serializer will generate JSON that looks like this:\n\n ```javascript\n {\n \"TITLE\": \"Rails is omakase\",\n \"BODY\": \"Yep. Omakase.\",\n \"COMMENT_IDS\": [ 1, 2, 3 ]\n }\n ```\n\n ## Tweaking the Default JSON\n\n If you just want to do some small tweaks on the default JSON,\n you can call super first and make the tweaks on the returned\n JSON.\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n serialize: function(record, options) {\n var json = this._super.apply(this, arguments);\n\n json.subject = json.title;\n delete json.title;\n\n return json;\n }\n });\n ```\n\n @method serialize\n @param {subclass of DS.Model} record\n @param {Object} options\n @return {Object} json\n */\n serialize: function(record, options) {\n var json = {};\n\n if (options && options.includeId) {\n var id = get(record, 'id');\n\n if (id) {\n json[get(this, 'primaryKey')] = id;\n }\n }\n\n record.eachAttribute(function(key, attribute) {\n this.serializeAttribute(record, json, key, attribute);\n }, this);\n\n record.eachRelationship(function(key, relationship) {\n if (relationship.kind === 'belongsTo') {\n this.serializeBelongsTo(record, json, relationship);\n } else if (relationship.kind === 'hasMany') {\n this.serializeHasMany(record, json, relationship);\n }\n }, this);\n\n return json;\n },\n\n /**\n `serializeAttribute` can be used to customize how `DS.attr`\n properties are serialized\n\n For example if you wanted to ensure all you attributes were always\n serialized as properties on an `attributes` object you could\n write:\n\n ```javascript\n App.ApplicationSerializer = DS.JSONSerializer.extend({\n serializeAttribute: function(record, json, key, attributes) {\n json.attributes = json.attributes || {};\n this._super(record, json.attributes, key, attributes);\n }\n });\n ```\n\n @method serializeAttribute\n @param {DS.Model} record\n @param {Object} json\n @param {String} key\n @param {Object} attribute\n */\n serializeAttribute: function(record, json, key, attribute) {\n var attrs = get(this, 'attrs');\n var value = get(record, key), type = attribute.type;\n\n if (type) {\n var transform = this.transformFor(type);\n value = transform.serialize(value);\n }\n\n // if provided, use the mapping provided by `attrs` in\n // the serializer\n key = attrs && attrs[key] || (this.keyForAttribute ? this.keyForAttribute(key) : key);\n\n json[key] = value;\n },\n\n /**\n `serializeBelongsTo` can be used to customize how `DS.belongsTo`\n properties are serialized.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n serializeBelongsTo: function(record, json, relationship) {\n var key = relationship.key;\n\n var belongsTo = get(record, key);\n\n key = this.keyForRelationship ? this.keyForRelationship(key, \"belongsTo\") : key;\n\n json[key] = Ember.isNone(belongsTo) ? belongsTo : belongsTo.toJSON();\n }\n });\n ```\n\n @method serializeBelongsTo\n @param {DS.Model} record\n @param {Object} json\n @param {Object} relationship\n */\n serializeBelongsTo: function(record, json, relationship) {\n var key = relationship.key;\n\n var belongsTo = get(record, key);\n\n key = this.keyForRelationship ? this.keyForRelationship(key, \"belongsTo\") : key;\n\n if (isNone(belongsTo)) {\n json[key] = belongsTo;\n } else {\n json[key] = get(belongsTo, 'id');\n }\n\n if (relationship.options.polymorphic) {\n this.serializePolymorphicType(record, json, relationship);\n }\n },\n\n /**\n `serializeHasMany` can be used to customize how `DS.hasMany`\n properties are serialized.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n serializeHasMany: function(record, json, relationship) {\n var key = relationship.key;\n if (key === 'comments') {\n return;\n } else {\n this._super.apply(this, arguments);\n }\n }\n });\n ```\n\n @method serializeHasMany\n @param {DS.Model} record\n @param {Object} json\n @param {Object} relationship\n */\n serializeHasMany: function(record, json, relationship) {\n var key = relationship.key;\n\n var relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship);\n\n if (relationshipType === 'manyToNone' || relationshipType === 'manyToMany') {\n json[key] = get(record, key).mapBy('id');\n // TODO support for polymorphic manyToNone and manyToMany relationships\n }\n },\n\n /**\n You can use this method to customize how polymorphic objects are\n serialized. Objects are considered to be polymorphic if\n `{polymorphic: true}` is pass as the second argument to the\n `DS.belongsTo` function.\n\n Example\n\n ```javascript\n App.CommentSerializer = DS.JSONSerializer.extend({\n serializePolymorphicType: function(record, json, relationship) {\n var key = relationship.key,\n belongsTo = get(record, key);\n key = this.keyForAttribute ? this.keyForAttribute(key) : key;\n json[key + \"_type\"] = belongsTo.constructor.typeKey;\n }\n });\n ```\n\n @method serializePolymorphicType\n @param {DS.Model} record\n @param {Object} json\n @param {Object} relationship\n */\n serializePolymorphicType: Ember.K,\n\n // EXTRACT\n\n /**\n The `extract` method is used to deserialize payload data from the\n server. By default the `JSONSerializer` does not push the records\n into the store. However records that subclass `JSONSerializer`\n such as the `RESTSerializer` may push records into the store as\n part of the extract call.\n\n This method delegates to a more specific extract method based on\n the `requestType`.\n\n Example\n\n ```javascript\n var get = Ember.get;\n socket.on('message', function(message) {\n var modelName = message.model;\n var data = message.data;\n var type = store.modelFor(modelName);\n var serializer = store.serializerFor(type.typeKey);\n var record = serializer.extract(store, type, data, get(data, 'id'), 'single');\n store.push(modelName, record);\n });\n ```\n\n @method extract\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @param {String or Number} id\n @param {String} requestType\n @return {Object} json The deserialized payload\n */\n extract: function(store, type, payload, id, requestType) {\n this.extractMeta(store, type, payload);\n\n var specificExtract = \"extract\" + requestType.charAt(0).toUpperCase() + requestType.substr(1);\n return this[specificExtract](store, type, payload, id, requestType);\n },\n\n /**\n `extractFindAll` is a hook into the extract method used when a\n call is made to `DS.Store#findAll`. By default this method is an\n alias for [extractArray](#method_extractArray).\n\n @method extractFindAll\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractFindAll: aliasMethod('extractArray'),\n /**\n `extractFindQuery` is a hook into the extract method used when a\n call is made to `DS.Store#findQuery`. By default this method is an\n alias for [extractArray](#method_extractArray).\n\n @method extractFindQuery\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractFindQuery: aliasMethod('extractArray'),\n /**\n `extractFindMany` is a hook into the extract method used when a\n call is made to `DS.Store#findMany`. By default this method is\n alias for [extractArray](#method_extractArray).\n\n @method extractFindMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractFindMany: aliasMethod('extractArray'),\n /**\n `extractFindHasMany` is a hook into the extract method used when a\n call is made to `DS.Store#findHasMany`. By default this method is\n alias for [extractArray](#method_extractArray).\n\n @method extractFindHasMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractFindHasMany: aliasMethod('extractArray'),\n\n /**\n `extractCreateRecord` is a hook into the extract method used when a\n call is made to `DS.Store#createRecord`. By default this method is\n alias for [extractSave](#method_extractSave).\n\n @method extractCreateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractCreateRecord: aliasMethod('extractSave'),\n /**\n `extractUpdateRecord` is a hook into the extract method used when\n a call is made to `DS.Store#update`. By default this method is alias\n for [extractSave](#method_extractSave).\n\n @method extractUpdateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractUpdateRecord: aliasMethod('extractSave'),\n /**\n `extractDeleteRecord` is a hook into the extract method used when\n a call is made to `DS.Store#deleteRecord`. By default this method is\n alias for [extractSave](#method_extractSave).\n\n @method extractDeleteRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractDeleteRecord: aliasMethod('extractSave'),\n\n /**\n `extractFind` is a hook into the extract method used when\n a call is made to `DS.Store#find`. By default this method is\n alias for [extractSingle](#method_extractSingle).\n\n @method extractFind\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractFind: aliasMethod('extractSingle'),\n /**\n `extractFindBelongsTo` is a hook into the extract method used when\n a call is made to `DS.Store#findBelongsTo`. By default this method is\n alias for [extractSingle](#method_extractSingle).\n\n @method extractFindBelongsTo\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractFindBelongsTo: aliasMethod('extractSingle'),\n /**\n `extractSave` is a hook into the extract method used when a call\n is made to `DS.Model#save`. By default this method is alias\n for [extractSingle](#method_extractSingle).\n\n @method extractSave\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractSave: aliasMethod('extractSingle'),\n\n /**\n `extractSingle` is used to deserialize a single record returned\n from the adapter.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n extractSingle: function(store, type, payload) {\n payload.comments = payload._embedded.comment;\n delete payload._embedded;\n\n return this._super(store, type, payload);\n },\n });\n ```\n\n @method extractSingle\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Object} json The deserialized payload\n */\n extractSingle: function(store, type, payload) {\n return this.normalize(type, payload);\n },\n\n /**\n `extractArray` is used to deserialize an array of records\n returned from the adapter.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n extractArray: function(store, type, payload) {\n return payload.map(function(json) {\n return this.extractSingle(json);\n }, this);\n }\n });\n ```\n\n @method extractArray\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @return {Array} array An array of deserialized objects\n */\n extractArray: function(store, type, payload) {\n return this.normalize(type, payload);\n },\n\n /**\n `extractMeta` is used to deserialize any meta information in the\n adapter payload. By default Ember Data expects meta information to\n be located on the `meta` property of the payload object.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n extractMeta: function(store, type, payload) {\n if (payload && payload._pagination) {\n store.metaForType(type, payload._pagination);\n delete payload._pagination;\n }\n }\n });\n ```\n\n @method extractMeta\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n */\n extractMeta: function(store, type, payload) {\n if (payload && payload.meta) {\n store.metaForType(type, payload.meta);\n delete payload.meta;\n }\n },\n\n /**\n `keyForAttribute` can be used to define rules for how to convert an\n attribute name in your model to a key in your JSON.\n\n Example\n\n ```javascript\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n keyForAttribute: function(attr) {\n return Ember.String.underscore(attr).toUpperCase();\n }\n });\n ```\n\n @method keyForAttribute\n @param {String} key\n @return {String} normalized key\n */\n\n\n /**\n `keyForRelationship` can be used to define a custom key when\n serializing relationship properties. By default `JSONSerializer`\n does not provide an implementation of this method.\n\n Example\n\n ```javascript\n App.PostSerializer = DS.JSONSerializer.extend({\n keyForRelationship: function(key, relationship) {\n return 'rel_' + Ember.String.underscore(key);\n }\n });\n ```\n\n @method keyForRelationship\n @param {String} key\n @param {String} relationship type\n @return {String} normalized key\n */\n\n // HELPERS\n\n /**\n @method transformFor\n @private\n @param {String} attributeType\n @param {Boolean} skipAssertion\n @return {DS.Transform} transform\n */\n transformFor: function(attributeType, skipAssertion) {\n var transform = this.container.lookup('transform:' + attributeType);\n Ember.assert(\"Unable to find transform for '\" + attributeType + \"'\", skipAssertion || !!transform);\n return transform;\n }\n});\n\n})();\n//@ sourceURL=ember-data/serializers/json_serializer");minispade.register('ember-data/serializers/rest_serializer', "(function() {minispade.require('ember-data/serializers/json_serializer');\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar forEach = Ember.ArrayPolyfills.forEach;\nvar map = Ember.ArrayPolyfills.map;\n\nfunction coerceId(id) {\n return id == null ? null : id+'';\n}\n\n/**\n Normally, applications will use the `RESTSerializer` by implementing\n the `normalize` method and individual normalizations under\n `normalizeHash`.\n\n This allows you to do whatever kind of munging you need, and is\n especially useful if your server is inconsistent and you need to\n do munging differently for many different kinds of responses.\n\n See the `normalize` documentation for more information.\n\n ## Across the Board Normalization\n\n There are also a number of hooks that you might find useful to defined\n across-the-board rules for your payload. These rules will be useful\n if your server is consistent, or if you're building an adapter for\n an infrastructure service, like Parse, and want to encode service\n conventions.\n\n For example, if all of your keys are underscored and all-caps, but\n otherwise consistent with the names you use in your models, you\n can implement across-the-board rules for how to convert an attribute\n name in your model to a key in your JSON.\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n keyForAttribute: function(attr) {\n return Ember.String.underscore(attr).toUpperCase();\n }\n });\n ```\n\n You can also implement `keyForRelationship`, which takes the name\n of the relationship as the first parameter, and the kind of\n relationship (`hasMany` or `belongsTo`) as the second parameter.\n\n @class RESTSerializer\n @namespace DS\n @extends DS.JSONSerializer\n*/\nDS.RESTSerializer = DS.JSONSerializer.extend({\n /**\n If you want to do normalizations specific to some part of the payload, you\n can specify those under `normalizeHash`.\n\n For example, given the following json where the the `IDs` under\n `\"comments\"` are provided as `_id` instead of `id`.\n\n ```javascript\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"comments\": [ 1, 2 ]\n },\n \"comments\": [{\n \"_id\": 1,\n \"body\": \"FIRST\"\n }, {\n \"_id\": 2,\n \"body\": \"Rails is unagi\"\n }]\n }\n ```\n\n You use `normalizeHash` to normalize just the comments:\n\n ```javascript\n App.PostSerializer = DS.RESTSerializer.extend({\n normalizeHash: {\n comments: function(hash) {\n hash.id = hash._id;\n delete hash._id;\n return hash;\n }\n }\n });\n ```\n\n The key under `normalizeHash` is usually just the original key\n that was in the original payload. However, key names will be\n impacted by any modifications done in the `normalizePayload`\n method. The `DS.RESTSerializer`'s default implementation makes no\n changes to the payload keys.\n\n @property normalizeHash\n @type {Object}\n @default undefined\n */\n\n /**\n Normalizes a part of the JSON payload returned by\n the server. You should override this method, munge the hash\n and call super if you have generic normalization to do.\n\n It takes the type of the record that is being normalized\n (as a DS.Model class), the property where the hash was\n originally found, and the hash to normalize.\n\n For example, if you have a payload that looks like this:\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"comments\": [ 1, 2 ]\n },\n \"comments\": [{\n \"id\": 1,\n \"body\": \"FIRST\"\n }, {\n \"id\": 2,\n \"body\": \"Rails is unagi\"\n }]\n }\n ```\n\n The `normalize` method will be called three times:\n\n * With `App.Post`, `\"posts\"` and `{ id: 1, title: \"Rails is omakase\", ... }`\n * With `App.Comment`, `\"comments\"` and `{ id: 1, body: \"FIRST\" }`\n * With `App.Comment`, `\"comments\"` and `{ id: 2, body: \"Rails is unagi\" }`\n\n You can use this method, for example, to normalize underscored keys to camelized\n or other general-purpose normalizations.\n\n If you want to do normalizations specific to some part of the payload, you\n can specify those under `normalizeHash`.\n\n For example, if the `IDs` under `\"comments\"` are provided as `_id` instead of\n `id`, you can specify how to normalize just the comments:\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n normalizeHash: {\n comments: function(hash) {\n hash.id = hash._id;\n delete hash._id;\n return hash;\n }\n }\n });\n ```\n\n The key under `normalizeHash` is just the original key that was in the original\n payload.\n\n @method normalize\n @param {subclass of DS.Model} type\n @param {Object} hash\n @param {String} prop\n @returns {Object}\n */\n normalize: function(type, hash, prop) {\n this.normalizeId(hash);\n this.normalizeAttributes(type, hash);\n this.normalizeRelationships(type, hash);\n\n this.normalizeUsingDeclaredMapping(type, hash);\n\n if (this.normalizeHash && this.normalizeHash[prop]) {\n this.normalizeHash[prop](hash);\n }\n\n return this._super(type, hash, prop);\n },\n\n /**\n You can use this method to normalize all payloads, regardless of whether they\n represent single records or an array.\n\n For example, you might want to remove some extraneous data from the payload:\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n normalizePayload: function(type, payload) {\n delete payload.version;\n delete payload.status;\n return payload;\n }\n });\n ```\n\n @method normalizePayload\n @param {subclass of DS.Model} type\n @param {Object} hash\n @returns {Object} the normalized payload\n */\n normalizePayload: function(type, payload) {\n return payload;\n },\n\n /**\n @method normalizeId\n @private\n */\n normalizeId: function(hash) {\n var primaryKey = get(this, 'primaryKey');\n\n if (primaryKey === 'id') { return; }\n\n hash.id = hash[primaryKey];\n delete hash[primaryKey];\n },\n\n /**\n @method normalizeUsingDeclaredMapping\n @private\n */\n normalizeUsingDeclaredMapping: function(type, hash) {\n var attrs = get(this, 'attrs'), payloadKey, key;\n\n if (attrs) {\n for (key in attrs) {\n payloadKey = attrs[key];\n if (payloadKey && payloadKey.key) {\n payloadKey = payloadKey.key;\n }\n if (typeof payloadKey === 'string') {\n hash[key] = hash[payloadKey];\n delete hash[payloadKey];\n }\n }\n }\n },\n\n /**\n @method normalizeAttributes\n @private\n */\n normalizeAttributes: function(type, hash) {\n var payloadKey, key;\n\n if (this.keyForAttribute) {\n type.eachAttribute(function(key) {\n payloadKey = this.keyForAttribute(key);\n if (key === payloadKey) { return; }\n\n hash[key] = hash[payloadKey];\n delete hash[payloadKey];\n }, this);\n }\n },\n\n /**\n @method normalizeRelationships\n @private\n */\n normalizeRelationships: function(type, hash) {\n var payloadKey, key;\n\n if (this.keyForRelationship) {\n type.eachRelationship(function(key, relationship) {\n payloadKey = this.keyForRelationship(key, relationship.kind);\n if (key === payloadKey) { return; }\n\n hash[key] = hash[payloadKey];\n delete hash[payloadKey];\n }, this);\n }\n },\n\n /**\n Called when the server has returned a payload representing\n a single record, such as in response to a `find` or `save`.\n\n It is your opportunity to clean up the server's response into the normalized\n form expected by Ember Data.\n\n If you want, you can just restructure the top-level of your payload, and\n do more fine-grained normalization in the `normalize` method.\n\n For example, if you have a payload like this in response to a request for\n post 1:\n\n ```js\n {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n\n \"_embedded\": {\n \"comment\": [{\n \"_id\": 1,\n \"comment_title\": \"FIRST\"\n }, {\n \"_id\": 2,\n \"comment_title\": \"Rails is unagi\"\n }]\n }\n }\n ```\n\n You could implement a serializer that looks like this to get your payload\n into shape:\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n // First, restructure the top-level so it's organized by type\n extractSingle: function(store, type, payload, id, requestType) {\n var comments = payload._embedded.comment;\n delete payload._embedded;\n\n payload = { comments: comments, post: payload };\n return this._super(store, type, payload, id, requestType);\n },\n\n normalizeHash: {\n // Next, normalize individual comments, which (after `extract`)\n // are now located under `comments`\n comments: function(hash) {\n hash.id = hash._id;\n hash.title = hash.comment_title;\n delete hash._id;\n delete hash.comment_title;\n return hash;\n }\n }\n })\n ```\n\n When you call super from your own implementation of `extractSingle`, the\n built-in implementation will find the primary record in your normalized\n payload and push the remaining records into the store.\n\n The primary record is the single hash found under `post` or the first\n element of the `posts` array.\n\n The primary record has special meaning when the record is being created\n for the first time or updated (`createRecord` or `updateRecord`). In\n particular, it will update the properties of the record that was saved.\n\n @method extractSingle\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @param {String} id\n @param {'find'|'createRecord'|'updateRecord'|'deleteRecord'} requestType\n @returns {Object} the primary response to the original request\n */\n extractSingle: function(store, primaryType, payload, recordId, requestType) {\n payload = this.normalizePayload(primaryType, payload);\n\n var primaryTypeName = primaryType.typeKey,\n primaryRecord;\n\n for (var prop in payload) {\n var typeName = this.typeForRoot(prop),\n type = store.modelFor(typeName),\n isPrimary = type.typeKey === primaryTypeName;\n\n // legacy support for singular resources\n if (isPrimary && Ember.typeOf(payload[prop]) !== \"array\" ) {\n primaryRecord = this.normalize(primaryType, payload[prop], prop);\n continue;\n }\n\n /*jshint loopfunc:true*/\n forEach.call(payload[prop], function(hash) {\n var typeName = this.typeForRoot(prop),\n type = store.modelFor(typeName),\n typeSerializer = store.serializerFor(type);\n\n hash = typeSerializer.normalize(type, hash, prop);\n\n var isFirstCreatedRecord = isPrimary && !recordId && !primaryRecord,\n isUpdatedRecord = isPrimary && coerceId(hash.id) === recordId;\n\n // find the primary record.\n //\n // It's either:\n // * the record with the same ID as the original request\n // * in the case of a newly created record that didn't have an ID, the first\n // record in the Array\n if (isFirstCreatedRecord || isUpdatedRecord) {\n primaryRecord = hash;\n } else {\n store.push(typeName, hash);\n }\n }, this);\n }\n\n return primaryRecord;\n },\n\n /**\n Called when the server has returned a payload representing\n multiple records, such as in response to a `findAll` or `findQuery`.\n\n It is your opportunity to clean up the server's response into the normalized\n form expected by Ember Data.\n\n If you want, you can just restructure the top-level of your payload, and\n do more fine-grained normalization in the `normalize` method.\n\n For example, if you have a payload like this in response to a request for\n all posts:\n\n ```js\n {\n \"_embedded\": {\n \"post\": [{\n \"id\": 1,\n \"title\": \"Rails is omakase\"\n }, {\n \"id\": 2,\n \"title\": \"The Parley Letter\"\n }],\n \"comment\": [{\n \"_id\": 1,\n \"comment_title\": \"Rails is unagi\"\n \"post_id\": 1\n }, {\n \"_id\": 2,\n \"comment_title\": \"Don't tread on me\",\n \"post_id\": 2\n }]\n }\n }\n ```\n\n You could implement a serializer that looks like this to get your payload\n into shape:\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n // First, restructure the top-level so it's organized by type\n // and the comments are listed under a post's `comments` key.\n extractArray: function(store, type, payload, id, requestType) {\n var posts = payload._embedded.post;\n var comments = [];\n var postCache = {};\n\n posts.forEach(function(post) {\n post.comments = [];\n postCache[post.id] = post;\n });\n\n payload._embedded.comment.forEach(function(comment) {\n comments.push(comment);\n postCache[comment.post_id].comments.push(comment);\n delete comment.post_id;\n }\n\n payload = { comments: comments, posts: payload };\n\n return this._super(store, type, payload, id, requestType);\n },\n\n normalizeHash: {\n // Next, normalize individual comments, which (after `extract`)\n // are now located under `comments`\n comments: function(hash) {\n hash.id = hash._id;\n hash.title = hash.comment_title;\n delete hash._id;\n delete hash.comment_title;\n return hash;\n }\n }\n })\n ```\n\n When you call super from your own implementation of `extractArray`, the\n built-in implementation will find the primary array in your normalized\n payload and push the remaining records into the store.\n\n The primary array is the array found under `posts`.\n\n The primary record has special meaning when responding to `findQuery`\n or `findHasMany`. In particular, the primary array will become the\n list of records in the record array that kicked off the request.\n\n If your primary array contains secondary (embedded) records of the same type,\n you cannot place these into the primary array `posts`. Instead, place the\n secondary items into an underscore prefixed property `_posts`, which will\n push these items into the store and will not affect the resulting query.\n\n @method extractArray\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} payload\n @param {'findAll'|'findMany'|'findHasMany'|'findQuery'} requestType\n @returns {Array} The primary array that was returned in response\n to the original query.\n */\n extractArray: function(store, primaryType, payload) {\n payload = this.normalizePayload(primaryType, payload);\n\n var primaryTypeName = primaryType.typeKey,\n primaryArray;\n\n for (var prop in payload) {\n var typeKey = prop,\n forcedSecondary = false;\n\n if (prop.charAt(0) === '_') {\n forcedSecondary = true;\n typeKey = prop.substr(1);\n }\n\n var typeName = this.typeForRoot(typeKey),\n type = store.modelFor(typeName),\n typeSerializer = store.serializerFor(type),\n isPrimary = (!forcedSecondary && (type.typeKey === primaryTypeName));\n\n /*jshint loopfunc:true*/\n var normalizedArray = map.call(payload[prop], function(hash) {\n return typeSerializer.normalize(type, hash, prop);\n }, this);\n\n if (isPrimary) {\n primaryArray = normalizedArray;\n } else {\n store.pushMany(typeName, normalizedArray);\n }\n }\n\n return primaryArray;\n },\n\n /**\n This method allows you to push a payload containing top-level\n collections of records organized per type.\n\n ```js\n {\n \"posts\": [{\n \"id\": \"1\",\n \"title\": \"Rails is omakase\",\n \"author\", \"1\",\n \"comments\": [ \"1\" ]\n }],\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"FIRST\"\n }],\n \"users\": [{\n \"id\": \"1\",\n \"name\": \"@d2h\"\n }]\n }\n ```\n\n It will first normalize the payload, so you can use this to push\n in data streaming in from your server structured the same way\n that fetches and saves are structured.\n\n @method pushPayload\n @param {DS.Store} store\n @param {Object} payload\n */\n pushPayload: function(store, payload) {\n payload = this.normalizePayload(null, payload);\n\n for (var prop in payload) {\n var typeName = this.typeForRoot(prop),\n type = store.modelFor(typeName);\n\n /*jshint loopfunc:true*/\n var normalizedArray = map.call(Ember.makeArray(payload[prop]), function(hash) {\n return this.normalize(type, hash, prop);\n }, this);\n\n store.pushMany(typeName, normalizedArray);\n }\n },\n\n /**\n You can use this method to normalize the JSON root keys returned\n into the model type expected by your store.\n\n For example, your server may return underscored root keys rather than\n the expected camelcased versions.\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n typeForRoot: function(root) {\n var camelized = Ember.String.camelize(root);\n return Ember.String.singularize(camelized);\n }\n });\n ```\n\n @method typeForRoot\n @param {String} root\n @returns {String} the model's typeKey\n */\n typeForRoot: function(root) {\n return Ember.String.singularize(root);\n },\n\n // SERIALIZE\n\n /**\n Called when a record is saved in order to convert the\n record into JSON.\n\n By default, it creates a JSON object with a key for\n each attribute and belongsTo relationship.\n\n For example, consider this model:\n\n ```js\n App.Comment = DS.Model.extend({\n title: DS.attr(),\n body: DS.attr(),\n\n author: DS.belongsTo('user')\n });\n ```\n\n The default serialization would create a JSON object like:\n\n ```js\n {\n \"title\": \"Rails is unagi\",\n \"body\": \"Rails? Omakase? O_O\",\n \"author\": 12\n }\n ```\n\n By default, attributes are passed through as-is, unless\n you specified an attribute type (`DS.attr('date')`). If\n you specify a transform, the JavaScript value will be\n serialized when inserted into the JSON hash.\n\n By default, belongs-to relationships are converted into\n IDs when inserted into the JSON hash.\n\n ## IDs\n\n `serialize` takes an options hash with a single option:\n `includeId`. If this option is `true`, `serialize` will,\n by default include the ID in the JSON object it builds.\n\n The adapter passes in `includeId: true` when serializing\n a record for `createRecord`, but not for `updateRecord`.\n\n ## Customization\n\n Your server may expect a different JSON format than the\n built-in serialization format.\n\n In that case, you can implement `serialize` yourself and\n return a JSON hash of your choosing.\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n serialize: function(post, options) {\n var json = {\n POST_TTL: post.get('title'),\n POST_BDY: post.get('body'),\n POST_CMS: post.get('comments').mapProperty('id')\n }\n\n if (options.includeId) {\n json.POST_ID_ = post.get('id');\n }\n\n return json;\n }\n });\n ```\n\n ## Customizing an App-Wide Serializer\n\n If you want to define a serializer for your entire\n application, you'll probably want to use `eachAttribute`\n and `eachRelationship` on the record.\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n serialize: function(record, options) {\n var json = {};\n\n record.eachAttribute(function(name) {\n json[serverAttributeName(name)] = record.get(name);\n })\n\n record.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'hasMany') {\n json[serverHasManyName(name)] = record.get(name).mapBy('id');\n }\n });\n\n if (options.includeId) {\n json.ID_ = record.get('id');\n }\n\n return json;\n }\n });\n\n function serverAttributeName(attribute) {\n return attribute.underscore().toUpperCase();\n }\n\n function serverHasManyName(name) {\n return serverAttributeName(name.singularize()) + \"_IDS\";\n }\n ```\n\n This serializer will generate JSON that looks like this:\n\n ```js\n {\n \"TITLE\": \"Rails is omakase\",\n \"BODY\": \"Yep. Omakase.\",\n \"COMMENT_IDS\": [ 1, 2, 3 ]\n }\n ```\n\n ## Tweaking the Default JSON\n\n If you just want to do some small tweaks on the default JSON,\n you can call super first and make the tweaks on the returned\n JSON.\n\n ```js\n App.PostSerializer = DS.RESTSerializer.extend({\n serialize: function(record, options) {\n var json = this._super(record, options);\n\n json.subject = json.title;\n delete json.title;\n\n return json;\n }\n });\n ```\n\n @method serialize\n @param record\n @param options\n */\n serialize: function(record, options) {\n return this._super.apply(this, arguments);\n },\n\n /**\n You can use this method to customize the root keys serialized into the JSON.\n By default the REST Serializer sends camelized root keys.\n For example, your server may expect underscored root objects.\n\n ```js\n App.ApplicationSerializer = DS.RESTSerializer.extend({\n serializeIntoHash: function(data, type, record, options) {\n var root = Ember.String.decamelize(type.typeKey);\n data[root] = this.serialize(record, options);\n }\n });\n ```\n\n @method serializeIntoHash\n @param {Object} hash\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @param {Object} options\n */\n serializeIntoHash: function(hash, type, record, options) {\n var root = Ember.String.camelize(type.typeKey);\n hash[root] = this.serialize(record, options);\n },\n\n /**\n You can use this method to customize how polymorphic objects are serialized.\n By default the JSON Serializer creates the key by appending `Type` to\n the attribute and value from the model's camelcased model name.\n\n @method serializePolymorphicType\n @param {DS.Model} record\n @param {Object} json\n @param {Object} relationship\n */\n serializePolymorphicType: function(record, json, relationship) {\n var key = relationship.key,\n belongsTo = get(record, key);\n key = this.keyForAttribute ? this.keyForAttribute(key) : key;\n json[key + \"Type\"] = Ember.String.camelize(belongsTo.constructor.typeKey);\n }\n});\n\n})();\n//@ sourceURL=ember-data/serializers/rest_serializer");minispade.register('ember-data/system/adapter', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar map = Ember.ArrayPolyfills.map;\n\nvar errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];\n\n/**\n A `DS.InvalidError` is used by an adapter to signal the external API\n was unable to process a request because the content was not\n semantically correct or meaningful per the API. Usually this means a\n record failed some form of server side validation. When a promise\n from an adapter is rejected with a `DS.InvalidError` the record will\n transition to the `invalid` state and the errors will be set to the\n `errors` property on the record.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.RESTAdapter.extend({\n ajaxError: function(jqXHR) {\n var error = this._super(jqXHR);\n\n if (jqXHR && jqXHR.status === 422) {\n var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)[\"errors\"];\n return new DS.InvalidError(jsonErrors);\n } else {\n return error;\n }\n }\n });\n ```\n\n @class InvalidError\n @namespace DS\n*/\nDS.InvalidError = function(errors) {\n var tmp = Error.prototype.constructor.call(this, \"The backend rejected the commit because it was invalid: \" + Ember.inspect(errors));\n this.errors = errors;\n\n for (var i=0, l=errorProps.length; i<l; i++) {\n this[errorProps[i]] = tmp[errorProps[i]];\n }\n};\nDS.InvalidError.prototype = Ember.create(Error.prototype);\n\n/**\n An adapter is an object that receives requests from a store and\n translates them into the appropriate action to take against your\n persistence layer. The persistence layer is usually an HTTP API, but\n may be anything, such as the browser's local storage. Typically the\n adapter is not invoked directly instead its functionality is accessed\n through the `store`.\n\n ### Creating an Adapter\n\n First, create a new subclass of `DS.Adapter`:\n\n ```javascript\n App.MyAdapter = DS.Adapter.extend({\n // ...your code here\n });\n ```\n\n To tell your store which adapter to use, set its `adapter` property:\n\n ```javascript\n App.store = DS.Store.create({\n adapter: 'MyAdapter'\n });\n ```\n\n `DS.Adapter` is an abstract base class that you should override in your\n application to customize it for your backend. The minimum set of methods\n that you should implement is:\n\n * `find()`\n * `createRecord()`\n * `updateRecord()`\n * `deleteRecord()`\n * `findAll()`\n * `findQuery()`\n\n To improve the network performance of your application, you can optimize\n your adapter by overriding these lower-level methods:\n\n * `findMany()`\n\n\n For an example implementation, see `DS.RESTAdapter`, the\n included REST adapter.\n\n @class Adapter\n @namespace DS\n @extends Ember.Object\n*/\n\nDS.Adapter = Ember.Object.extend({\n\n /**\n If you would like your adapter to use a custom serializer you can\n set the `defaultSerializer` property to be the name of the custom\n serializer.\n\n Note the `defaultSerializer` serializer has a lower priority then\n a model specific serializer (i.e. `PostSerializer`) or the\n `application` serializer.\n\n ```javascript\n var DjangoAdapter = DS.Adapter.extend({\n defaultSerializer: 'django'\n });\n ```\n\n @property defaultSerializer\n @type {String}\n */\n\n /**\n The `find()` method is invoked when the store is asked for a record that\n has not previously been loaded. In response to `find()` being called, you\n should query your persistence layer for a record with the given ID. Once\n found, you can asynchronously call the store's `push()` method to push\n the record into the store.\n\n Here is an example `find` implementation:\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n find: function(store, type, id) {\n var url = [type, id].join('/');\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.getJSON(url).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method find\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} id\n @return {Promise} promise\n */\n find: Ember.required(Function),\n\n /**\n The `findAll()` method is called when you call `find` on the store\n without an ID (i.e. `store.find('post')`).\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n findAll: function(store, type, sinceToken) {\n var url = type;\n var query = { since: sinceToken };\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.getJSON(url, query).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @private\n @method findAll\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {String} sinceToken\n @return {Promise} promise\n */\n findAll: null,\n\n /**\n This method is called when you call `find` on the store with a\n query object as the second parameter (i.e. `store.find('person', {\n page: 1 })`).\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n findQuery: function(store, type, query) {\n var url = type;\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.getJSON(url, query).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @private\n @method findQuery\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {Object} query\n @param {DS.AdapterPopulatedRecordArray} recordArray\n @return {Promise} promise\n */\n findQuery: null,\n\n /**\n If the globally unique IDs for your records should be generated on the client,\n implement the `generateIdForRecord()` method. This method will be invoked\n each time you create a new record, and the value returned from it will be\n assigned to the record's `primaryKey`.\n\n Most traditional REST-like HTTP APIs will not use this method. Instead, the ID\n of the record will be set by the server, and your adapter will update the store\n with the new ID when it calls `didCreateRecord()`. Only implement this method if\n you intend to generate record IDs on the client-side.\n\n The `generateIdForRecord()` method will be invoked with the requesting store as\n the first parameter and the newly created record as the second parameter:\n\n ```javascript\n generateIdForRecord: function(store, record) {\n var uuid = App.generateUUIDWithStatisticallyLowOddsOfCollision();\n return uuid;\n }\n ```\n\n @method generateIdForRecord\n @param {DS.Store} store\n @param {DS.Model} record\n @return {String|Number} id\n */\n generateIdForRecord: null,\n\n /**\n Proxies to the serializer's `serialize` method.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n createRecord: function(store, type, record) {\n var data = this.serialize(record, { includeId: true });\n var url = type;\n\n // ...\n }\n });\n ```\n\n @method serialize\n @param {DS.Model} record\n @param {Object} options\n @return {Object} serialized record\n */\n serialize: function(record, options) {\n return get(record, 'store').serializerFor(record.constructor.typeKey).serialize(record, options);\n },\n\n /**\n Implement this method in a subclass to handle the creation of\n new records.\n\n Serializes the record and send it to the server.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n createRecord: function(store, type, record) {\n var data = this.serialize(record, { includeId: true });\n var url = type;\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.ajax({\n type: 'POST',\n url: url,\n dataType: 'json',\n data: data\n }).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method createRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type the DS.Model class of the record\n @param {DS.Model} record\n @return {Promise} promise\n */\n createRecord: Ember.required(Function),\n\n /**\n Implement this method in a subclass to handle the updating of\n a record.\n\n Serializes the record update and send it to the server.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n updateRecord: function(store, type, record) {\n var data = this.serialize(record, { includeId: true });\n var id = record.get('id');\n var url = [type, id].join('/');\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.ajax({\n type: 'PUT',\n url: url,\n dataType: 'json',\n data: data\n }).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method updateRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type the DS.Model class of the record\n @param {DS.Model} record\n @return {Promise} promise\n */\n updateRecord: Ember.required(Function),\n\n /**\n Implement this method in a subclass to handle the deletion of\n a record.\n\n Sends a delete request for the record to the server.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n deleteRecord: function(store, type, record) {\n var data = this.serialize(record, { includeId: true });\n var id = record.get('id');\n var url = [type, id].join('/');\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.ajax({\n type: 'DELETE',\n url: url,\n dataType: 'json',\n data: data\n }).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method deleteRecord\n @param {DS.Store} store\n @param {subclass of DS.Model} type the DS.Model class of the record\n @param {DS.Model} record\n @return {Promise} promise\n */\n deleteRecord: Ember.required(Function),\n\n /**\n Find multiple records at once.\n\n By default, it loops over the provided ids and calls `find` on each.\n May be overwritten to improve performance and reduce the number of\n server requests.\n\n Example\n\n ```javascript\n App.ApplicationAdapter = DS.Adapter.extend({\n findMany: function(store, type, ids) {\n var url = type;\n return new Ember.RSVP.Promise(function(resolve, reject) {\n jQuery.getJSON(url, {ids: ids}).then(function(data) {\n Ember.run(null, resolve, data);\n }, function(jqXHR) {\n jqXHR.then = null; // tame jQuery's ill mannered promises\n Ember.run(null, reject, jqXHR);\n });\n });\n }\n });\n ```\n\n @method findMany\n @param {DS.Store} store\n @param {subclass of DS.Model} type the DS.Model class of the records\n @param {Array} ids\n @return {Promise} promise\n */\n findMany: function(store, type, ids) {\n var promises = map.call(ids, function(id) {\n return this.find(store, type, id);\n }, this);\n\n return Ember.RSVP.all(promises);\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/adapter");minispade.register('ember-data/system/changes', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/system/changes/attribute_change\");\nminispade.require(\"ember-data/system/changes/relationship_change\");\n\n})();\n//@ sourceURL=ember-data/system/changes");minispade.register('ember-data/system/changes/attribute_change', "(function() {/**\n @module ember-data\n*/\n\n/**\n An AttributeChange object is created whenever a record's\n attribute changes value. It is used to track changes to a\n record between transaction commits.\n\n @class AttributeChange\n @namespace DS\n @private\n @constructor\n*/\nvar AttributeChange = DS.AttributeChange = function(options) {\n this.record = options.record;\n this.store = options.store;\n this.name = options.name;\n this.value = options.value;\n this.oldValue = options.oldValue;\n};\n\nAttributeChange.createChange = function(options) {\n return new AttributeChange(options);\n};\n\nAttributeChange.prototype = {\n sync: function() {\n if (this.value !== this.oldValue) {\n this.record.send('becomeDirty');\n this.record.updateRecordArraysLater();\n }\n\n // TODO: Use this object in the commit process\n this.destroy();\n },\n\n /**\n If the AttributeChange is destroyed (either by being rolled back\n or being committed), remove it from the list of pending changes\n on the record.\n\n @method destroy\n */\n destroy: function() {\n delete this.record._changesToSync[this.name];\n }\n};\n\n})();\n//@ sourceURL=ember-data/system/changes/attribute_change");minispade.register('ember-data/system/changes/relationship_change', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar forEach = Ember.EnumerableUtils.forEach;\n\n/**\n @class RelationshipChange\n @namespace DS\n @private\n @constructor\n*/\nDS.RelationshipChange = function(options) {\n this.parentRecord = options.parentRecord;\n this.childRecord = options.childRecord;\n this.firstRecord = options.firstRecord;\n this.firstRecordKind = options.firstRecordKind;\n this.firstRecordName = options.firstRecordName;\n this.secondRecord = options.secondRecord;\n this.secondRecordKind = options.secondRecordKind;\n this.secondRecordName = options.secondRecordName;\n this.changeType = options.changeType;\n this.store = options.store;\n\n this.committed = {};\n};\n\n/**\n @class RelationshipChangeAdd\n @namespace DS\n @private\n @constructor\n*/\nDS.RelationshipChangeAdd = function(options){\n DS.RelationshipChange.call(this, options);\n};\n\n/**\n @class RelationshipChangeRemove\n @namespace DS\n @private\n @constructor\n*/\nDS.RelationshipChangeRemove = function(options){\n DS.RelationshipChange.call(this, options);\n};\n\nDS.RelationshipChange.create = function(options) {\n return new DS.RelationshipChange(options);\n};\n\nDS.RelationshipChangeAdd.create = function(options) {\n return new DS.RelationshipChangeAdd(options);\n};\n\nDS.RelationshipChangeRemove.create = function(options) {\n return new DS.RelationshipChangeRemove(options);\n};\n\nDS.OneToManyChange = {};\nDS.OneToNoneChange = {};\nDS.ManyToNoneChange = {};\nDS.OneToOneChange = {};\nDS.ManyToManyChange = {};\n\nDS.RelationshipChange._createChange = function(options){\n if(options.changeType === \"add\"){\n return DS.RelationshipChangeAdd.create(options);\n }\n if(options.changeType === \"remove\"){\n return DS.RelationshipChangeRemove.create(options);\n }\n};\n\n\nDS.RelationshipChange.determineRelationshipType = function(recordType, knownSide){\n var knownKey = knownSide.key, key, otherKind;\n var knownKind = knownSide.kind;\n\n var inverse = recordType.inverseFor(knownKey);\n\n if (inverse){\n key = inverse.name;\n otherKind = inverse.kind;\n }\n\n if (!inverse){\n return knownKind === \"belongsTo\" ? \"oneToNone\" : \"manyToNone\";\n }\n else{\n if(otherKind === \"belongsTo\"){\n return knownKind === \"belongsTo\" ? \"oneToOne\" : \"manyToOne\";\n }\n else{\n return knownKind === \"belongsTo\" ? \"oneToMany\" : \"manyToMany\";\n }\n }\n\n};\n\nDS.RelationshipChange.createChange = function(firstRecord, secondRecord, store, options){\n // Get the type of the child based on the child's client ID\n var firstRecordType = firstRecord.constructor, changeType;\n changeType = DS.RelationshipChange.determineRelationshipType(firstRecordType, options);\n if (changeType === \"oneToMany\"){\n return DS.OneToManyChange.createChange(firstRecord, secondRecord, store, options);\n }\n else if (changeType === \"manyToOne\"){\n return DS.OneToManyChange.createChange(secondRecord, firstRecord, store, options);\n }\n else if (changeType === \"oneToNone\"){\n return DS.OneToNoneChange.createChange(firstRecord, secondRecord, store, options);\n }\n else if (changeType === \"manyToNone\"){\n return DS.ManyToNoneChange.createChange(firstRecord, secondRecord, store, options);\n }\n else if (changeType === \"oneToOne\"){\n return DS.OneToOneChange.createChange(firstRecord, secondRecord, store, options);\n }\n else if (changeType === \"manyToMany\"){\n return DS.ManyToManyChange.createChange(firstRecord, secondRecord, store, options);\n }\n};\n\nDS.OneToNoneChange.createChange = function(childRecord, parentRecord, store, options) {\n var key = options.key;\n var change = DS.RelationshipChange._createChange({\n parentRecord: parentRecord,\n childRecord: childRecord,\n firstRecord: childRecord,\n store: store,\n changeType: options.changeType,\n firstRecordName: key,\n firstRecordKind: \"belongsTo\"\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change);\n\n return change;\n};\n\nDS.ManyToNoneChange.createChange = function(childRecord, parentRecord, store, options) {\n var key = options.key;\n var change = DS.RelationshipChange._createChange({\n parentRecord: childRecord,\n childRecord: parentRecord,\n secondRecord: childRecord,\n store: store,\n changeType: options.changeType,\n secondRecordName: options.key,\n secondRecordKind: \"hasMany\"\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change);\n return change;\n};\n\n\nDS.ManyToManyChange.createChange = function(childRecord, parentRecord, store, options) {\n // If the name of the belongsTo side of the relationship is specified,\n // use that\n // If the type of the parent is specified, look it up on the child's type\n // definition.\n var key = options.key;\n\n var change = DS.RelationshipChange._createChange({\n parentRecord: parentRecord,\n childRecord: childRecord,\n firstRecord: childRecord,\n secondRecord: parentRecord,\n firstRecordKind: \"hasMany\",\n secondRecordKind: \"hasMany\",\n store: store,\n changeType: options.changeType,\n firstRecordName: key\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change);\n\n\n return change;\n};\n\nDS.OneToOneChange.createChange = function(childRecord, parentRecord, store, options) {\n var key;\n\n // If the name of the belongsTo side of the relationship is specified,\n // use that\n // If the type of the parent is specified, look it up on the child's type\n // definition.\n if (options.parentType) {\n key = options.parentType.inverseFor(options.key).name;\n } else if (options.key) {\n key = options.key;\n } else {\n Ember.assert(\"You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent\", false);\n }\n\n var change = DS.RelationshipChange._createChange({\n parentRecord: parentRecord,\n childRecord: childRecord,\n firstRecord: childRecord,\n secondRecord: parentRecord,\n firstRecordKind: \"belongsTo\",\n secondRecordKind: \"belongsTo\",\n store: store,\n changeType: options.changeType,\n firstRecordName: key\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change);\n\n\n return change;\n};\n\nDS.OneToOneChange.maintainInvariant = function(options, store, childRecord, key){\n if (options.changeType === \"add\" && store.recordIsMaterialized(childRecord)) {\n var oldParent = get(childRecord, key);\n if (oldParent){\n var correspondingChange = DS.OneToOneChange.createChange(childRecord, oldParent, store, {\n parentType: options.parentType,\n hasManyName: options.hasManyName,\n changeType: \"remove\",\n key: options.key\n });\n store.addRelationshipChangeFor(childRecord, key, options.parentRecord , null, correspondingChange);\n correspondingChange.sync();\n }\n }\n};\n\nDS.OneToManyChange.createChange = function(childRecord, parentRecord, store, options) {\n var key;\n\n // If the name of the belongsTo side of the relationship is specified,\n // use that\n // If the type of the parent is specified, look it up on the child's type\n // definition.\n if (options.parentType) {\n key = options.parentType.inverseFor(options.key).name;\n DS.OneToManyChange.maintainInvariant( options, store, childRecord, key );\n } else if (options.key) {\n key = options.key;\n } else {\n Ember.assert(\"You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent\", false);\n }\n\n var change = DS.RelationshipChange._createChange({\n parentRecord: parentRecord,\n childRecord: childRecord,\n firstRecord: childRecord,\n secondRecord: parentRecord,\n firstRecordKind: \"belongsTo\",\n secondRecordKind: \"hasMany\",\n store: store,\n changeType: options.changeType,\n firstRecordName: key\n });\n\n store.addRelationshipChangeFor(childRecord, key, parentRecord, change.getSecondRecordName(), change);\n\n\n return change;\n};\n\n\nDS.OneToManyChange.maintainInvariant = function(options, store, childRecord, key){\n if (options.changeType === \"add\" && childRecord) {\n var oldParent = get(childRecord, key);\n if (oldParent){\n var correspondingChange = DS.OneToManyChange.createChange(childRecord, oldParent, store, {\n parentType: options.parentType,\n hasManyName: options.hasManyName,\n changeType: \"remove\",\n key: options.key\n });\n store.addRelationshipChangeFor(childRecord, key, options.parentRecord, correspondingChange.getSecondRecordName(), correspondingChange);\n correspondingChange.sync();\n }\n }\n};\n\n/**\n @class RelationshipChange\n @namespace DS\n*/\nDS.RelationshipChange.prototype = {\n\n getSecondRecordName: function() {\n var name = this.secondRecordName, parent;\n\n if (!name) {\n parent = this.secondRecord;\n if (!parent) { return; }\n\n var childType = this.firstRecord.constructor;\n var inverse = childType.inverseFor(this.firstRecordName);\n this.secondRecordName = inverse.name;\n }\n\n return this.secondRecordName;\n },\n\n /**\n Get the name of the relationship on the belongsTo side.\n\n @method getFirstRecordName\n @return {String}\n */\n getFirstRecordName: function() {\n var name = this.firstRecordName;\n return name;\n },\n\n /**\n @method destroy\n @private\n */\n destroy: function() {\n var childRecord = this.childRecord,\n belongsToName = this.getFirstRecordName(),\n hasManyName = this.getSecondRecordName(),\n store = this.store;\n\n store.removeRelationshipChangeFor(childRecord, belongsToName, this.parentRecord, hasManyName, this.changeType);\n },\n\n getSecondRecord: function(){\n return this.secondRecord;\n },\n\n /**\n @method getFirstRecord\n @private\n */\n getFirstRecord: function() {\n return this.firstRecord;\n },\n\n coalesce: function(){\n var relationshipPairs = this.store.relationshipChangePairsFor(this.firstRecord);\n forEach(relationshipPairs, function(pair){\n var addedChange = pair[\"add\"];\n var removedChange = pair[\"remove\"];\n if(addedChange && removedChange) {\n addedChange.destroy();\n removedChange.destroy();\n }\n });\n }\n};\n\nDS.RelationshipChangeAdd.prototype = Ember.create(DS.RelationshipChange.create({}));\nDS.RelationshipChangeRemove.prototype = Ember.create(DS.RelationshipChange.create({}));\n\n// the object is a value, and not a promise\nfunction isValue(object) {\n return typeof object === 'object' && (!object.then || typeof object.then !== 'function');\n}\n\nDS.RelationshipChangeAdd.prototype.changeType = \"add\";\nDS.RelationshipChangeAdd.prototype.sync = function() {\n var secondRecordName = this.getSecondRecordName(),\n firstRecordName = this.getFirstRecordName(),\n firstRecord = this.getFirstRecord(),\n secondRecord = this.getSecondRecord();\n\n //Ember.assert(\"You specified a hasMany (\" + hasManyName + \") on \" + (!belongsToName && (newParent || oldParent || this.lastParent).constructor) + \" but did not specify an inverse belongsTo on \" + child.constructor, belongsToName);\n //Ember.assert(\"You specified a belongsTo (\" + belongsToName + \") on \" + child.constructor + \" but did not specify an inverse hasMany on \" + (!hasManyName && (newParent || oldParent || this.lastParentRecord).constructor), hasManyName);\n\n if (secondRecord instanceof DS.Model && firstRecord instanceof DS.Model) {\n if(this.secondRecordKind === \"belongsTo\"){\n secondRecord.suspendRelationshipObservers(function(){\n set(secondRecord, secondRecordName, firstRecord);\n });\n\n }\n else if(this.secondRecordKind === \"hasMany\"){\n secondRecord.suspendRelationshipObservers(function(){\n var relationship = get(secondRecord, secondRecordName);\n if (isValue(relationship)) { relationship.addObject(firstRecord); }\n });\n }\n }\n\n if (firstRecord instanceof DS.Model && secondRecord instanceof DS.Model && get(firstRecord, firstRecordName) !== secondRecord) {\n if(this.firstRecordKind === \"belongsTo\"){\n firstRecord.suspendRelationshipObservers(function(){\n set(firstRecord, firstRecordName, secondRecord);\n });\n }\n else if(this.firstRecordKind === \"hasMany\"){\n firstRecord.suspendRelationshipObservers(function(){\n var relationship = get(firstRecord, firstRecordName);\n if (isValue(relationship)) { relationship.addObject(secondRecord); }\n });\n }\n }\n\n this.coalesce();\n};\n\nDS.RelationshipChangeRemove.prototype.changeType = \"remove\";\nDS.RelationshipChangeRemove.prototype.sync = function() {\n var secondRecordName = this.getSecondRecordName(),\n firstRecordName = this.getFirstRecordName(),\n firstRecord = this.getFirstRecord(),\n secondRecord = this.getSecondRecord();\n\n //Ember.assert(\"You specified a hasMany (\" + hasManyName + \") on \" + (!belongsToName && (newParent || oldParent || this.lastParent).constructor) + \" but did not specify an inverse belongsTo on \" + child.constructor, belongsToName);\n //Ember.assert(\"You specified a belongsTo (\" + belongsToName + \") on \" + child.constructor + \" but did not specify an inverse hasMany on \" + (!hasManyName && (newParent || oldParent || this.lastParentRecord).constructor), hasManyName);\n\n if (secondRecord instanceof DS.Model && firstRecord instanceof DS.Model) {\n if(this.secondRecordKind === \"belongsTo\"){\n secondRecord.suspendRelationshipObservers(function(){\n set(secondRecord, secondRecordName, null);\n });\n }\n else if(this.secondRecordKind === \"hasMany\"){\n secondRecord.suspendRelationshipObservers(function(){\n var relationship = get(secondRecord, secondRecordName);\n if (isValue(relationship)) { relationship.removeObject(firstRecord); }\n });\n }\n }\n\n if (firstRecord instanceof DS.Model && get(firstRecord, firstRecordName)) {\n if(this.firstRecordKind === \"belongsTo\"){\n firstRecord.suspendRelationshipObservers(function(){\n set(firstRecord, firstRecordName, null);\n });\n }\n else if(this.firstRecordKind === \"hasMany\"){\n firstRecord.suspendRelationshipObservers(function(){\n var relationship = get(firstRecord, firstRecordName);\n if (isValue(relationship)) { relationship.removeObject(secondRecord); }\n });\n }\n }\n\n this.coalesce();\n};\n\n})();\n//@ sourceURL=ember-data/system/changes/relationship_change");minispade.register('ember-data/system/container_proxy', "(function() {/**\n This is used internally to enable deprecation of container paths and provide\n a decent message to the user indicating how to fix the issue.\n\n @class ContainerProxy\n @namespace DS\n @private\n*/\nvar ContainerProxy = function (container){\n this.container = container;\n};\n\nContainerProxy.prototype.aliasedFactory = function(path, preLookup) {\n var _this = this;\n\n return {create: function(){ \n if (preLookup) { preLookup(); }\n\n return _this.container.lookup(path); \n }};\n};\n\nContainerProxy.prototype.registerAlias = function(source, dest, preLookup) {\n var factory = this.aliasedFactory(dest, preLookup);\n\n return this.container.register(source, factory);\n};\n\nContainerProxy.prototype.registerDeprecation = function(deprecated, valid) {\n var preLookupCallback = function(){\n Ember.deprecate(\"You tried to look up '\" + deprecated + \"', \" +\n \"but this has been deprecated in favor of '\" + valid + \"'.\", false);\n };\n\n return this.registerAlias(deprecated, valid, preLookupCallback);\n};\n\nContainerProxy.prototype.registerDeprecations = function(proxyPairs) {\n for (var i = proxyPairs.length; i > 0; i--) {\n var proxyPair = proxyPairs[i - 1],\n deprecated = proxyPair['deprecated'],\n valid = proxyPair['valid'];\n\n this.registerDeprecation(deprecated, valid);\n }\n};\n\nDS.ContainerProxy = ContainerProxy;\n\n})();\n//@ sourceURL=ember-data/system/container_proxy");minispade.register('ember-data/system/debug', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/system/debug/debug_info\");\nminispade.require(\"ember-data/system/debug/debug_adapter\");\n\n})();\n//@ sourceURL=ember-data/system/debug");minispade.register('ember-data/system/debug/debug_adapter', "(function() {/**\n @module ember-data\n*/\nvar get = Ember.get, capitalize = Ember.String.capitalize, underscore = Ember.String.underscore, DS = window.DS ;\n\n/**\n Extend `Ember.DataAdapter` with ED specific code.\n\n @class DebugAdapter\n @namespace DS\n @extends Ember.DataAdapter\n @private\n*/\nDS.DebugAdapter = Ember.DataAdapter.extend({\n getFilters: function() {\n return [\n { name: 'isNew', desc: 'New' },\n { name: 'isModified', desc: 'Modified' },\n { name: 'isClean', desc: 'Clean' }\n ];\n },\n\n detect: function(klass) {\n return klass !== DS.Model && DS.Model.detect(klass);\n },\n\n columnsForType: function(type) {\n var columns = [{ name: 'id', desc: 'Id' }], count = 0, self = this;\n get(type, 'attributes').forEach(function(name, meta) {\n if (count++ > self.attributeLimit) { return false; }\n var desc = capitalize(underscore(name).replace('_', ' '));\n columns.push({ name: name, desc: desc });\n });\n return columns;\n },\n\n getRecords: function(type) {\n return this.get('store').all(type);\n },\n\n getRecordColumnValues: function(record) {\n var self = this, count = 0,\n columnValues = { id: get(record, 'id') };\n\n record.eachAttribute(function(key) {\n if (count++ > self.attributeLimit) {\n return false;\n }\n var value = get(record, key);\n columnValues[key] = value;\n });\n return columnValues;\n },\n\n getRecordKeywords: function(record) {\n var keywords = [], keys = Ember.A(['id']);\n record.eachAttribute(function(key) {\n keys.push(key);\n });\n keys.forEach(function(key) {\n keywords.push(get(record, key));\n });\n return keywords;\n },\n\n getRecordFilterValues: function(record) {\n return {\n isNew: record.get('isNew'),\n isModified: record.get('isDirty') && !record.get('isNew'),\n isClean: !record.get('isDirty')\n };\n },\n\n getRecordColor: function(record) {\n var color = 'black';\n if (record.get('isNew')) {\n color = 'green';\n } else if (record.get('isDirty')) {\n color = 'blue';\n }\n return color;\n },\n\n observeRecord: function(record, recordUpdated) {\n var releaseMethods = Ember.A(), self = this,\n keysToObserve = Ember.A(['id', 'isNew', 'isDirty']);\n\n record.eachAttribute(function(key) {\n keysToObserve.push(key);\n });\n\n keysToObserve.forEach(function(key) {\n var handler = function() {\n recordUpdated(self.wrapRecord(record));\n };\n Ember.addObserver(record, key, handler);\n releaseMethods.push(function() {\n Ember.removeObserver(record, key, handler);\n });\n });\n\n var release = function() {\n releaseMethods.forEach(function(fn) { fn(); } );\n };\n\n return release;\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/system/debug/debug_adapter");minispade.register('ember-data/system/debug/debug_info', "(function() {minispade.require(\"ember-data/system/model/model\");\n\nDS.Model.reopen({\n\n /**\n Provides info about the model for debugging purposes\n by grouping the properties into more semantic groups.\n\n Meant to be used by debugging tools such as the Chrome Ember Extension.\n\n - Groups all attributes in \"Attributes\" group.\n - Groups all belongsTo relationships in \"Belongs To\" group.\n - Groups all hasMany relationships in \"Has Many\" group.\n - Groups all flags in \"Flags\" group.\n - Flags relationship CPs as expensive properties.\n\n @method _debugInfo\n @for DS.Model\n @private\n */\n _debugInfo: function() {\n var attributes = ['id'],\n relationships = { belongsTo: [], hasMany: [] },\n expensiveProperties = [];\n\n this.eachAttribute(function(name, meta) {\n attributes.push(name);\n }, this);\n\n this.eachRelationship(function(name, relationship) {\n relationships[relationship.kind].push(name);\n expensiveProperties.push(name);\n });\n\n var groups = [\n {\n name: 'Attributes',\n properties: attributes,\n expand: true\n },\n {\n name: 'Belongs To',\n properties: relationships.belongsTo,\n expand: true\n },\n {\n name: 'Has Many',\n properties: relationships.hasMany,\n expand: true\n },\n {\n name: 'Flags',\n properties: ['isLoaded', 'isDirty', 'isSaving', 'isDeleted', 'isError', 'isNew', 'isValid']\n }\n ];\n\n return {\n propertyInfo: {\n // include all other mixins / properties (not just the grouped ones)\n includeOtherProperties: true,\n groups: groups,\n // don't pre-calculate unless cached\n expensiveProperties: expensiveProperties\n }\n };\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/system/debug/debug_info");minispade.register('ember-data/system/model', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/system/model/model\");\nminispade.require(\"ember-data/system/model/states\");\nminispade.require(\"ember-data/system/model/attributes\");\n\n})();\n//@ sourceURL=ember-data/system/model");minispade.register('ember-data/system/model/attributes', "(function() {minispade.require(\"ember-data/system/model/model\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get;\n\n/**\n @class Model\n @namespace DS\n*/\nDS.Model.reopenClass({\n /**\n A map whose keys are the attributes of the model (properties\n described by DS.attr) and whose values are the meta object for the\n property.\n\n Example\n\n ```javascript\n\n App.Person = DS.Model.extend({\n firstName: attr('string'),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\n var attributes = Ember.get(App.Person, 'attributes')\n\n attributes.forEach(function(name, meta) {\n console.log(name, meta);\n });\n\n // prints:\n // firstName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"firstName\"}\n // lastName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"lastName\"}\n // birthday {type: \"date\", isAttribute: true, options: Object, parentType: function, name: \"birthday\"}\n ```\n\n @property attributes\n @static\n @type {Ember.Map}\n @readOnly\n */\n attributes: Ember.computed(function() {\n var map = Ember.Map.create();\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isAttribute) {\n Ember.assert(\"You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from \" + this.toString(), name !== 'id');\n\n meta.name = name;\n map.set(name, meta);\n }\n });\n\n return map;\n }),\n\n /**\n A map whose keys are the attributes of the model (properties\n described by DS.attr) and whose values are type of transformation\n applied to each attribute. This map does not include any\n attributes that do not have an transformation type.\n\n Example\n\n ```javascript\n App.Person = DS.Model.extend({\n firstName: attr(),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\n var transformedAttributes = Ember.get(App.Person, 'transformedAttributes')\n\n transformedAttributes.forEach(function(field, type) {\n console.log(field, type);\n });\n\n // prints:\n // lastName string\n // birthday date\n ```\n\n @property transformedAttributes\n @static\n @type {Ember.Map}\n @readOnly\n */\n transformedAttributes: Ember.computed(function() {\n var map = Ember.Map.create();\n\n this.eachAttribute(function(key, meta) {\n if (meta.type) {\n map.set(key, meta.type);\n }\n });\n\n return map;\n }),\n\n /**\n Iterates through the attributes of the model, calling the passed function on each\n attribute.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(name, meta);\n ```\n\n - `name` the name of the current property in the iteration\n - `meta` the meta object for the attribute property in the iteration\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context.\n\n Example\n\n ```javascript\n App.Person = DS.Model.extend({\n firstName: attr('string'),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\n App.Person.eachAttribute(function(name, meta) {\n console.log(name, meta);\n });\n\n // prints:\n // firstName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"firstName\"}\n // lastName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"lastName\"}\n // birthday {type: \"date\", isAttribute: true, options: Object, parentType: function, name: \"birthday\"}\n ```\n\n @method eachAttribute\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @static\n */\n eachAttribute: function(callback, binding) {\n get(this, 'attributes').forEach(function(name, meta) {\n callback.call(binding, name, meta);\n }, binding);\n },\n\n /**\n Iterates through the transformedAttributes of the model, calling\n the passed function on each attribute. Note the callback will not be\n called for any attributes that do not have an transformation type.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(name, type);\n ```\n\n - `name` the name of the current property in the iteration\n - `type` a string containing the name of the type of transformed\n applied to the attribute\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context.\n\n Example\n\n ```javascript\n App.Person = DS.Model.extend({\n firstName: attr(),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\n App.Person.eachTransformedAttribute(function(name, type) {\n console.log(name, type);\n });\n\n // prints:\n // lastName string\n // birthday date\n ```\n\n @method eachTransformedAttribute\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @static\n */\n eachTransformedAttribute: function(callback, binding) {\n get(this, 'transformedAttributes').forEach(function(name, type) {\n callback.call(binding, name, type);\n });\n }\n});\n\n\nDS.Model.reopen({\n eachAttribute: function(callback, binding) {\n this.constructor.eachAttribute(callback, binding);\n }\n});\n\nfunction getDefaultValue(record, options, key) {\n if (typeof options.defaultValue === \"function\") {\n return options.defaultValue();\n } else {\n return options.defaultValue;\n }\n}\n\nfunction hasValue(record, key) {\n return record._attributes.hasOwnProperty(key) ||\n record._inFlightAttributes.hasOwnProperty(key) ||\n record._data.hasOwnProperty(key);\n}\n\nfunction getValue(record, key) {\n if (record._attributes.hasOwnProperty(key)) {\n return record._attributes[key];\n } else if (record._inFlightAttributes.hasOwnProperty(key)) {\n return record._inFlightAttributes[key];\n } else {\n return record._data[key];\n }\n}\n\n/**\n `DS.attr` defines an attribute on a [DS.Model](DS.Model.html).\n By default, attributes are passed through as-is, however you can specify an\n optional type to have the value automatically transformed.\n Ember Data ships with four basic transform types: `string`, `number`,\n `boolean` and `date`. You can define your own transforms by subclassing\n [DS.Transform](DS.Transform.html).\n\n `DS.attr` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `defaultValue`: Pass a string or a function to be called to set the attribute\n to a default value if none is supplied.\n\n Example\n\n ```javascript\n var attr = DS.attr;\n\n App.User = DS.Model.extend({\n username: attr('string'),\n email: attr('string'),\n verified: attr('boolean', {defaultValue: false})\n });\n ```\n\n @namespace\n @method attr\n @for DS\n @param {String} type the attribute type\n @param {Object} options a hash of options\n @return {Attribute}\n*/\n\nDS.attr = function(type, options) {\n options = options || {};\n\n var meta = {\n type: type,\n isAttribute: true,\n options: options\n };\n\n return Ember.computed(function(key, value) {\n if (arguments.length > 1) {\n Ember.assert(\"You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from \" + this.constructor.toString(), key !== 'id');\n var oldValue = this._attributes[key] || this._inFlightAttributes[key] || this._data[key];\n\n this.send('didSetProperty', {\n name: key,\n oldValue: oldValue,\n originalValue: this._data[key],\n value: value\n });\n\n this._attributes[key] = value;\n return value;\n } else if (hasValue(this, key)) {\n return getValue(this, key);\n } else {\n return getDefaultValue(this, options, key);\n }\n\n // `data` is never set directly. However, it may be\n // invalidated from the state manager's setData\n // event.\n }).property('data').meta(meta);\n};\n\n\n})();\n//@ sourceURL=ember-data/system/model/attributes");minispade.register('ember-data/system/model/errors', "(function() {var get = Ember.get, isEmpty = Ember.isEmpty;\n\n/**\n@module ember-data\n*/\n\n/**\n Holds validation errors for a given record organized by attribute names.\n\n @class Errors\n @namespace DS\n @extends Ember.Object\n @uses Ember.Enumerable\n @uses Ember.Evented\n */\nDS.Errors = Ember.Object.extend(Ember.Enumerable, Ember.Evented, {\n /**\n Register with target handler\n\n @method registerHandlers\n @param {Object} target\n @param {Function} becameInvalid\n @param {Function} becameValid\n */\n registerHandlers: function(target, becameInvalid, becameValid) {\n this.on('becameInvalid', target, becameInvalid);\n this.on('becameValid', target, becameValid);\n },\n\n /**\n @property errorsByAttributeName\n @type {Ember.MapWithDefault}\n @private\n */\n errorsByAttributeName: Ember.reduceComputed(\"content\", {\n initialValue: function() {\n return Ember.MapWithDefault.create({\n defaultValue: function() {\n return Ember.A();\n }\n });\n },\n\n addedItem: function(errors, error) {\n errors.get(error.attribute).pushObject(error);\n\n return errors;\n },\n\n removedItem: function(errors, error) {\n errors.get(error.attribute).removeObject(error);\n\n return errors;\n }\n }),\n\n /**\n Returns errors for a given attribute\n\n @method errorsFor\n @param {String} attribute\n @returns {Array}\n */\n errorsFor: function(attribute) {\n return get(this, 'errorsByAttributeName').get(attribute);\n },\n\n /**\n */\n messages: Ember.computed.mapBy('content', 'message'),\n\n /**\n @property content\n @type {Array}\n @private\n */\n content: Ember.computed(function() {\n return Ember.A();\n }),\n\n /**\n @method unknownProperty\n @private\n */\n unknownProperty: function(attribute) {\n var errors = this.errorsFor(attribute);\n if (isEmpty(errors)) { return null; }\n return errors;\n },\n\n /**\n @method nextObject\n @private\n */\n nextObject: function(index, previousObject, context) {\n return get(this, 'content').objectAt(index);\n },\n\n /**\n Total number of errors.\n\n @property length\n @type {Number}\n @readOnly\n */\n length: Ember.computed.oneWay('content.length').readOnly(),\n\n /**\n @property isEmpty\n @type {Boolean}\n @readOnly\n */\n isEmpty: Ember.computed.not('length').readOnly(),\n\n /**\n Adds error messages to a given attribute and sends\n `becameInvalid` event to the record.\n\n @method add\n @param {String} attribute\n @param {Array|String} messages\n */\n add: function(attribute, messages) {\n var wasEmpty = get(this, 'isEmpty');\n\n messages = this._findOrCreateMessages(attribute, messages);\n get(this, 'content').addObjects(messages);\n\n this.notifyPropertyChange(attribute);\n this.enumerableContentDidChange();\n\n if (wasEmpty && !get(this, 'isEmpty')) {\n this.trigger('becameInvalid');\n }\n },\n\n /**\n @method _findOrCreateMessages\n @private\n */\n _findOrCreateMessages: function(attribute, messages) {\n var errors = this.errorsFor(attribute);\n\n return Ember.makeArray(messages).map(function(message) {\n return errors.findBy('message', message) || {\n attribute: attribute,\n message: message\n };\n });\n },\n\n /**\n Removes all error messages from the given attribute and sends\n `becameValid` event to the record if there no more errors left.\n\n @method remove\n @param {String} attribute\n */\n remove: function(attribute) {\n if (get(this, 'isEmpty')) { return; }\n\n var content = get(this, 'content').rejectBy('attribute', attribute);\n get(this, 'content').setObjects(content);\n\n this.notifyPropertyChange(attribute);\n this.enumerableContentDidChange();\n\n if (get(this, 'isEmpty')) {\n this.trigger('becameValid');\n }\n },\n\n /**\n Removes all error messages and sends `becameValid` event\n to the record.\n\n @method clear\n */\n clear: function() {\n if (get(this, 'isEmpty')) { return; }\n\n get(this, 'content').clear();\n this.enumerableContentDidChange();\n\n this.trigger('becameValid');\n },\n\n /**\n Checks if there is error messages for the given attribute.\n\n @method has\n @param {String} attribute\n @returns {Boolean} true if there some errors on given attribute\n */\n has: function(attribute) {\n return !isEmpty(this.errorsFor(attribute));\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/model/errors");minispade.register('ember-data/system/model/model', "(function() {minispade.require(\"ember-data/system/model/states\");\nminispade.require(\"ember-data/system/model/errors\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set,\n merge = Ember.merge;\n\nvar retrieveFromCurrentState = Ember.computed('currentState', function(key, value) {\n return get(get(this, 'currentState'), key);\n}).readOnly();\n\n/**\n\n The model class that all Ember Data records descend from.\n\n @class Model\n @namespace DS\n @extends Ember.Object\n @uses Ember.Evented\n*/\nDS.Model = Ember.Object.extend(Ember.Evented, {\n /**\n If this property is `true` the record is in the `empty`\n state. Empty is the first state all records enter after they have\n been created. Most records created by the store will quickly\n transition to the `loading` state if data needs to be fetched from\n the server or the `created` state if the record is created on the\n client. A record can also enter the empty state if the adapter is\n unable to locate the record.\n\n @property isEmpty\n @type {Boolean}\n @readOnly\n */\n isEmpty: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `loading` state. A\n record enters this state when the store asks the adapter for its\n data. It remains in this state until the adapter provides the\n requested data.\n\n @property isLoading\n @type {Boolean}\n @readOnly\n */\n isLoading: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `loaded` state. A\n record enters this state when its data is populated. Most of a\n record's lifecycle is spent inside substates of the `loaded`\n state.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isLoaded'); // true\n\n store.find('model', 1).then(function(model) {\n model.get('isLoaded'); // true\n });\n ```\n\n @property isLoaded\n @type {Boolean}\n @readOnly\n */\n isLoaded: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `dirty` state. The\n record has local changes that have not yet been saved by the\n adapter. This includes records that have been created (but not yet\n saved) or deleted.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isDirty'); // true\n\n store.find('model', 1).then(function(model) {\n model.get('isDirty'); // false\n model.set('foo', 'some value');\n model.set('isDirty'); // true\n });\n ```\n\n @property isDirty\n @type {Boolean}\n @readOnly\n */\n isDirty: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `saving` state. A\n record enters the saving state when `save` is called, but the\n adapter has not yet acknowledged that the changes have been\n persisted to the backend.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isSaving'); // false\n var promise = record.save();\n record.get('isSaving'); // true\n promise.then(function() {\n record.get('isSaving'); // false\n });\n ```\n\n @property isSaving\n @type {Boolean}\n @readOnly\n */\n isSaving: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `deleted` state\n and has been marked for deletion. When `isDeleted` is true and\n `isDirty` is true, the record is deleted locally but the deletion\n was not yet persisted. When `isSaving` is true, the change is\n in-flight. When both `isDirty` and `isSaving` are false, the\n change has persisted.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isDeleted'); // false\n record.deleteRecord();\n record.get('isDeleted'); // true\n ```\n\n @property isDeleted\n @type {Boolean}\n @readOnly\n */\n isDeleted: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `new` state. A\n record will be in the `new` state when it has been created on the\n client and the adapter has not yet report that it was successfully\n saved.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('isNew'); // true\n\n record.save().then(function(model) {\n model.get('isNew'); // false\n });\n ```\n\n @property isNew\n @type {Boolean}\n @readOnly\n */\n isNew: retrieveFromCurrentState,\n /**\n If this property is `true` the record is in the `valid` state. A\n record will be in the `valid` state when no client-side\n validations have failed and the adapter did not report any\n server-side validation failures.\n\n @property isValid\n @type {Boolean}\n @readOnly\n */\n isValid: retrieveFromCurrentState,\n /**\n If the record is in the dirty state this property will report what\n kind of change has caused it to move into the dirty\n state. Possible values are:\n\n - `created` The record has been created by the client and not yet saved to the adapter.\n - `updated` The record has been updated by the client and not yet saved to the adapter.\n - `deleted` The record has been deleted by the client and not yet saved to the adapter.\n\n Example\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('dirtyType'); // 'created'\n ```\n\n @property dirtyType\n @type {String}\n @readOnly\n */\n dirtyType: retrieveFromCurrentState,\n\n /**\n If `true` the adapter reported that it was unable to save local\n changes to the backend. This may also result in the record having\n its `isValid` property become false if the adapter reported that\n server-side validations failed.\n\n Example\n\n ```javascript\n record.get('isError'); // false\n record.set('foo', 'invalid value');\n record.save().then(null, function() {\n record.get('isError'); // true\n });\n ```\n\n @property isError\n @type {Boolean}\n @readOnly\n */\n isError: false,\n /**\n If `true` the store is attempting to reload the record form the adapter.\n\n Example\n\n ```javascript\n record.get('isReloading'); // false\n record.reload();\n record.get('isReloading'); // true\n ```\n\n @property isReloading\n @type {Boolean}\n @readOnly\n */\n isReloading: false,\n\n /**\n The `clientId` property is a transient numerical identifier\n generated at runtime by the data store. It is important\n primarily because newly created objects may not yet have an\n externally generated id.\n\n @property clientId\n @private\n @type {Number|String}\n */\n clientId: null,\n /**\n All ember models have an id property. This is an identifier\n managed by an external source. These are always coerced to be\n strings before being used internally. Note when declaring the\n attributes for a model it is an error to declare an id\n attribute.\n\n ```javascript\n var record = store.createRecord(App.Model);\n record.get('id'); // null\n\n store.find('model', 1).then(function(model) {\n model.get('id'); // '1'\n });\n ```\n\n @property id\n @type {String}\n */\n id: null,\n transaction: null,\n /**\n @property currentState\n @private\n @type {Object}\n */\n currentState: null,\n /**\n When the record is in the `invalid` state this object will contain\n any errors returned by the adapter. When present the errors hash\n typically contains keys corresponding to the invalid property names\n and values which are an array of error messages.\n\n ```javascript\n record.get('errors.length'); // 0\n record.set('foo', 'invalid value');\n record.save().then(null, function() {\n record.get('errors').get('foo'); // ['foo should be a number.']\n });\n ```\n\n @property errors\n @type {Object}\n */\n errors: null,\n\n /**\n Create a JSON representation of the record, using the serialization\n strategy of the store's adapter.\n\n `serialize` takes an optional hash as a parameter, currently\n supported options are:\n\n - `includeId`: `true` if the record's ID should be included in the\n JSON representation.\n\n @method serialize\n @param {Object} options\n @returns {Object} an object whose values are primitive JSON values only\n */\n serialize: function(options) {\n var store = get(this, 'store');\n return store.serialize(this, options);\n },\n\n /**\n Use [DS.JSONSerializer](DS.JSONSerializer.html) to\n get the JSON representation of a record.\n\n `toJSON` takes an optional hash as a parameter, currently\n supported options are:\n\n - `includeId`: `true` if the record's ID should be included in the\n JSON representation.\n\n @method toJSON\n @param {Object} options\n @returns {Object} A JSON representation of the object.\n */\n toJSON: function(options) {\n // container is for lazy transform lookups\n var serializer = DS.JSONSerializer.create({ container: this.container });\n return serializer.serialize(this, options);\n },\n\n /**\n Fired when the record is loaded from the server.\n\n @event didLoad\n */\n didLoad: Ember.K,\n\n /**\n Fired when the record is updated.\n\n @event didUpdate\n */\n didUpdate: Ember.K,\n\n /**\n Fired when the record is created.\n\n @event didCreate\n */\n didCreate: Ember.K,\n\n /**\n Fired when the record is deleted.\n\n @event didDelete\n */\n didDelete: Ember.K,\n\n /**\n Fired when the record becomes invalid.\n\n @event becameInvalid\n */\n becameInvalid: Ember.K,\n\n /**\n Fired when the record enters the error state.\n\n @event becameError\n */\n becameError: Ember.K,\n\n /**\n @property data\n @private\n @type {Object}\n */\n data: Ember.computed(function() {\n this._data = this._data || {};\n return this._data;\n }).property(),\n\n _data: null,\n\n init: function() {\n set(this, 'currentState', DS.RootState.empty);\n var errors = DS.Errors.create();\n errors.registerHandlers(this, function() {\n this.send('becameInvalid');\n }, function() {\n this.send('becameValid');\n });\n set(this, 'errors', errors);\n this._super();\n this._setup();\n },\n\n _setup: function() {\n this._changesToSync = {};\n this._deferredTriggers = [];\n this._data = {};\n this._attributes = {};\n this._inFlightAttributes = {};\n this._relationships = {};\n },\n\n /**\n @method send\n @private\n @param {String} name\n @param {Object} context\n */\n send: function(name, context) {\n var currentState = get(this, 'currentState');\n\n if (!currentState[name]) {\n this._unhandledEvent(currentState, name, context);\n }\n\n return currentState[name](this, context);\n },\n\n /**\n @method transitionTo\n @private\n @param {String} name\n */\n transitionTo: function(name) {\n // POSSIBLE TODO: Remove this code and replace with\n // always having direct references to state objects\n\n var pivotName = name.split(\".\", 1),\n currentState = get(this, 'currentState'),\n state = currentState;\n\n do {\n if (state.exit) { state.exit(this); }\n state = state.parentState;\n } while (!state.hasOwnProperty(pivotName));\n\n var path = name.split(\".\");\n\n var setups = [], enters = [], i, l;\n\n for (i=0, l=path.length; i<l; i++) {\n state = state[path[i]];\n\n if (state.enter) { enters.push(state); }\n if (state.setup) { setups.push(state); }\n }\n\n for (i=0, l=enters.length; i<l; i++) {\n enters[i].enter(this);\n }\n\n set(this, 'currentState', state);\n\n for (i=0, l=setups.length; i<l; i++) {\n setups[i].setup(this);\n }\n\n this.updateRecordArraysLater();\n },\n\n _unhandledEvent: function(state, name, context) {\n var errorMessage = \"Attempted to handle event `\" + name + \"` \";\n errorMessage += \"on \" + String(this) + \" while in state \";\n errorMessage += state.stateName + \". \";\n\n if (context !== undefined) {\n errorMessage += \"Called with \" + Ember.inspect(context) + \".\";\n }\n\n throw new Ember.Error(errorMessage);\n },\n\n withTransaction: function(fn) {\n var transaction = get(this, 'transaction');\n if (transaction) { fn(transaction); }\n },\n\n /**\n @method loadingData\n @private\n @param {Promise} promise\n */\n loadingData: function(promise) {\n this.send('loadingData', promise);\n },\n\n /**\n @method loadedData\n @private\n */\n loadedData: function() {\n this.send('loadedData');\n },\n\n /**\n @method notFound\n @private\n */\n notFound: function() {\n this.send('notFound');\n },\n\n /**\n @method pushedData\n @private\n */\n pushedData: function() {\n this.send('pushedData');\n },\n\n /**\n Marks the record as deleted but does not save it. You must call\n `save` afterwards if you want to persist it. You might use this\n method if you want to allow the user to still `rollback()` a\n delete after it was made.\n\n Example\n\n ```javascript\n App.ModelDeleteRoute = Ember.Route.extend({\n actions: {\n softDelete: function() {\n this.get('model').deleteRecord();\n },\n confirm: function() {\n this.get('model').save();\n },\n undo: function() {\n this.get('model').rollback();\n }\n }\n });\n ```\n\n @method deleteRecord\n */\n deleteRecord: function() {\n this.send('deleteRecord');\n },\n\n /**\n Same as `deleteRecord`, but saves the record immediately.\n\n Example\n\n ```javascript\n App.ModelDeleteRoute = Ember.Route.extend({\n actions: {\n delete: function() {\n var controller = this.controller;\n this.get('model').destroyRecord().then(function() {\n controller.transitionToRoute('model.index');\n });\n }\n }\n });\n ```\n\n @method destroyRecord\n @return {Promise} a promise that will be resolved when the adapter returns\n successfully or rejected if the adapter returns with an error.\n */\n destroyRecord: function() {\n this.deleteRecord();\n return this.save();\n },\n\n /**\n @method unloadRecord\n @private\n */\n unloadRecord: function() {\n Ember.assert(\"You can only unload a loaded, non-dirty record.\", !get(this, 'isDirty'));\n\n this.send('unloadRecord');\n },\n\n /**\n @method clearRelationships\n @private\n */\n clearRelationships: function() {\n this.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'belongsTo') {\n set(this, name, null);\n } else if (relationship.kind === 'hasMany') {\n var hasMany = this._relationships[relationship.name];\n if (hasMany) { hasMany.clear(); }\n }\n }, this);\n },\n\n /**\n @method updateRecordArrays\n @private\n */\n updateRecordArrays: function() {\n this._updatingRecordArraysLater = false;\n get(this, 'store').dataWasUpdated(this.constructor, this);\n },\n\n /**\n Returns an object, whose keys are changed properties, and value is\n an [oldProp, newProp] array.\n\n Example\n\n ```javascript\n App.Mascot = DS.Model.extend({\n name: attr('string')\n });\n\n var person = store.createRecord('person');\n person.changedAttributes(); // {}\n person.set('name', 'Tomster');\n person.changedAttributes(); // {name: [undefined, 'Tomster']}\n ```\n\n @method changedAttributes\n @return {Object} an object, whose keys are changed properties,\n and value is an [oldProp, newProp] array.\n */\n changedAttributes: function() {\n var oldData = get(this, '_data'),\n newData = get(this, '_attributes'),\n diffData = {},\n prop;\n\n for (prop in newData) {\n diffData[prop] = [oldData[prop], newData[prop]];\n }\n\n return diffData;\n },\n\n /**\n @method adapterWillCommit\n @private\n */\n adapterWillCommit: function() {\n this.send('willCommit');\n },\n\n /**\n If the adapter did not return a hash in response to a commit,\n merge the changed attributes and relationships into the existing\n saved data.\n\n @method adapterDidCommit\n */\n adapterDidCommit: function(data) {\n set(this, 'isError', false);\n\n if (data) {\n this._data = data;\n } else {\n Ember.mixin(this._data, this._inFlightAttributes);\n }\n\n this._inFlightAttributes = {};\n\n this.send('didCommit');\n this.updateRecordArraysLater();\n\n if (!data) { return; }\n\n this.suspendRelationshipObservers(function() {\n this.notifyPropertyChange('data');\n });\n },\n\n /**\n @method adapterDidDirty\n @private\n */\n adapterDidDirty: function() {\n this.send('becomeDirty');\n this.updateRecordArraysLater();\n },\n\n dataDidChange: Ember.observer(function() {\n this.reloadHasManys();\n }, 'data'),\n\n reloadHasManys: function() {\n var relationships = get(this.constructor, 'relationshipsByName');\n this.updateRecordArraysLater();\n relationships.forEach(function(name, relationship) {\n if (this._data.links && this._data.links[name]) { return; }\n if (relationship.kind === 'hasMany') {\n this.hasManyDidChange(relationship.key);\n }\n }, this);\n },\n\n hasManyDidChange: function(key) {\n var hasMany = this._relationships[key];\n\n if (hasMany) {\n var records = this._data[key] || [];\n\n set(hasMany, 'content', Ember.A(records));\n set(hasMany, 'isLoaded', true);\n hasMany.trigger('didLoad');\n }\n },\n\n /**\n @method updateRecordArraysLater\n @private\n */\n updateRecordArraysLater: function() {\n // quick hack (something like this could be pushed into run.once\n if (this._updatingRecordArraysLater) { return; }\n this._updatingRecordArraysLater = true;\n\n Ember.run.schedule('actions', this, this.updateRecordArrays);\n },\n\n /**\n @method setupData\n @private\n @param {Object} data\n @param {Boolean} partial the data should be merged into\n the existing data, not replace it.\n */\n setupData: function(data, partial) {\n if (partial) {\n Ember.merge(this._data, data);\n } else {\n this._data = data;\n }\n\n var relationships = this._relationships;\n\n this.eachRelationship(function(name, rel) {\n if (data.links && data.links[name]) { return; }\n if (rel.options.async) { relationships[name] = null; }\n });\n\n if (data) { this.pushedData(); }\n\n this.suspendRelationshipObservers(function() {\n this.notifyPropertyChange('data');\n });\n },\n\n materializeId: function(id) {\n set(this, 'id', id);\n },\n\n materializeAttributes: function(attributes) {\n Ember.assert(\"Must pass a hash of attributes to materializeAttributes\", !!attributes);\n merge(this._data, attributes);\n },\n\n materializeAttribute: function(name, value) {\n this._data[name] = value;\n },\n\n /**\n @method updateHasMany\n @private\n @param {String} name\n @param {Array} records\n */\n updateHasMany: function(name, records) {\n this._data[name] = records;\n this.hasManyDidChange(name);\n },\n\n /**\n @method updateBelongsTo\n @private\n @param {String} name\n @param {DS.Model} record\n */\n updateBelongsTo: function(name, record) {\n this._data[name] = record;\n },\n\n /**\n If the model `isDirty` this function will discard any unsaved\n changes\n\n Example\n\n ```javascript\n record.get('name'); // 'Untitled Document'\n record.set('name', 'Doc 1');\n record.get('name'); // 'Doc 1'\n record.rollback();\n record.get('name'); // 'Untitled Document'\n ```\n\n @method rollback\n */\n rollback: function() {\n this._attributes = {};\n\n if (get(this, 'isError')) {\n this._inFlightAttributes = {};\n set(this, 'isError', false);\n }\n\n if (!get(this, 'isValid')) {\n this._inFlightAttributes = {};\n }\n\n this.send('rolledBack');\n\n this.suspendRelationshipObservers(function() {\n this.notifyPropertyChange('data');\n });\n },\n\n toStringExtension: function() {\n return get(this, 'id');\n },\n\n /**\n The goal of this method is to temporarily disable specific observers\n that take action in response to application changes.\n\n This allows the system to make changes (such as materialization and\n rollback) that should not trigger secondary behavior (such as setting an\n inverse relationship or marking records as dirty).\n\n The specific implementation will likely change as Ember proper provides\n better infrastructure for suspending groups of observers, and if Array\n observation becomes more unified with regular observers.\n\n @method suspendRelationshipObservers\n @private\n @param callback\n @param binding\n */\n suspendRelationshipObservers: function(callback, binding) {\n var observers = get(this.constructor, 'relationshipNames').belongsTo;\n var self = this;\n\n try {\n this._suspendedRelationships = true;\n Ember._suspendObservers(self, observers, null, 'belongsToDidChange', function() {\n Ember._suspendBeforeObservers(self, observers, null, 'belongsToWillChange', function() {\n callback.call(binding || self);\n });\n });\n } finally {\n this._suspendedRelationships = false;\n }\n },\n\n /**\n Save the record and persist any changes to the record to an\n extenal source via the adapter.\n\n Example\n\n ```javascript\n record.set('name', 'Tomster');\n record.save().then(function(){\n // Success callback\n }, function() {\n // Error callback\n });\n ```\n @method save\n @return {Promise} a promise that will be resolved when the adapter returns\n successfully or rejected if the adapter returns with an error.\n */\n save: function() {\n var promiseLabel = \"DS: Model#save \" + this;\n var resolver = Ember.RSVP.defer(promiseLabel);\n\n this.get('store').scheduleSave(this, resolver);\n this._inFlightAttributes = this._attributes;\n this._attributes = {};\n\n return DS.PromiseObject.create({ promise: resolver.promise });\n },\n\n /**\n Reload the record from the adapter.\n\n This will only work if the record has already finished loading\n and has not yet been modified (`isLoaded` but not `isDirty`,\n or `isSaving`).\n\n Example\n\n ```javascript\n App.ModelViewRoute = Ember.Route.extend({\n actions: {\n reload: function() {\n this.get('model').reload();\n }\n }\n });\n ```\n\n @method reload\n @return {Promise} a promise that will be resolved with the record when the\n adapter returns successfully or rejected if the adapter returns\n with an error.\n */\n reload: function() {\n set(this, 'isReloading', true);\n\n var record = this;\n\n var promiseLabel = \"DS: Model#reload of \" + this;\n var promise = new Ember.RSVP.Promise(function(resolve){\n record.send('reloadRecord', resolve);\n }, promiseLabel).then(function() {\n record.set('isReloading', false);\n record.set('isError', false);\n return record;\n }, function(reason) {\n record.set('isError', true);\n throw reason;\n }, \"DS: Model#reload complete, update flags\");\n\n return DS.PromiseObject.create({ promise: promise });\n },\n\n // FOR USE DURING COMMIT PROCESS\n\n adapterDidUpdateAttribute: function(attributeName, value) {\n\n // If a value is passed in, update the internal attributes and clear\n // the attribute cache so it picks up the new value. Otherwise,\n // collapse the current value into the internal attributes because\n // the adapter has acknowledged it.\n if (value !== undefined) {\n this._data[attributeName] = value;\n this.notifyPropertyChange(attributeName);\n } else {\n this._data[attributeName] = this._inFlightAttributes[attributeName];\n }\n\n this.updateRecordArraysLater();\n },\n\n /**\n @method adapterDidInvalidate\n @private\n */\n adapterDidInvalidate: function(errors) {\n var recordErrors = get(this, 'errors');\n function addError(name) {\n if (errors[name]) {\n recordErrors.add(name, errors[name]);\n }\n }\n\n this.eachAttribute(addError);\n this.eachRelationship(addError);\n },\n\n /**\n @method adapterDidError\n @private\n */\n adapterDidError: function() {\n this.send('becameError');\n set(this, 'isError', true);\n },\n\n /**\n Override the default event firing from Ember.Evented to\n also call methods with the given name.\n\n @method trigger\n @private\n @param name\n */\n trigger: function(name) {\n Ember.tryInvoke(this, name, [].slice.call(arguments, 1));\n this._super.apply(this, arguments);\n },\n\n triggerLater: function() {\n if (this._deferredTriggers.push(arguments) !== 1) { return; }\n Ember.run.schedule('actions', this, '_triggerDeferredTriggers');\n },\n\n _triggerDeferredTriggers: function() {\n for (var i=0, l=this._deferredTriggers.length; i<l; i++) {\n this.trigger.apply(this, this._deferredTriggers[i]);\n }\n\n this._deferredTriggers.length = 0;\n }\n});\n\nDS.Model.reopenClass({\n\n /**\n Alias DS.Model's `create` method to `_create`. This allows us to create DS.Model\n instances from within the store, but if end users accidentally call `create()`\n (instead of `createRecord()`), we can raise an error.\n\n @method _create\n @private\n @static\n */\n _create: DS.Model.create,\n\n /**\n Override the class' `create()` method to raise an error. This\n prevents end users from inadvertently calling `create()` instead\n of `createRecord()`. The store is still able to create instances\n by calling the `_create()` method. To create an instance of a\n `DS.Model` use [store.createRecord](DS.Store.html#method_createRecord).\n\n @method create\n @private\n @static\n */\n create: function() {\n throw new Ember.Error(\"You should not call `create` on a model. Instead, call `store.createRecord` with the attributes you would like to set.\");\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/model/model");minispade.register('ember-data/system/model/states', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\n/*\n This file encapsulates the various states that a record can transition\n through during its lifecycle.\n*/\n/**\n ### State\n\n Each record has a `currentState` property that explicitly tracks what\n state a record is in at any given time. For instance, if a record is\n newly created and has not yet been sent to the adapter to be saved,\n it would be in the `root.loaded.created.uncommitted` state. If a\n record has had local modifications made to it that are in the\n process of being saved, the record would be in the\n `root.loaded.updated.inFlight` state. (These state paths will be\n explained in more detail below.)\n\n Events are sent by the record or its store to the record's\n `currentState` property. How the state reacts to these events is\n dependent on which state it is in. In some states, certain events\n will be invalid and will cause an exception to be raised.\n\n States are hierarchical and every state is a substate of the\n `RootState`. For example, a record can be in the\n `root.deleted.uncommitted` state, then transition into the\n `root.deleted.inFlight` state. If a child state does not implement\n an event handler, the state manager will attempt to invoke the event\n on all parent states until the root state is reached. The state\n hierarchy of a record is described in terms of a path string. You\n can determine a record's current state by getting the state's\n `stateName` property:\n\n ```javascript\n record.get('currentState.stateName');\n //=> \"root.created.uncommitted\"\n ```\n\n The hierarchy of valid states that ship with ember data looks like\n this:\n\n ```text\n * root\n * deleted\n * saved\n * uncommitted\n * inFlight\n * empty\n * loaded\n * created\n * uncommitted\n * inFlight\n * saved\n * updated\n * uncommitted\n * inFlight\n * loading\n ```\n\n The `DS.Model` states are themselves stateless. What we mean is\n that, the hierarchical states that each of *those* points to is a\n shared data structure. For performance reasons, instead of each\n record getting its own copy of the hierarchy of states, each record\n points to this global, immutable shared instance. How does a state\n know which record it should be acting on? We pass the record\n instance into the state's event handlers as the first argument.\n\n The record passed as the first parameter is where you should stash\n state about the record if needed; you should never store data on the state\n object itself.\n\n ### Events and Flags\n\n A state may implement zero or more events and flags.\n\n #### Events\n\n Events are named functions that are invoked when sent to a record. The\n record will first look for a method with the given name on the\n current state. If no method is found, it will search the current\n state's parent, and then its grandparent, and so on until reaching\n the top of the hierarchy. If the root is reached without an event\n handler being found, an exception will be raised. This can be very\n helpful when debugging new features.\n\n Here's an example implementation of a state with a `myEvent` event handler:\n\n ```javascript\n aState: DS.State.create({\n myEvent: function(manager, param) {\n console.log(\"Received myEvent with\", param);\n }\n })\n ```\n\n To trigger this event:\n\n ```javascript\n record.send('myEvent', 'foo');\n //=> \"Received myEvent with foo\"\n ```\n\n Note that an optional parameter can be sent to a record's `send()` method,\n which will be passed as the second parameter to the event handler.\n\n Events should transition to a different state if appropriate. This can be\n done by calling the record's `transitionTo()` method with a path to the\n desired state. The state manager will attempt to resolve the state path\n relative to the current state. If no state is found at that path, it will\n attempt to resolve it relative to the current state's parent, and then its\n parent, and so on until the root is reached. For example, imagine a hierarchy\n like this:\n\n * created\n * uncommitted <-- currentState\n * inFlight\n * updated\n * inFlight\n\n If we are currently in the `uncommitted` state, calling\n `transitionTo('inFlight')` would transition to the `created.inFlight` state,\n while calling `transitionTo('updated.inFlight')` would transition to\n the `updated.inFlight` state.\n\n Remember that *only events* should ever cause a state transition. You should\n never call `transitionTo()` from outside a state's event handler. If you are\n tempted to do so, create a new event and send that to the state manager.\n\n #### Flags\n\n Flags are Boolean values that can be used to introspect a record's current\n state in a more user-friendly way than examining its state path. For example,\n instead of doing this:\n\n ```javascript\n var statePath = record.get('stateManager.currentPath');\n if (statePath === 'created.inFlight') {\n doSomething();\n }\n ```\n\n You can say:\n\n ```javascript\n if (record.get('isNew') && record.get('isSaving')) {\n doSomething();\n }\n ```\n\n If your state does not set a value for a given flag, the value will\n be inherited from its parent (or the first place in the state hierarchy\n where it is defined).\n\n The current set of flags are defined below. If you want to add a new flag,\n in addition to the area below, you will also need to declare it in the\n `DS.Model` class.\n\n\n * [isEmpty](DS.Model.html#property_isEmpty)\n * [isLoading](DS.Model.html#property_isLoading)\n * [isLoaded](DS.Model.html#property_isLoaded)\n * [isDirty](DS.Model.html#property_isDirty)\n * [isSaving](DS.Model.html#property_isSaving)\n * [isDeleted](DS.Model.html#property_isDeleted)\n * [isNew](DS.Model.html#property_isNew)\n * [isValid](DS.Model.html#property_isValid)\n\n @namespace DS\n @class RootState\n*/\n\nvar hasDefinedProperties = function(object) {\n // Ignore internal property defined by simulated `Ember.create`.\n var names = Ember.keys(object);\n var i, l, name;\n for (i = 0, l = names.length; i < l; i++ ) {\n name = names[i];\n if (object.hasOwnProperty(name) && object[name]) { return true; }\n }\n\n return false;\n};\n\nvar didSetProperty = function(record, context) {\n if (context.value === context.originalValue) {\n delete record._attributes[context.name];\n record.send('propertyWasReset', context.name);\n } else if (context.value !== context.oldValue) {\n record.send('becomeDirty');\n }\n\n record.updateRecordArraysLater();\n};\n\n// Implementation notes:\n//\n// Each state has a boolean value for all of the following flags:\n//\n// * isLoaded: The record has a populated `data` property. When a\n// record is loaded via `store.find`, `isLoaded` is false\n// until the adapter sets it. When a record is created locally,\n// its `isLoaded` property is always true.\n// * isDirty: The record has local changes that have not yet been\n// saved by the adapter. This includes records that have been\n// created (but not yet saved) or deleted.\n// * isSaving: The record has been committed, but\n// the adapter has not yet acknowledged that the changes have\n// been persisted to the backend.\n// * isDeleted: The record was marked for deletion. When `isDeleted`\n// is true and `isDirty` is true, the record is deleted locally\n// but the deletion was not yet persisted. When `isSaving` is\n// true, the change is in-flight. When both `isDirty` and\n// `isSaving` are false, the change has persisted.\n// * isError: The adapter reported that it was unable to save\n// local changes to the backend. This may also result in the\n// record having its `isValid` property become false if the\n// adapter reported that server-side validations failed.\n// * isNew: The record was created on the client and the adapter\n// did not yet report that it was successfully saved.\n// * isValid: No client-side validations have failed and the\n// adapter did not report any server-side validation failures.\n\n// The dirty state is a abstract state whose functionality is\n// shared between the `created` and `updated` states.\n//\n// The deleted state shares the `isDirty` flag with the\n// subclasses of `DirtyState`, but with a very different\n// implementation.\n//\n// Dirty states have three child states:\n//\n// `uncommitted`: the store has not yet handed off the record\n// to be saved.\n// `inFlight`: the store has handed off the record to be saved,\n// but the adapter has not yet acknowledged success.\n// `invalid`: the record has invalid information and cannot be\n// send to the adapter yet.\nvar DirtyState = {\n initialState: 'uncommitted',\n\n // FLAGS\n isDirty: true,\n\n // SUBSTATES\n\n // When a record first becomes dirty, it is `uncommitted`.\n // This means that there are local pending changes, but they\n // have not yet begun to be saved, and are not invalid.\n uncommitted: {\n // EVENTS\n didSetProperty: didSetProperty,\n\n propertyWasReset: function(record, name) {\n var stillDirty = false;\n\n for (var prop in record._attributes) {\n stillDirty = true;\n break;\n }\n\n if (!stillDirty) { record.send('rolledBack'); }\n },\n\n pushedData: Ember.K,\n\n becomeDirty: Ember.K,\n\n willCommit: function(record) {\n record.transitionTo('inFlight');\n },\n\n reloadRecord: function(record, resolve) {\n resolve(get(record, 'store').reloadRecord(record));\n },\n\n rolledBack: function(record) {\n record.transitionTo('loaded.saved');\n },\n\n becameInvalid: function(record) {\n record.transitionTo('invalid');\n },\n\n rollback: function(record) {\n record.rollback();\n }\n },\n\n // Once a record has been handed off to the adapter to be\n // saved, it is in the 'in flight' state. Changes to the\n // record cannot be made during this window.\n inFlight: {\n // FLAGS\n isSaving: true,\n\n // EVENTS\n didSetProperty: didSetProperty,\n becomeDirty: Ember.K,\n pushedData: Ember.K,\n\n // TODO: More robust semantics around save-while-in-flight\n willCommit: Ember.K,\n\n didCommit: function(record) {\n var dirtyType = get(this, 'dirtyType');\n\n record.transitionTo('saved');\n record.send('invokeLifecycleCallbacks', dirtyType);\n },\n\n becameInvalid: function(record) {\n record.transitionTo('invalid');\n record.send('invokeLifecycleCallbacks');\n },\n\n becameError: function(record) {\n record.transitionTo('uncommitted');\n record.triggerLater('becameError', record);\n }\n },\n\n // A record is in the `invalid` state when its client-side\n // invalidations have failed, or if the adapter has indicated\n // the the record failed server-side invalidations.\n invalid: {\n // FLAGS\n isValid: false,\n\n // EVENTS\n deleteRecord: function(record) {\n record.transitionTo('deleted.uncommitted');\n record.clearRelationships();\n },\n\n didSetProperty: function(record, context) {\n get(record, 'errors').remove(context.name);\n\n didSetProperty(record, context);\n },\n\n becomeDirty: Ember.K,\n\n rolledBack: function(record) {\n get(record, 'errors').clear();\n },\n\n becameValid: function(record) {\n record.transitionTo('uncommitted');\n },\n\n invokeLifecycleCallbacks: function(record) {\n record.triggerLater('becameInvalid', record);\n }\n }\n};\n\n// The created and updated states are created outside the state\n// chart so we can reopen their substates and add mixins as\n// necessary.\n\nfunction deepClone(object) {\n var clone = {}, value;\n\n for (var prop in object) {\n value = object[prop];\n if (value && typeof value === 'object') {\n clone[prop] = deepClone(value);\n } else {\n clone[prop] = value;\n }\n }\n\n return clone;\n}\n\nfunction mixin(original, hash) {\n for (var prop in hash) {\n original[prop] = hash[prop];\n }\n\n return original;\n}\n\nfunction dirtyState(options) {\n var newState = deepClone(DirtyState);\n return mixin(newState, options);\n}\n\nvar createdState = dirtyState({\n dirtyType: 'created',\n\n // FLAGS\n isNew: true\n});\n\ncreatedState.uncommitted.rolledBack = function(record) {\n record.transitionTo('deleted.saved');\n};\n\nvar updatedState = dirtyState({\n dirtyType: 'updated'\n});\n\ncreatedState.uncommitted.deleteRecord = function(record) {\n record.clearRelationships();\n record.transitionTo('deleted.saved');\n};\n\ncreatedState.uncommitted.rollback = function(record) {\n DirtyState.uncommitted.rollback.apply(this, arguments);\n record.transitionTo('deleted.saved');\n};\n\ncreatedState.uncommitted.propertyWasReset = Ember.K;\n\nupdatedState.uncommitted.deleteRecord = function(record) {\n record.transitionTo('deleted.uncommitted');\n record.clearRelationships();\n};\n\nvar RootState = {\n // FLAGS\n isEmpty: false,\n isLoading: false,\n isLoaded: false,\n isDirty: false,\n isSaving: false,\n isDeleted: false,\n isNew: false,\n isValid: true,\n\n // DEFAULT EVENTS\n\n // Trying to roll back if you're not in the dirty state\n // doesn't change your state. For example, if you're in the\n // in-flight state, rolling back the record doesn't move\n // you out of the in-flight state.\n rolledBack: Ember.K,\n\n propertyWasReset: Ember.K,\n\n // SUBSTATES\n\n // A record begins its lifecycle in the `empty` state.\n // If its data will come from the adapter, it will\n // transition into the `loading` state. Otherwise, if\n // the record is being created on the client, it will\n // transition into the `created` state.\n empty: {\n isEmpty: true,\n\n // EVENTS\n loadingData: function(record, promise) {\n record._loadingPromise = promise;\n record.transitionTo('loading');\n },\n\n loadedData: function(record) {\n record.transitionTo('loaded.created.uncommitted');\n\n record.suspendRelationshipObservers(function() {\n record.notifyPropertyChange('data');\n });\n },\n\n pushedData: function(record) {\n record.transitionTo('loaded.saved');\n record.triggerLater('didLoad');\n }\n },\n\n // A record enters this state when the store asks\n // the adapter for its data. It remains in this state\n // until the adapter provides the requested data.\n //\n // Usually, this process is asynchronous, using an\n // XHR to retrieve the data.\n loading: {\n // FLAGS\n isLoading: true,\n\n exit: function(record) {\n record._loadingPromise = null;\n },\n\n // EVENTS\n pushedData: function(record) {\n record.transitionTo('loaded.saved');\n record.triggerLater('didLoad');\n set(record, 'isError', false);\n },\n\n becameError: function(record) {\n record.triggerLater('becameError', record);\n },\n\n notFound: function(record) {\n record.transitionTo('empty');\n }\n },\n\n // A record enters this state when its data is populated.\n // Most of a record's lifecycle is spent inside substates\n // of the `loaded` state.\n loaded: {\n initialState: 'saved',\n\n // FLAGS\n isLoaded: true,\n\n // SUBSTATES\n\n // If there are no local changes to a record, it remains\n // in the `saved` state.\n saved: {\n setup: function(record) {\n var attrs = record._attributes,\n isDirty = false;\n\n for (var prop in attrs) {\n if (attrs.hasOwnProperty(prop)) {\n isDirty = true;\n break;\n }\n }\n\n if (isDirty) {\n record.adapterDidDirty();\n }\n },\n\n // EVENTS\n didSetProperty: didSetProperty,\n\n pushedData: Ember.K,\n\n becomeDirty: function(record) {\n record.transitionTo('updated.uncommitted');\n },\n\n willCommit: function(record) {\n record.transitionTo('updated.inFlight');\n },\n\n reloadRecord: function(record, resolve) {\n resolve(get(record, 'store').reloadRecord(record));\n },\n\n deleteRecord: function(record) {\n record.transitionTo('deleted.uncommitted');\n record.clearRelationships();\n },\n\n unloadRecord: function(record) {\n // clear relationships before moving to deleted state\n // otherwise it fails\n record.clearRelationships();\n record.transitionTo('deleted.saved');\n },\n\n didCommit: function(record) {\n record.send('invokeLifecycleCallbacks', get(record, 'lastDirtyType'));\n },\n\n // loaded.saved.notFound would be triggered by a failed\n // `reload()` on an unchanged record\n notFound: Ember.K\n\n },\n\n // A record is in this state after it has been locally\n // created but before the adapter has indicated that\n // it has been saved.\n created: createdState,\n\n // A record is in this state if it has already been\n // saved to the server, but there are new local changes\n // that have not yet been saved.\n updated: updatedState\n },\n\n // A record is in this state if it was deleted from the store.\n deleted: {\n initialState: 'uncommitted',\n dirtyType: 'deleted',\n\n // FLAGS\n isDeleted: true,\n isLoaded: true,\n isDirty: true,\n\n // TRANSITIONS\n setup: function(record) {\n record.updateRecordArrays();\n },\n\n // SUBSTATES\n\n // When a record is deleted, it enters the `start`\n // state. It will exit this state when the record\n // starts to commit.\n uncommitted: {\n\n // EVENTS\n\n willCommit: function(record) {\n record.transitionTo('inFlight');\n },\n\n rollback: function(record) {\n record.rollback();\n },\n\n becomeDirty: Ember.K,\n deleteRecord: Ember.K,\n\n rolledBack: function(record) {\n record.transitionTo('loaded.saved');\n }\n },\n\n // After a record starts committing, but\n // before the adapter indicates that the deletion\n // has saved to the server, a record is in the\n // `inFlight` substate of `deleted`.\n inFlight: {\n // FLAGS\n isSaving: true,\n\n // EVENTS\n\n // TODO: More robust semantics around save-while-in-flight\n willCommit: Ember.K,\n didCommit: function(record) {\n record.transitionTo('saved');\n\n record.send('invokeLifecycleCallbacks');\n },\n\n becameError: function(record) {\n record.transitionTo('uncommitted');\n record.triggerLater('becameError', record);\n }\n },\n\n // Once the adapter indicates that the deletion has\n // been saved, the record enters the `saved` substate\n // of `deleted`.\n saved: {\n // FLAGS\n isDirty: false,\n\n setup: function(record) {\n var store = get(record, 'store');\n store.dematerializeRecord(record);\n },\n\n invokeLifecycleCallbacks: function(record) {\n record.triggerLater('didDelete', record);\n record.triggerLater('didCommit', record);\n }\n }\n },\n\n invokeLifecycleCallbacks: function(record, dirtyType) {\n if (dirtyType === 'created') {\n record.triggerLater('didCreate', record);\n } else {\n record.triggerLater('didUpdate', record);\n }\n\n record.triggerLater('didCommit', record);\n }\n};\n\nfunction wireState(object, parent, name) {\n /*jshint proto:true*/\n // TODO: Use Object.create and copy instead\n object = mixin(parent ? Ember.create(parent) : {}, object);\n object.parentState = parent;\n object.stateName = name;\n\n for (var prop in object) {\n if (!object.hasOwnProperty(prop) || prop === 'parentState' || prop === 'stateName') { continue; }\n if (typeof object[prop] === 'object') {\n object[prop] = wireState(object[prop], object, name + \".\" + prop);\n }\n }\n\n return object;\n}\n\nRootState = wireState(RootState, null, \"root\");\n\nDS.RootState = RootState;\n\n})();\n//@ sourceURL=ember-data/system/model/states");minispade.register('ember-data/system/record_array_manager', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar forEach = Ember.EnumerableUtils.forEach;\n\n/**\n @class RecordArrayManager\n @namespace DS\n @private\n @extends Ember.Object\n*/\nDS.RecordArrayManager = Ember.Object.extend({\n init: function() {\n this.filteredRecordArrays = Ember.MapWithDefault.create({\n defaultValue: function() { return []; }\n });\n\n this.changedRecords = [];\n },\n\n recordDidChange: function(record) {\n if (this.changedRecords.push(record) !== 1) { return; }\n\n Ember.run.schedule('actions', this, this.updateRecordArrays);\n },\n\n recordArraysForRecord: function(record) {\n record._recordArrays = record._recordArrays || Ember.OrderedSet.create();\n return record._recordArrays;\n },\n\n /**\n This method is invoked whenever data is loaded into the store by the\n adapter or updated by the adapter, or when a record has changed.\n\n It updates all record arrays that a record belongs to.\n\n To avoid thrashing, it only runs at most once per run loop.\n\n @method updateRecordArrays\n @param {Class} type\n @param {Number|String} clientId\n */\n updateRecordArrays: function() {\n forEach(this.changedRecords, function(record) {\n if (get(record, 'isDeleted')) {\n this._recordWasDeleted(record);\n } else {\n this._recordWasChanged(record);\n }\n }, this);\n\n this.changedRecords.length = 0;\n },\n\n _recordWasDeleted: function (record) {\n var recordArrays = record._recordArrays;\n\n if (!recordArrays) { return; }\n\n forEach(recordArrays, function(array) {\n array.removeRecord(record);\n });\n },\n\n _recordWasChanged: function (record) {\n var type = record.constructor,\n recordArrays = this.filteredRecordArrays.get(type),\n filter;\n\n forEach(recordArrays, function(array) {\n filter = get(array, 'filterFunction');\n this.updateRecordArray(array, filter, type, record);\n }, this);\n\n // loop through all manyArrays containing an unloaded copy of this\n // clientId and notify them that the record was loaded.\n var manyArrays = record._loadingRecordArrays;\n\n if (manyArrays) {\n for (var i=0, l=manyArrays.length; i<l; i++) {\n manyArrays[i].loadedRecord();\n }\n\n record._loadingRecordArrays = [];\n }\n },\n\n /**\n Update an individual filter.\n\n @method updateRecordArray\n @param {DS.FilteredRecordArray} array\n @param {Function} filter\n @param {Class} type\n @param {Number|String} clientId\n */\n updateRecordArray: function(array, filter, type, record) {\n var shouldBeInArray;\n\n if (!filter) {\n shouldBeInArray = true;\n } else {\n shouldBeInArray = filter(record);\n }\n\n var recordArrays = this.recordArraysForRecord(record);\n\n if (shouldBeInArray) {\n recordArrays.add(array);\n array.addRecord(record);\n } else if (!shouldBeInArray) {\n recordArrays.remove(array);\n array.removeRecord(record);\n }\n },\n\n /**\n This method is invoked if the `filterFunction` property is\n changed on a `DS.FilteredRecordArray`.\n\n It essentially re-runs the filter from scratch. This same\n method is invoked when the filter is created in th first place.\n\n @method updateFilter\n @param array\n @param type\n @param filter\n */\n updateFilter: function(array, type, filter) {\n var typeMap = this.store.typeMapFor(type),\n records = typeMap.records, record;\n\n for (var i=0, l=records.length; i<l; i++) {\n record = records[i];\n\n if (!get(record, 'isDeleted') && !get(record, 'isEmpty')) {\n this.updateRecordArray(array, filter, type, record);\n }\n }\n },\n\n /**\n Create a `DS.ManyArray` for a type and list of record references, and index\n the `ManyArray` under each reference. This allows us to efficiently remove\n records from `ManyArray`s when they are deleted.\n\n @method createManyArray\n @param {Class} type\n @param {Array} references\n @return {DS.ManyArray}\n */\n createManyArray: function(type, records) {\n var manyArray = DS.ManyArray.create({\n type: type,\n content: records,\n store: this.store\n });\n\n forEach(records, function(record) {\n var arrays = this.recordArraysForRecord(record);\n arrays.add(manyArray);\n }, this);\n\n return manyArray;\n },\n\n /**\n Create a `DS.RecordArray` for a type and register it for updates.\n\n @method createRecordArray\n @param {Class} type\n @return {DS.RecordArray}\n */\n createRecordArray: function(type) {\n var array = DS.RecordArray.create({\n type: type,\n content: Ember.A(),\n store: this.store,\n isLoaded: true\n });\n\n this.registerFilteredRecordArray(array, type);\n\n return array;\n },\n\n /**\n Create a `DS.FilteredRecordArray` for a type and register it for updates.\n\n @method createFilteredRecordArray\n @param {Class} type\n @param {Function} filter\n @return {DS.FilteredRecordArray}\n */\n createFilteredRecordArray: function(type, filter) {\n var array = DS.FilteredRecordArray.create({\n type: type,\n content: Ember.A(),\n store: this.store,\n manager: this,\n filterFunction: filter\n });\n\n this.registerFilteredRecordArray(array, type, filter);\n\n return array;\n },\n\n /**\n Create a `DS.AdapterPopulatedRecordArray` for a type with given query.\n\n @method createAdapterPopulatedRecordArray\n @param {Class} type\n @param {Object} query\n @return {DS.AdapterPopulatedRecordArray}\n */\n createAdapterPopulatedRecordArray: function(type, query) {\n return DS.AdapterPopulatedRecordArray.create({\n type: type,\n query: query,\n content: Ember.A(),\n store: this.store\n });\n },\n\n /**\n Register a RecordArray for a given type to be backed by\n a filter function. This will cause the array to update\n automatically when records of that type change attribute\n values or states.\n\n @method registerFilteredRecordArray\n @param {DS.RecordArray} array\n @param {Class} type\n @param {Function} filter\n */\n registerFilteredRecordArray: function(array, type, filter) {\n var recordArrays = this.filteredRecordArrays.get(type);\n recordArrays.push(array);\n\n this.updateFilter(array, type, filter);\n },\n\n // Internally, we maintain a map of all unloaded IDs requested by\n // a ManyArray. As the adapter loads data into the store, the\n // store notifies any interested ManyArrays. When the ManyArray's\n // total number of loading records drops to zero, it becomes\n // `isLoaded` and fires a `didLoad` event.\n registerWaitingRecordArray: function(record, array) {\n var loadingRecordArrays = record._loadingRecordArrays || [];\n loadingRecordArrays.push(array);\n record._loadingRecordArrays = loadingRecordArrays;\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/record_array_manager");minispade.register('ember-data/system/record_arrays', "(function() {/**\n @module ember-data\n*/\nminispade.require('ember-data/system/record_arrays/record_array');\nminispade.require('ember-data/system/record_arrays/filtered_record_array');\nminispade.require('ember-data/system/record_arrays/adapter_populated_record_array');\nminispade.require('ember-data/system/record_arrays/many_array');\n\n})();\n//@ sourceURL=ember-data/system/record_arrays");minispade.register('ember-data/system/record_arrays/adapter_populated_record_array', "(function() {minispade.require(\"ember-data/system/record_arrays/record_array\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n Represents an ordered list of records whose order and membership is\n determined by the adapter. For example, a query sent to the adapter\n may trigger a search on the server, whose results would be loaded\n into an instance of the `AdapterPopulatedRecordArray`.\n\n @class AdapterPopulatedRecordArray\n @namespace DS\n @extends DS.RecordArray\n*/\nDS.AdapterPopulatedRecordArray = DS.RecordArray.extend({\n query: null,\n\n replace: function() {\n var type = get(this, 'type').toString();\n throw new Error(\"The result of a server query (on \" + type + \") is immutable.\");\n },\n\n /**\n @method load\n @private\n @param {Array} data\n */\n load: function(data) {\n var store = get(this, 'store'),\n type = get(this, 'type'),\n records = store.pushMany(type, data),\n meta = store.metadataFor(type);\n\n this.setProperties({\n content: Ember.A(records),\n isLoaded: true,\n meta: meta\n });\n\n // TODO: does triggering didLoad event should be the last action of the runLoop?\n Ember.run.once(this, 'trigger', 'didLoad');\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/adapter_populated_record_array");minispade.register('ember-data/system/record_arrays/filtered_record_array', "(function() {minispade.require(\"ember-data/system/record_arrays/record_array\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get;\n\n/**\n Represents a list of records whose membership is determined by the\n store. As records are created, loaded, or modified, the store\n evaluates them to determine if they should be part of the record\n array.\n\n @class FilteredRecordArray\n @namespace DS\n @extends DS.RecordArray\n*/\nDS.FilteredRecordArray = DS.RecordArray.extend({\n /**\n The filterFunction is a function used to test records from the store to\n determine if they should be part of the record array.\n\n Example\n\n ```javascript\n var allPeople = store.all('person');\n allPeople.mapBy('name'); // [\"Tom Dale\", \"Yehuda Katz\", \"Trek Glowacki\"]\n\n var people = store.filter('person', function(person) {\n if (person.get('name').match(/Katz$/)) { return true; }\n });\n people.mapBy('name'); // [\"Yehuda Katz\"]\n\n var notKatzFilter = function(person) {\n return !person.get('name').match(/Katz$/);\n };\n people.set('filterFunction', notKatzFilter);\n people.mapBy('name'); // [\"Tom Dale\", \"Trek Glowacki\"]\n ```\n\n @method filterFunction\n @param {DS.Model} record\n @return {Boolean} `true` if the record should be in the array\n */\n filterFunction: null,\n isLoaded: true,\n\n replace: function() {\n var type = get(this, 'type').toString();\n throw new Error(\"The result of a client-side filter (on \" + type + \") is immutable.\");\n },\n\n /**\n @method updateFilter\n @private\n */\n updateFilter: Ember.observer(function() {\n var manager = get(this, 'manager');\n manager.updateFilter(this, get(this, 'type'), get(this, 'filterFunction'));\n }, 'filterFunction')\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/filtered_record_array");minispade.register('ember-data/system/record_arrays/many_array', "(function() {minispade.require(\"ember-data/system/record_arrays/record_array\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar map = Ember.EnumerableUtils.map;\n\n/**\n A `ManyArray` is a `RecordArray` that represents the contents of a has-many\n relationship.\n\n The `ManyArray` is instantiated lazily the first time the relationship is\n requested.\n\n ### Inverses\n\n Often, the relationships in Ember Data applications will have\n an inverse. For example, imagine the following models are\n defined:\n\n ```javascript\n App.Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n App.Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n ```\n\n If you created a new instance of `App.Post` and added\n a `App.Comment` record to its `comments` has-many\n relationship, you would expect the comment's `post`\n property to be set to the post that contained\n the has-many.\n\n We call the record to which a relationship belongs the\n relationship's _owner_.\n\n @class ManyArray\n @namespace DS\n @extends DS.RecordArray\n*/\nDS.ManyArray = DS.RecordArray.extend({\n init: function() {\n this._super.apply(this, arguments);\n this._changesToSync = Ember.OrderedSet.create();\n },\n\n /**\n The property name of the relationship\n\n @property {String} name\n @private\n */\n name: null,\n\n /**\n The record to which this relationship belongs.\n\n @property {DS.Model} owner\n @private\n */\n owner: null,\n\n /**\n `true` if the relationship is polymorphic, `false` otherwise.\n\n @property {Boolean} isPolymorphic\n @private\n */\n isPolymorphic: false,\n\n // LOADING STATE\n\n isLoaded: false,\n\n /**\n Used for async `hasMany` arrays\n to keep track of when they will resolve.\n\n @property {Ember.RSVP.Promise} promise\n @private\n */\n promise: null,\n\n /**\n @method loadingRecordsCount\n @param {Number} count\n @private\n */\n loadingRecordsCount: function(count) {\n this.loadingRecordsCount = count;\n },\n\n /**\n @method loadedRecord\n @private\n */\n loadedRecord: function() {\n this.loadingRecordsCount--;\n if (this.loadingRecordsCount === 0) {\n set(this, 'isLoaded', true);\n this.trigger('didLoad');\n }\n },\n\n /**\n @method fetch\n @private\n */\n fetch: function() {\n var records = get(this, 'content'),\n store = get(this, 'store'),\n owner = get(this, 'owner'),\n resolver = Ember.RSVP.defer(\"DS: ManyArray#fetch \" + get(this, 'type'));\n\n var unloadedRecords = records.filterProperty('isEmpty', true);\n store.fetchMany(unloadedRecords, owner, resolver);\n },\n\n // Overrides Ember.Array's replace method to implement\n replaceContent: function(index, removed, added) {\n // Map the array of record objects into an array of client ids.\n added = map(added, function(record) {\n Ember.assert(\"You cannot add '\" + record.constructor.typeKey + \"' records to this relationship (only '\" + this.type.typeKey + \"' allowed)\", !this.type || record instanceof this.type);\n return record;\n }, this);\n\n this._super(index, removed, added);\n },\n\n arrangedContentDidChange: function() {\n Ember.run.once(this, 'fetch');\n },\n\n arrayContentWillChange: function(index, removed, added) {\n var owner = get(this, 'owner'),\n name = get(this, 'name');\n\n if (!owner._suspendedRelationships) {\n // This code is the first half of code that continues inside\n // of arrayContentDidChange. It gets or creates a change from\n // the child object, adds the current owner as the old\n // parent if this is the first time the object was removed\n // from a ManyArray, and sets `newParent` to null.\n //\n // Later, if the object is added to another ManyArray,\n // the `arrayContentDidChange` will set `newParent` on\n // the change.\n for (var i=index; i<index+removed; i++) {\n var record = get(this, 'content').objectAt(i);\n\n var change = DS.RelationshipChange.createChange(owner, record, get(this, 'store'), {\n parentType: owner.constructor,\n changeType: \"remove\",\n kind: \"hasMany\",\n key: name\n });\n\n this._changesToSync.add(change);\n }\n }\n\n return this._super.apply(this, arguments);\n },\n\n arrayContentDidChange: function(index, removed, added) {\n this._super.apply(this, arguments);\n\n var owner = get(this, 'owner'),\n name = get(this, 'name'),\n store = get(this, 'store');\n\n if (!owner._suspendedRelationships) {\n // This code is the second half of code that started in\n // `arrayContentWillChange`. It gets or creates a change\n // from the child object, and adds the current owner as\n // the new parent.\n for (var i=index; i<index+added; i++) {\n var record = get(this, 'content').objectAt(i);\n\n var change = DS.RelationshipChange.createChange(owner, record, store, {\n parentType: owner.constructor,\n changeType: \"add\",\n kind:\"hasMany\",\n key: name\n });\n change.hasManyName = name;\n\n this._changesToSync.add(change);\n }\n\n // We wait until the array has finished being\n // mutated before syncing the OneToManyChanges created\n // in arrayContentWillChange, so that the array\n // membership test in the sync() logic operates\n // on the final results.\n this._changesToSync.forEach(function(change) {\n change.sync();\n });\n\n this._changesToSync.clear();\n }\n },\n\n /**\n Create a child record within the owner\n\n @method createRecord\n @private\n @param {Object} hash\n @return {DS.Model} record\n */\n createRecord: function(hash) {\n var owner = get(this, 'owner'),\n store = get(owner, 'store'),\n type = get(this, 'type'),\n record;\n\n Ember.assert(\"You cannot add '\" + type.typeKey + \"' records to this polymorphic relationship.\", !get(this, 'isPolymorphic'));\n\n record = store.createRecord.call(store, type, hash);\n this.pushObject(record);\n\n return record;\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/many_array");minispade.register('ember-data/system/record_arrays/record_array', "(function() {/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n A record array is an array that contains records of a certain type. The record\n array materializes records as needed when they are retrieved for the first\n time. You should not create record arrays yourself. Instead, an instance of\n `DS.RecordArray` or its subclasses will be returned by your application's store\n in response to queries.\n\n @class RecordArray\n @namespace DS\n @extends Ember.ArrayProxy\n @uses Ember.Evented\n*/\n\nDS.RecordArray = Ember.ArrayProxy.extend(Ember.Evented, {\n /**\n The model type contained by this record array.\n\n @property type\n @type DS.Model\n */\n type: null,\n\n /**\n The array of client ids backing the record array. When a\n record is requested from the record array, the record\n for the client id at the same index is materialized, if\n necessary, by the store.\n\n @property content\n @private\n @type Ember.Array\n */\n content: null,\n\n /**\n The flag to signal a `RecordArray` is currently loading data.\n\n Example\n\n ```javascript\n var people = store.all(App.Person);\n people.get('isLoaded'); // true\n ```\n\n @property isLoaded\n @type Boolean\n */\n isLoaded: false,\n /**\n The flag to signal a `RecordArray` is currently loading data.\n\n Example\n\n ```javascript\n var people = store.all(App.Person);\n people.get('isUpdating'); // false\n people.update();\n people.get('isUpdating'); // true\n ```\n\n @property isUpdating\n @type Boolean\n */\n isUpdating: false,\n\n /**\n The store that created this record array.\n\n @property store\n @private\n @type DS.Store\n */\n store: null,\n\n /**\n Retrieves an object from the content by index.\n\n @method objectAtContent\n @private\n @param {Number} index\n @return {DS.Model} record\n */\n objectAtContent: function(index) {\n var content = get(this, 'content');\n\n return content.objectAt(index);\n },\n\n /**\n Used to get the latest version of all of the records in this array\n from the adapter.\n\n Example\n\n ```javascript\n var people = store.all(App.Person);\n people.get('isUpdating'); // false\n people.update();\n people.get('isUpdating'); // true\n ```\n\n @method update\n */\n update: function() {\n if (get(this, 'isUpdating')) { return; }\n\n var store = get(this, 'store'),\n type = get(this, 'type');\n\n return store.fetchAll(type, this);\n },\n\n /**\n Adds a record to the `RecordArray`.\n\n @method addRecord\n @private\n @param {DS.Model} record\n */\n addRecord: function(record) {\n get(this, 'content').addObject(record);\n },\n\n /**\n Removes a record to the `RecordArray`.\n\n @method removeRecord\n @private\n @param {DS.Model} record\n */\n removeRecord: function(record) {\n get(this, 'content').removeObject(record);\n },\n\n /**\n Saves all of the records in the `RecordArray`.\n\n Example\n\n ```javascript\n var messages = store.all(App.Message);\n messages.forEach(function(message) {\n message.set('hasBeenSeen', true);\n });\n messages.save();\n ```\n\n @method save\n @return {DS.PromiseArray} promise\n */\n save: function() {\n var promiseLabel = \"DS: RecordArray#save \" + get(this, 'type');\n var promise = Ember.RSVP.all(this.invoke(\"save\"), promiseLabel).then(function(array) {\n return Ember.A(array);\n }, null, \"DS: RecordArray#save apply Ember.NativeArray\");\n\n return DS.PromiseArray.create({ promise: promise });\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/record_array");minispade.register('ember-data/system/relationships', "(function() {/**\n @module ember-data\n*/\nminispade.require(\"ember-data/system/relationships/belongs_to\");\nminispade.require(\"ember-data/system/relationships/has_many\");\nminispade.require(\"ember-data/system/relationships/ext\");\n\n})();\n//@ sourceURL=ember-data/system/relationships");minispade.register('ember-data/system/relationships/belongs_to', "(function() {var get = Ember.get, set = Ember.set,\n isNone = Ember.isNone;\n\n/**\n @module ember-data\n*/\n\nfunction asyncBelongsTo(type, options, meta) {\n return Ember.computed(function(key, value) {\n var data = get(this, 'data'),\n store = get(this, 'store'),\n promiseLabel = \"DS: Async belongsTo \" + this + \" : \" + key;\n\n if (arguments.length === 2) {\n Ember.assert(\"You can only add a '\" + type + \"' record to this relationship\", !value || value instanceof store.modelFor(type));\n return value === undefined ? null : DS.PromiseObject.create({ promise: Ember.RSVP.resolve(value, promiseLabel) });\n }\n\n var link = data.links && data.links[key],\n belongsTo = data[key];\n\n if(!isNone(belongsTo)) {\n var promise = store.fetchRecord(belongsTo) || Ember.RSVP.resolve(belongsTo, promiseLabel);\n return DS.PromiseObject.create({ promise: promise});\n } else if (link) {\n var resolver = Ember.RSVP.defer(\"DS: Async belongsTo (link) \" + this + \" : \" + key);\n store.findBelongsTo(this, link, meta, resolver);\n return DS.PromiseObject.create({ promise: resolver.promise });\n } else {\n return null;\n }\n }).property('data').meta(meta);\n}\n\n/**\n `DS.belongsTo` is used to define One-To-One and One-To-Many\n relationships on a [DS.Model](DS.Model.html).\n\n\n `DS.belongsTo` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `async`: A boolean value used to explicitly declare this to be an async relationship.\n - `inverse`: A string used to identify the inverse property on a\n related model in a One-To-Many relationship. See [Explicit Inverses](#toc_explicit-inverses)\n\n #### One-To-One\n To declare a one-to-one relationship between two models, use\n `DS.belongsTo`:\n\n ```javascript\n App.User = DS.Model.extend({\n profile: DS.belongsTo('profile')\n });\n\n App.Profile = DS.Model.extend({\n user: DS.belongsTo('user')\n });\n ```\n\n #### One-To-Many\n To declare a one-to-many relationship between two models, use\n `DS.belongsTo` in combination with `DS.hasMany`, like this:\n\n ```javascript\n App.Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n App.Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n ```\n\n @namespace\n @method belongsTo\n @for DS\n @param {String or DS.Model} type the model type of the relationship\n @param {Object} options a hash of options\n @return {Ember.computed} relationship\n*/\nDS.belongsTo = function(type, options) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n } else {\n Ember.assert(\"The first argument DS.belongsTo must be a model type or string, like DS.belongsTo(App.Person)\", !!type && (typeof type === 'string' || DS.Model.detect(type)));\n }\n\n options = options || {};\n\n var meta = { type: type, isRelationship: true, options: options, kind: 'belongsTo' };\n\n if (options.async) {\n return asyncBelongsTo(type, options, meta);\n }\n\n return Ember.computed(function(key, value) {\n var data = get(this, 'data'),\n store = get(this, 'store'), belongsTo, typeClass;\n\n if (typeof type === 'string') {\n typeClass = store.modelFor(type);\n } else {\n typeClass = type;\n }\n\n if (arguments.length === 2) {\n Ember.assert(\"You can only add a '\" + type + \"' record to this relationship\", !value || value instanceof typeClass);\n return value === undefined ? null : value;\n }\n\n belongsTo = data[key];\n\n if (isNone(belongsTo)) { return null; }\n\n store.fetchRecord(belongsTo);\n\n return belongsTo;\n }).property('data').meta(meta);\n};\n\n/**\n These observers observe all `belongsTo` relationships on the record. See\n `relationships/ext` to see how these observers get their dependencies.\n\n @class Model\n @namespace DS\n*/\nDS.Model.reopen({\n\n /**\n @method belongsToWillChange\n @private\n @static\n @param record\n @param key\n */\n belongsToWillChange: Ember.beforeObserver(function(record, key) {\n if (get(record, 'isLoaded')) {\n var oldParent = get(record, key);\n\n if (oldParent) {\n var store = get(record, 'store'),\n change = DS.RelationshipChange.createChange(record, oldParent, store, { key: key, kind: \"belongsTo\", changeType: \"remove\" });\n\n change.sync();\n this._changesToSync[key] = change;\n }\n }\n }),\n\n /**\n @method belongsToDidChange\n @private\n @static\n @param record\n @param key\n */\n belongsToDidChange: Ember.immediateObserver(function(record, key) {\n if (get(record, 'isLoaded')) {\n var newParent = get(record, key);\n\n if (newParent) {\n var store = get(record, 'store'),\n change = DS.RelationshipChange.createChange(record, newParent, store, { key: key, kind: \"belongsTo\", changeType: \"add\" });\n\n change.sync();\n }\n }\n\n delete this._changesToSync[key];\n })\n});\n\n})();\n//@ sourceURL=ember-data/system/relationships/belongs_to");minispade.register('ember-data/system/relationships/ext', "(function() {minispade.require(\"ember-inflector/system\");\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n @module ember-data\n*/\n\n/*\n This file defines several extensions to the base `DS.Model` class that\n add support for one-to-many relationships.\n*/\n\n/**\n @class Model\n @namespace DS\n*/\nDS.Model.reopen({\n\n /**\n This Ember.js hook allows an object to be notified when a property\n is defined.\n\n In this case, we use it to be notified when an Ember Data user defines a\n belongs-to relationship. In that case, we need to set up observers for\n each one, allowing us to track relationship changes and automatically\n reflect changes in the inverse has-many array.\n\n This hook passes the class being set up, as well as the key and value\n being defined. So, for example, when the user does this:\n\n ```javascript\n DS.Model.extend({\n parent: DS.belongsTo('user')\n });\n ```\n\n This hook would be called with \"parent\" as the key and the computed\n property returned by `DS.belongsTo` as the value.\n\n @method didDefineProperty\n @param proto\n @param key\n @param value\n */\n didDefineProperty: function(proto, key, value) {\n // Check if the value being set is a computed property.\n if (value instanceof Ember.Descriptor) {\n\n // If it is, get the metadata for the relationship. This is\n // populated by the `DS.belongsTo` helper when it is creating\n // the computed property.\n var meta = value.meta();\n\n if (meta.isRelationship && meta.kind === 'belongsTo') {\n Ember.addObserver(proto, key, null, 'belongsToDidChange');\n Ember.addBeforeObserver(proto, key, null, 'belongsToWillChange');\n }\n\n meta.parentType = proto.constructor;\n }\n }\n});\n\n/*\n These DS.Model extensions add class methods that provide relationship\n introspection abilities about relationships.\n\n A note about the computed properties contained here:\n\n **These properties are effectively sealed once called for the first time.**\n To avoid repeatedly doing expensive iteration over a model's fields, these\n values are computed once and then cached for the remainder of the runtime of\n your application.\n\n If your application needs to modify a class after its initial definition\n (for example, using `reopen()` to add additional attributes), make sure you\n do it before using your model with the store, which uses these properties\n extensively.\n*/\n\nDS.Model.reopenClass({\n /**\n For a given relationship name, returns the model type of the relationship.\n\n For example, if you define a model like this:\n\n ```javascript\n App.Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n ```\n\n Calling `App.Post.typeForRelationship('comments')` will return `App.Comment`.\n\n @method typeForRelationship\n @static\n @param {String} name the name of the relationship\n @return {subclass of DS.Model} the type of the relationship, or undefined\n */\n typeForRelationship: function(name) {\n var relationship = get(this, 'relationshipsByName').get(name);\n return relationship && relationship.type;\n },\n\n inverseFor: function(name) {\n var inverseType = this.typeForRelationship(name);\n\n if (!inverseType) { return null; }\n\n var options = this.metaForProperty(name).options;\n\n if (options.inverse === null) { return null; }\n\n var inverseName, inverseKind;\n\n if (options.inverse) {\n inverseName = options.inverse;\n inverseKind = Ember.get(inverseType, 'relationshipsByName').get(inverseName).kind;\n } else {\n var possibleRelationships = findPossibleInverses(this, inverseType);\n\n if (possibleRelationships.length === 0) { return null; }\n\n Ember.assert(\"You defined the '\" + name + \"' relationship on \" + this + \", but multiple possible inverse relationships of type \" + this + \" were found on \" + inverseType + \". Look at http://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses\", possibleRelationships.length === 1);\n\n inverseName = possibleRelationships[0].name;\n inverseKind = possibleRelationships[0].kind;\n }\n\n function findPossibleInverses(type, inverseType, possibleRelationships) {\n possibleRelationships = possibleRelationships || [];\n\n var relationshipMap = get(inverseType, 'relationships');\n if (!relationshipMap) { return; }\n\n var relationships = relationshipMap.get(type);\n if (relationships) {\n possibleRelationships.push.apply(possibleRelationships, relationshipMap.get(type));\n }\n\n if (type.superclass) {\n findPossibleInverses(type.superclass, inverseType, possibleRelationships);\n }\n\n return possibleRelationships;\n }\n\n return {\n type: inverseType,\n name: inverseName,\n kind: inverseKind\n };\n },\n\n /**\n The model's relationships as a map, keyed on the type of the\n relationship. The value of each entry is an array containing a descriptor\n for each relationship with that type, describing the name of the relationship\n as well as the type.\n\n For example, given the following model definition:\n\n ```javascript\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n posts: DS.hasMany('post')\n });\n ```\n\n This computed property would return a map describing these\n relationships, like this:\n\n ```javascript\n var relationships = Ember.get(App.Blog, 'relationships');\n relationships.get(App.User);\n //=> [ { name: 'users', kind: 'hasMany' },\n // { name: 'owner', kind: 'belongsTo' } ]\n relationships.get(App.Post);\n //=> [ { name: 'posts', kind: 'hasMany' } ]\n ```\n\n @property relationships\n @static\n @type Ember.Map\n @readOnly\n */\n relationships: Ember.computed(function() {\n var map = new Ember.MapWithDefault({\n defaultValue: function() { return []; }\n });\n\n // Loop through each computed property on the class\n this.eachComputedProperty(function(name, meta) {\n\n // If the computed property is a relationship, add\n // it to the map.\n if (meta.isRelationship) {\n if (typeof meta.type === 'string') {\n meta.type = this.store.modelFor(meta.type);\n }\n\n var relationshipsForType = map.get(meta.type);\n\n relationshipsForType.push({ name: name, kind: meta.kind });\n }\n });\n\n return map;\n }),\n\n /**\n A hash containing lists of the model's relationships, grouped\n by the relationship kind. For example, given a model with this\n definition:\n\n ```javascript\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n\n posts: DS.hasMany('post')\n });\n ```\n\n This property would contain the following:\n\n ```javascript\n var relationshipNames = Ember.get(App.Blog, 'relationshipNames');\n relationshipNames.hasMany;\n //=> ['users', 'posts']\n relationshipNames.belongsTo;\n //=> ['owner']\n ```\n\n @property relationshipNames\n @static\n @type Object\n @readOnly\n */\n relationshipNames: Ember.computed(function() {\n var names = { hasMany: [], belongsTo: [] };\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n names[meta.kind].push(name);\n }\n });\n\n return names;\n }),\n\n /**\n An array of types directly related to a model. Each type will be\n included once, regardless of the number of relationships it has with\n the model.\n\n For example, given a model with this definition:\n\n ```javascript\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n\n posts: DS.hasMany('post')\n });\n ```\n\n This property would contain the following:\n\n ```javascript\n var relatedTypes = Ember.get(App.Blog, 'relatedTypes');\n //=> [ App.User, App.Post ]\n ```\n\n @property relatedTypes\n @static\n @type Ember.Array\n @readOnly\n */\n relatedTypes: Ember.computed(function() {\n var type,\n types = Ember.A();\n\n // Loop through each computed property on the class,\n // and create an array of the unique types involved\n // in relationships\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n type = meta.type;\n\n if (typeof type === 'string') {\n type = get(this, type, false) || this.store.modelFor(type);\n }\n\n Ember.assert(\"You specified a hasMany (\" + meta.type + \") on \" + meta.parentType + \" but \" + meta.type + \" was not found.\", type);\n\n if (!types.contains(type)) {\n Ember.assert(\"Trying to sideload \" + name + \" on \" + this.toString() + \" but the type doesn't exist.\", !!type);\n types.push(type);\n }\n }\n });\n\n return types;\n }),\n\n /**\n A map whose keys are the relationships of a model and whose values are\n relationship descriptors.\n\n For example, given a model with this\n definition:\n\n ```javascript\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n\n posts: DS.hasMany('post')\n });\n ```\n\n This property would contain the following:\n\n ```javascript\n var relationshipsByName = Ember.get(App.Blog, 'relationshipsByName');\n relationshipsByName.get('users');\n //=> { key: 'users', kind: 'hasMany', type: App.User }\n relationshipsByName.get('owner');\n //=> { key: 'owner', kind: 'belongsTo', type: App.User }\n ```\n\n @property relationshipsByName\n @static\n @type Ember.Map\n @readOnly\n */\n relationshipsByName: Ember.computed(function() {\n var map = Ember.Map.create(), type;\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n meta.key = name;\n type = meta.type;\n\n if (!type && meta.kind === 'hasMany') {\n type = Ember.String.singularize(name);\n } else if (!type) {\n type = name;\n }\n\n if (typeof type === 'string') {\n meta.type = this.store.modelFor(type);\n }\n\n map.set(name, meta);\n }\n });\n\n return map;\n }),\n\n /**\n A map whose keys are the fields of the model and whose values are strings\n describing the kind of the field. A model's fields are the union of all of its\n attributes and relationships.\n\n For example:\n\n ```javascript\n\n App.Blog = DS.Model.extend({\n users: DS.hasMany('user'),\n owner: DS.belongsTo('user'),\n\n posts: DS.hasMany('post'),\n\n title: DS.attr('string')\n });\n\n var fields = Ember.get(App.Blog, 'fields');\n fields.forEach(function(field, kind) {\n console.log(field, kind);\n });\n\n // prints:\n // users, hasMany\n // owner, belongsTo\n // posts, hasMany\n // title, attribute\n ```\n\n @property fields\n @static\n @type Ember.Map\n @readOnly\n */\n fields: Ember.computed(function() {\n var map = Ember.Map.create();\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n map.set(name, meta.kind);\n } else if (meta.isAttribute) {\n map.set(name, 'attribute');\n }\n });\n\n return map;\n }),\n\n /**\n Given a callback, iterates over each of the relationships in the model,\n invoking the callback with the name of each relationship and its relationship\n descriptor.\n\n @method eachRelationship\n @static\n @param {Function} callback the callback to invoke\n @param {any} binding the value to which the callback's `this` should be bound\n */\n eachRelationship: function(callback, binding) {\n get(this, 'relationshipsByName').forEach(function(name, relationship) {\n callback.call(binding, name, relationship);\n });\n },\n\n /**\n Given a callback, iterates over each of the types related to a model,\n invoking the callback with the related type's class. Each type will be\n returned just once, regardless of how many different relationships it has\n with a model.\n\n @method eachRelatedType\n @static\n @param {Function} callback the callback to invoke\n @param {any} binding the value to which the callback's `this` should be bound\n */\n eachRelatedType: function(callback, binding) {\n get(this, 'relatedTypes').forEach(function(type) {\n callback.call(binding, type);\n });\n }\n});\n\nDS.Model.reopen({\n /**\n Given a callback, iterates over each of the relationships in the model,\n invoking the callback with the name of each relationship and its relationship\n descriptor.\n\n @method eachRelationship\n @param {Function} callback the callback to invoke\n @param {any} binding the value to which the callback's `this` should be bound\n */\n eachRelationship: function(callback, binding) {\n this.constructor.eachRelationship(callback, binding);\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/relationships/ext");minispade.register('ember-data/system/relationships/has_many', "(function() {minispade.require(\"ember-data/system/model/model\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set, setProperties = Ember.setProperties;\n\nfunction asyncHasMany(type, options, meta) {\n return Ember.computed(function(key, value) {\n var relationship = this._relationships[key],\n promiseLabel = \"DS: Async hasMany \" + this + \" : \" + key;\n\n if (!relationship) {\n var resolver = Ember.RSVP.defer(promiseLabel);\n relationship = buildRelationship(this, key, options, function(store, data) {\n var link = data.links && data.links[key];\n var rel;\n if (link) {\n rel = store.findHasMany(this, link, meta, resolver);\n } else {\n rel = store.findMany(this, data[key], meta.type, resolver);\n }\n // cache the promise so we can use it\n // when we come back and don't need to rebuild\n // the relationship.\n set(rel, 'promise', resolver.promise);\n return rel;\n });\n }\n\n var promise = relationship.get('promise').then(function() {\n return relationship;\n }, null, \"DS: Async hasMany records received\");\n\n return DS.PromiseArray.create({ promise: promise });\n }).property('data').meta(meta);\n}\n\nfunction buildRelationship(record, key, options, callback) {\n var rels = record._relationships;\n\n if (rels[key]) { return rels[key]; }\n\n var data = get(record, 'data'),\n store = get(record, 'store');\n\n var relationship = rels[key] = callback.call(record, store, data);\n\n return setProperties(relationship, {\n owner: record, name: key, isPolymorphic: options.polymorphic\n });\n}\n\nfunction hasRelationship(type, options) {\n options = options || {};\n\n var meta = { type: type, isRelationship: true, options: options, kind: 'hasMany' };\n\n if (options.async) {\n return asyncHasMany(type, options, meta);\n }\n\n return Ember.computed(function(key, value) {\n return buildRelationship(this, key, options, function(store, data) {\n var records = data[key];\n Ember.assert(\"You looked up the '\" + key + \"' relationship on '\" + this + \"' but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)\", Ember.A(records).everyProperty('isEmpty', false));\n return store.findMany(this, data[key], meta.type);\n });\n }).property('data').meta(meta);\n}\n\n/**\n `DS.hasMany` is used to define One-To-Many and Many-To-Many\n relationships on a [DS.Model](DS.Model.html).\n\n `DS.hasMany` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `async`: A boolean value used to explicitly declare this to be an async relationship.\n - `inverse`: A string used to identify the inverse property on a related model.\n\n #### One-To-Many\n To declare a one-to-many relationship between two models, use\n `DS.belongsTo` in combination with `DS.hasMany`, like this:\n\n ```javascript\n App.Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n App.Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n ```\n\n #### Many-To-Many\n To declare a many-to-many relationship between two models, use\n `DS.hasMany`:\n\n ```javascript\n App.Post = DS.Model.extend({\n tags: DS.hasMany('tag')\n });\n\n App.Tag = DS.Model.extend({\n posts: DS.hasMany('post')\n });\n ```\n\n #### Explicit Inverses\n\n Ember Data will do its best to discover which relationships map to\n one another. In the one-to-many code above, for example, Ember Data\n can figure out that changing the `comments` relationship should update\n the `post` relationship on the inverse because post is the only\n relationship to that model.\n\n However, sometimes you may have multiple `belongsTo`/`hasManys` for the\n same type. You can specify which property on the related model is\n the inverse using `DS.hasMany`'s `inverse` option:\n\n ```javascript\n var belongsTo = DS.belongsTo,\n hasMany = DS.hasMany;\n\n App.Comment = DS.Model.extend({\n onePost: belongsTo('post'),\n twoPost: belongsTo('post'),\n redPost: belongsTo('post'),\n bluePost: belongsTo('post')\n });\n\n App.Post = DS.Model.extend({\n comments: hasMany('comment', {\n inverse: 'redPost'\n })\n });\n ```\n\n You can also specify an inverse on a `belongsTo`, which works how\n you'd expect.\n\n @namespace\n @method hasMany\n @for DS\n @param {String or DS.Model} type the model type of the relationship\n @param {Object} options a hash of options\n @return {Ember.computed} relationship\n*/\nDS.hasMany = function(type, options) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n }\n return hasRelationship(type, options);\n};\n\n})();\n//@ sourceURL=ember-data/system/relationships/has_many");minispade.register('ember-data/system/store', "(function() {/*globals Ember*/\n/*jshint eqnull:true*/\nminispade.require(\"ember-data/system/record_arrays\");\n\n/**\n @module ember-data\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar once = Ember.run.once;\nvar isNone = Ember.isNone;\nvar forEach = Ember.EnumerableUtils.forEach;\nvar indexOf = Ember.EnumerableUtils.indexOf;\nvar map = Ember.EnumerableUtils.map;\nvar resolve = Ember.RSVP.resolve;\nvar copy = Ember.copy;\n\n// Implementors Note:\n//\n// The variables in this file are consistently named according to the following\n// scheme:\n//\n// * +id+ means an identifier managed by an external source, provided inside\n// the data provided by that source. These are always coerced to be strings\n// before being used internally.\n// * +clientId+ means a transient numerical identifier generated at runtime by\n// the data store. It is important primarily because newly created objects may\n// not yet have an externally generated id.\n// * +reference+ means a record reference object, which holds metadata about a\n// record, even if it has not yet been fully materialized.\n// * +type+ means a subclass of DS.Model.\n\n// Used by the store to normalize IDs entering the store. Despite the fact\n// that developers may provide IDs as numbers (e.g., `store.find(Person, 1)`),\n// it is important that internally we use strings, since IDs may be serialized\n// and lose type information. For example, Ember's router may put a record's\n// ID into the URL, and if we later try to deserialize that URL and find the\n// corresponding record, we will not know if it is a string or a number.\nvar coerceId = function(id) {\n return id == null ? null : id+'';\n};\n\n/**\n The store contains all of the data for records loaded from the server.\n It is also responsible for creating instances of `DS.Model` that wrap\n the individual data for a record, so that they can be bound to in your\n Handlebars templates.\n\n Define your application's store like this:\n\n ```javascript\n MyApp.Store = DS.Store.extend();\n ```\n\n Most Ember.js applications will only have a single `DS.Store` that is\n automatically created by their `Ember.Application`.\n\n You can retrieve models from the store in several ways. To retrieve a record\n for a specific id, use `DS.Store`'s `find()` method:\n\n ```javascript\n var person = store.find('person', 123);\n ```\n\n If your application has multiple `DS.Store` instances (an unusual case), you can\n specify which store should be used:\n\n ```javascript\n var person = store.find(App.Person, 123);\n ```\n\n By default, the store will talk to your backend using a standard\n REST mechanism. You can customize how the store talks to your\n backend by specifying a custom adapter:\n\n ```javascript\n MyApp.store = DS.Store.create({\n adapter: 'MyApp.CustomAdapter'\n });\n ```\n\n You can learn more about writing a custom adapter by reading the `DS.Adapter`\n documentation.\n\n @class Store\n @namespace DS\n @extends Ember.Object\n*/\nDS.Store = Ember.Object.extend({\n\n /**\n @method init\n @private\n */\n init: function() {\n // internal bookkeeping; not observable\n this.typeMaps = {};\n this.recordArrayManager = DS.RecordArrayManager.create({\n store: this\n });\n this._relationshipChanges = {};\n this._pendingSave = [];\n },\n\n /**\n The adapter to use to communicate to a backend server or other persistence layer.\n\n This can be specified as an instance, class, or string.\n\n If you want to specify `App.CustomAdapter` as a string, do:\n\n ```js\n adapter: 'custom'\n ```\n\n @property adapter\n @default DS.RESTAdapter\n @type {DS.Adapter|String}\n */\n adapter: '-rest',\n\n /**\n Returns a JSON representation of the record using a custom\n type-specific serializer, if one exists.\n\n The available options are:\n\n * `includeId`: `true` if the record's ID should be included in\n the JSON representation\n\n @method serialize\n @private\n @param {DS.Model} record the record to serialize\n @param {Object} options an options hash\n */\n serialize: function(record, options) {\n return this.serializerFor(record.constructor.typeKey).serialize(record, options);\n },\n\n /**\n This property returns the adapter, after resolving a possible\n string key.\n\n If the supplied `adapter` was a class, or a String property\n path resolved to a class, this property will instantiate the\n class.\n\n This property is cacheable, so the same instance of a specified\n adapter class should be used for the lifetime of the store.\n\n @property defaultAdapter\n @private\n @returns DS.Adapter\n */\n defaultAdapter: Ember.computed('adapter', function() {\n var adapter = get(this, 'adapter');\n\n Ember.assert('You tried to set `adapter` property to an instance of `DS.Adapter`, where it should be a name or a factory', !(adapter instanceof DS.Adapter));\n\n if (typeof adapter === 'string') {\n adapter = this.container.lookup('adapter:' + adapter) || this.container.lookup('adapter:application') || this.container.lookup('adapter:-rest');\n }\n\n if (DS.Adapter.detect(adapter)) {\n adapter = adapter.create({ container: this.container });\n }\n\n return adapter;\n }),\n\n // .....................\n // . CREATE NEW RECORD .\n // .....................\n\n /**\n Create a new record in the current store. The properties passed\n to this method are set on the newly created record.\n\n To create a new instance of `App.Post`:\n\n ```js\n store.createRecord('post', {\n title: \"Rails is omakase\"\n });\n ```\n\n @method createRecord\n @param {String} type\n @param {Object} properties a hash of properties to set on the\n newly created record.\n @returns {DS.Model} record\n */\n createRecord: function(type, properties) {\n type = this.modelFor(type);\n\n properties = copy(properties) || {};\n\n // If the passed properties do not include a primary key,\n // give the adapter an opportunity to generate one. Typically,\n // client-side ID generators will use something like uuid.js\n // to avoid conflicts.\n\n if (isNone(properties.id)) {\n properties.id = this._generateId(type);\n }\n\n // Coerce ID to a string\n properties.id = coerceId(properties.id);\n\n var record = this.buildRecord(type, properties.id);\n\n // Move the record out of its initial `empty` state into\n // the `loaded` state.\n record.loadedData();\n\n // Set the properties specified on the record.\n record.setProperties(properties);\n\n return record;\n },\n\n /**\n If possible, this method asks the adapter to generate an ID for\n a newly created record.\n\n @method _generateId\n @private\n @param {String} type\n @returns {String} if the adapter can generate one, an ID\n */\n _generateId: function(type) {\n var adapter = this.adapterFor(type);\n\n if (adapter && adapter.generateIdForRecord) {\n return adapter.generateIdForRecord(this);\n }\n\n return null;\n },\n\n // .................\n // . DELETE RECORD .\n // .................\n\n /**\n For symmetry, a record can be deleted via the store.\n\n Example\n\n ```javascript\n var post = store.createRecord('post', {\n title: \"Rails is omakase\"\n });\n\n store.deleteRecord(post);\n ```\n\n @method deleteRecord\n @param {DS.Model} record\n */\n deleteRecord: function(record) {\n record.deleteRecord();\n },\n\n /**\n For symmetry, a record can be unloaded via the store. Only\n non-dirty records can be unloaded.\n\n Example\n\n ```javascript\n store.find('post', 1).then(function(post) {\n store.unloadRecord(post);\n });\n ```\n\n @method unloadRecord\n @param {DS.Model} record\n */\n unloadRecord: function(record) {\n record.unloadRecord();\n },\n\n // ................\n // . FIND RECORDS .\n // ................\n\n /**\n This is the main entry point into finding records. The first parameter to\n this method is the model's name as a string.\n\n ---\n\n To find a record by ID, pass the `id` as the second parameter:\n\n ```javascript\n store.find('person', 1);\n ```\n\n The `find` method will always return a **promise** that will be resolved\n with the record. If the record was already in the store, the promise will\n be resolved immediately. Otherwise, the store will ask the adapter's `find`\n method to find the necessary data.\n\n The `find` method will always resolve its promise with the same object for\n a given type and `id`.\n\n ---\n\n To find all records for a type, call `find` with no additional parameters:\n\n ```javascript\n store.find('person');\n ```\n\n This will ask the adapter's `findAll` method to find the records for the\n given type, and return a promise that will be resolved once the server\n returns the values.\n\n ---\n\n To find a record by a query, call `find` with a hash as the second\n parameter:\n\n ```javascript\n store.find(App.Person, { page: 1 });\n ```\n\n This will ask the adapter's `findQuery` method to find the records for\n the query, and return a promise that will be resolved once the server\n responds.\n\n @method find\n @param {String or subclass of DS.Model} type\n @param {Object|String|Integer|null} id\n @return {Promise} promise\n */\n find: function(type, id) {\n if (id === undefined) {\n return this.findAll(type);\n }\n\n // We are passed a query instead of an id.\n if (Ember.typeOf(id) === 'object') {\n return this.findQuery(type, id);\n }\n\n return this.findById(type, coerceId(id));\n },\n\n /**\n This method returns a record for a given type and id combination.\n\n @method findById\n @private\n @param {String or subclass of DS.Model} type\n @param {String|Integer} id\n @return {Promise} promise\n */\n findById: function(type, id) {\n type = this.modelFor(type);\n\n var record = this.recordForId(type, id);\n\n var promise = this.fetchRecord(record) || resolve(record, \"DS: Store#findById \" + type + \" with id: \" + id);\n return promiseObject(promise);\n },\n\n /**\n This method makes a series of requests to the adapter's `find` method\n and returns a promise that resolves once they are all loaded.\n\n @private\n @method findByIds\n @param {String} type\n @param {Array} ids\n @returns {Promise} promise\n */\n findByIds: function(type, ids) {\n var store = this;\n var promiseLabel = \"DS: Store#findByIds \" + type;\n return promiseArray(Ember.RSVP.all(map(ids, function(id) {\n return store.findById(type, id);\n })).then(Ember.A, null, \"DS: Store#findByIds of \" + type + \" complete\"));\n },\n\n /**\n This method is called by `findById` if it discovers that a particular\n type/id pair hasn't been loaded yet to kick off a request to the\n adapter.\n\n @method fetchRecord\n @private\n @param {DS.Model} record\n @returns {Promise} promise\n */\n fetchRecord: function(record) {\n if (isNone(record)) { return null; }\n if (record._loadingPromise) { return record._loadingPromise; }\n if (!get(record, 'isEmpty')) { return null; }\n\n var type = record.constructor,\n id = get(record, 'id');\n\n var adapter = this.adapterFor(type);\n\n Ember.assert(\"You tried to find a record but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to find a record but your adapter (for \" + type + \") does not implement 'find'\", adapter.find);\n\n var promise = _find(adapter, this, type, id);\n record.loadingData(promise);\n return promise;\n },\n\n /**\n Get a record by a given type and ID without triggering a fetch.\n\n This method will synchronously return the record if it's available.\n Otherwise, it will return null.\n\n ```js\n var post = store.getById('post', 1);\n ```\n\n @method getById\n @param {String or subclass of DS.Model} type\n @param {String|Integer} id\n @param {DS.Model} record\n */\n getById: function(type, id) {\n if (this.hasRecordForId(type, id)) {\n return this.recordForId(type, id);\n } else {\n return null;\n }\n },\n\n /**\n This method is called by the record's `reload` method.\n\n This method calls the adapter's `find` method, which returns a promise. When\n **that** promise resolves, `reloadRecord` will resolve the promise returned\n by the record's `reload`.\n\n @method reloadRecord\n @private\n @param {DS.Model} record\n @return {Promise} promise\n */\n reloadRecord: function(record) {\n var type = record.constructor,\n adapter = this.adapterFor(type),\n id = get(record, 'id');\n\n Ember.assert(\"You cannot reload a record without an ID\", id);\n Ember.assert(\"You tried to reload a record but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to reload a record but your adapter does not implement `find`\", adapter.find);\n\n return _find(adapter, this, type, id);\n },\n\n /**\n This method takes a list of records, groups the records by type,\n converts the records into IDs, and then invokes the adapter's `findMany`\n method.\n\n The records are grouped by type to invoke `findMany` on adapters\n for each unique type in records.\n\n It is used both by a brand new relationship (via the `findMany`\n method) or when the data underlying an existing relationship\n changes.\n\n @method fetchMany\n @private\n @param {Array} records\n @param {DS.Model} owner\n @param {Resolver} resolver\n */\n fetchMany: function(records, owner, resolver) {\n if (!records.length) { return; }\n\n // Group By Type\n var recordsByTypeMap = Ember.MapWithDefault.create({\n defaultValue: function() { return Ember.A(); }\n });\n\n forEach(records, function(record) {\n recordsByTypeMap.get(record.constructor).push(record);\n });\n\n forEach(recordsByTypeMap, function(type, records) {\n var ids = records.mapProperty('id'),\n adapter = this.adapterFor(type);\n\n Ember.assert(\"You tried to load many records but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to load many records but your adapter does not implement `findMany`\", adapter.findMany);\n\n resolver.resolve(_findMany(adapter, this, type, ids, owner));\n }, this);\n },\n\n /**\n Returns true if a record for a given type and ID is already loaded.\n\n @method hasRecordForId\n @param {String or subclass of DS.Model} type\n @param {String|Integer} id\n @returns {Boolean}\n */\n hasRecordForId: function(type, id) {\n id = coerceId(id);\n type = this.modelFor(type);\n return !!this.typeMapFor(type).idToRecord[id];\n },\n\n /**\n Returns id record for a given type and ID. If one isn't already loaded,\n it builds a new record and leaves it in the `empty` state.\n\n @method recordForId\n @private\n @param {String or subclass of DS.Model} type\n @param {String|Integer} id\n @returns {DS.Model} record\n */\n recordForId: function(type, id) {\n type = this.modelFor(type);\n\n id = coerceId(id);\n\n var record = this.typeMapFor(type).idToRecord[id];\n\n if (!record) {\n record = this.buildRecord(type, id);\n }\n\n return record;\n },\n\n /**\n @method findMany\n @private\n @param {DS.Model} owner\n @param {Array} records\n @param {String or subclass of DS.Model} type\n @param {Resolver} resolver\n @return {DS.ManyArray} records\n */\n findMany: function(owner, records, type, resolver) {\n type = this.modelFor(type);\n\n records = Ember.A(records);\n\n var unloadedRecords = records.filterProperty('isEmpty', true),\n manyArray = this.recordArrayManager.createManyArray(type, records);\n\n forEach(unloadedRecords, function(record) {\n record.loadingData();\n });\n\n manyArray.loadingRecordsCount = unloadedRecords.length;\n\n if (unloadedRecords.length) {\n forEach(unloadedRecords, function(record) {\n this.recordArrayManager.registerWaitingRecordArray(record, manyArray);\n }, this);\n\n this.fetchMany(unloadedRecords, owner, resolver);\n } else {\n if (resolver) { resolver.resolve(); }\n manyArray.set('isLoaded', true);\n Ember.run.once(manyArray, 'trigger', 'didLoad');\n }\n\n return manyArray;\n },\n\n /**\n If a relationship was originally populated by the adapter as a link\n (as opposed to a list of IDs), this method is called when the\n relationship is fetched.\n\n The link (which is usually a URL) is passed through unchanged, so the\n adapter can make whatever request it wants.\n\n The usual use-case is for the server to register a URL as a link, and\n then use that URL in the future to make a request for the relationship.\n\n @method findHasMany\n @private\n @param {DS.Model} owner\n @param {any} link\n @param {String or subclass of DS.Model} type\n @param {Resolver} resolver\n @return {DS.ManyArray}\n */\n findHasMany: function(owner, link, relationship, resolver) {\n var adapter = this.adapterFor(owner.constructor);\n\n Ember.assert(\"You tried to load a hasMany relationship but you have no adapter (for \" + owner.constructor + \")\", adapter);\n Ember.assert(\"You tried to load a hasMany relationship from a specified `link` in the original payload but your adapter does not implement `findHasMany`\", adapter.findHasMany);\n\n var records = this.recordArrayManager.createManyArray(relationship.type, Ember.A([]));\n resolver.resolve(_findHasMany(adapter, this, owner, link, relationship));\n return records;\n },\n\n /**\n @method findBelongsTo\n @private\n @param {DS.Model} owner\n @param {any} link\n @param {Relationship} relationship\n @param {Resolver} resolver\n */\n findBelongsTo: function(owner, link, relationship, resolver) {\n var adapter = this.adapterFor(owner.constructor);\n\n Ember.assert(\"You tried to load a belongsTo relationship but you have no adapter (for \" + owner.constructor + \")\", adapter);\n Ember.assert(\"You tried to load a belongsTo relationship from a specified `link` in the original payload but your adapter does not implement `findBelongsTo`\", adapter.findBelongsTo);\n\n resolver.resolve(_findBelongsTo(adapter, this, owner, link, relationship));\n },\n\n /**\n This method delegates a query to the adapter. This is the one place where\n adapter-level semantics are exposed to the application.\n\n Exposing queries this way seems preferable to creating an abstract query\n language for all server-side queries, and then require all adapters to\n implement them.\n\n This method returns a promise, which is resolved with a `RecordArray`\n once the server returns.\n\n @method findQuery\n @private\n @param {String or subclass of DS.Model} type\n @param {any} query an opaque query to be used by the adapter\n @return {Promise} promise\n */\n findQuery: function(type, query) {\n type = this.modelFor(type);\n\n var array = this.recordArrayManager\n .createAdapterPopulatedRecordArray(type, query);\n\n var adapter = this.adapterFor(type),\n promiseLabel = \"DS: Store#findQuery \" + type,\n resolver = Ember.RSVP.defer(promiseLabel);\n\n Ember.assert(\"You tried to load a query but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to load a query but your adapter does not implement `findQuery`\", adapter.findQuery);\n\n resolver.resolve(_findQuery(adapter, this, type, query, array));\n\n return promiseArray(resolver.promise);\n },\n\n /**\n This method returns an array of all records adapter can find.\n It triggers the adapter's `findAll` method to give it an opportunity to populate\n the array with records of that type.\n\n @method findAll\n @private\n @param {String or subclass of DS.Model} type\n @return {DS.AdapterPopulatedRecordArray}\n */\n findAll: function(type) {\n type = this.modelFor(type);\n\n return this.fetchAll(type, this.all(type));\n },\n\n /**\n @method fetchAll\n @private\n @param {DS.Model} type\n @param {DS.RecordArray} array\n @returns {Promise} promise\n */\n fetchAll: function(type, array) {\n var adapter = this.adapterFor(type),\n sinceToken = this.typeMapFor(type).metadata.since;\n\n set(array, 'isUpdating', true);\n\n Ember.assert(\"You tried to load all records but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to load all records but your adapter does not implement `findAll`\", adapter.findAll);\n\n return promiseArray(_findAll(adapter, this, type, sinceToken));\n },\n\n /**\n @method didUpdateAll\n @param {DS.Model} type\n */\n didUpdateAll: function(type) {\n var findAllCache = this.typeMapFor(type).findAllCache;\n set(findAllCache, 'isUpdating', false);\n },\n\n /**\n This method returns a filtered array that contains all of the known records\n for a given type.\n\n Note that because it's just a filter, it will have any locally\n created records of the type.\n\n Also note that multiple calls to `all` for a given type will always\n return the same RecordArray.\n\n Example\n\n ```javascript\n var local_posts = store.all(App.Post);\n ```\n\n @method all\n @param {String or subclass of DS.Model} type\n @return {DS.RecordArray}\n */\n all: function(type) {\n type = this.modelFor(type);\n\n var typeMap = this.typeMapFor(type),\n findAllCache = typeMap.findAllCache;\n\n if (findAllCache) { return findAllCache; }\n\n var array = this.recordArrayManager.createRecordArray(type);\n\n typeMap.findAllCache = array;\n return array;\n },\n\n\n /**\n This method unloads all of the known records for a given type.\n\n ```javascript\n store.unloadAll(App.Post);\n ```\n\n @method unloadAll\n @param {String or subclass of DS.Model} type\n */\n unloadAll: function(type) {\n type = this.modelFor(type);\n\n var typeMap = this.typeMapFor(type),\n records = typeMap.records.splice(0), record;\n\n while(record = records.pop()) {\n record.unloadRecord();\n }\n\n typeMap.findAllCache = null;\n },\n\n /**\n Takes a type and filter function, and returns a live RecordArray that\n remains up to date as new records are loaded into the store or created\n locally.\n\n The callback function takes a materialized record, and returns true\n if the record should be included in the filter and false if it should\n not.\n\n The filter function is called once on all records for the type when\n it is created, and then once on each newly loaded or created record.\n\n If any of a record's properties change, or if it changes state, the\n filter function will be invoked again to determine whether it should\n still be in the array.\n\n Optionally you can pass a query which will be triggered at first. The\n results returned by the server could then appear in the filter if they\n match the filter function.\n\n Example\n\n ```javascript\n store.filter(App.Post, {unread: true}, function(post) {\n return post.get('unread');\n }).then(function(unreadPosts) {\n unreadPosts.get('length'); // 5\n var unreadPost = unreadPosts.objectAt(0);\n unreadPost.set('unread', false);\n unreadPosts.get('length'); // 4\n });\n ```\n\n @method filter\n @param {String or subclass of DS.Model} type\n @param {Object} query optional query\n @param {Function} filter\n @return {DS.PromiseArray}\n */\n filter: function(type, query, filter) {\n var promise;\n\n // allow an optional server query\n if (arguments.length === 3) {\n promise = this.findQuery(type, query);\n } else if (arguments.length === 2) {\n filter = query;\n }\n\n type = this.modelFor(type);\n\n var array = this.recordArrayManager\n .createFilteredRecordArray(type, filter);\n promise = promise || resolve(array);\n\n return promiseArray(promise.then(function() {\n return array;\n }, null, \"DS: Store#filter of \" + type));\n },\n\n /**\n This method returns if a certain record is already loaded\n in the store. Use this function to know beforehand if a find()\n will result in a request or that it will be a cache hit.\n\n Example\n\n ```javascript\n store.recordIsLoaded(App.Post, 1); // false\n store.find(App.Post, 1).then(function() {\n store.recordIsLoaded(App.Post, 1); // true\n });\n ```\n\n @method recordIsLoaded\n @param {String or subclass of DS.Model} type\n @param {string} id\n @return {boolean}\n */\n recordIsLoaded: function(type, id) {\n if (!this.hasRecordForId(type, id)) { return false; }\n return !get(this.recordForId(type, id), 'isEmpty');\n },\n\n /**\n This method returns the metadata for a specific type.\n\n @method metadataFor\n @param {String or subclass of DS.Model} type\n @return {object}\n */\n metadataFor: function(type) {\n type = this.modelFor(type);\n return this.typeMapFor(type).metadata;\n },\n\n // ............\n // . UPDATING .\n // ............\n\n /**\n If the adapter updates attributes or acknowledges creation\n or deletion, the record will notify the store to update its\n membership in any filters.\n To avoid thrashing, this method is invoked only once per\n\n run loop per record.\n\n @method dataWasUpdated\n @private\n @param {Class} type\n @param {DS.Model} record\n */\n dataWasUpdated: function(type, record) {\n this.recordArrayManager.recordDidChange(record);\n },\n\n // ..............\n // . PERSISTING .\n // ..............\n\n /**\n This method is called by `record.save`, and gets passed a\n resolver for the promise that `record.save` returns.\n\n It schedules saving to happen at the end of the run loop.\n\n @method scheduleSave\n @private\n @param {DS.Model} record\n @param {Resolver} resolver\n */\n scheduleSave: function(record, resolver) {\n record.adapterWillCommit();\n this._pendingSave.push([record, resolver]);\n once(this, 'flushPendingSave');\n },\n\n /**\n This method is called at the end of the run loop, and\n flushes any records passed into `scheduleSave`\n\n @method flushPendingSave\n @private\n */\n flushPendingSave: function() {\n var pending = this._pendingSave.slice();\n this._pendingSave = [];\n\n forEach(pending, function(tuple) {\n var record = tuple[0], resolver = tuple[1],\n adapter = this.adapterFor(record.constructor),\n operation;\n\n if (get(record, 'isNew')) {\n operation = 'createRecord';\n } else if (get(record, 'isDeleted')) {\n operation = 'deleteRecord';\n } else {\n operation = 'updateRecord';\n }\n\n resolver.resolve(_commit(adapter, this, operation, record));\n }, this);\n },\n\n /**\n This method is called once the promise returned by an\n adapter's `createRecord`, `updateRecord` or `deleteRecord`\n is resolved.\n\n If the data provides a server-generated ID, it will\n update the record and the store's indexes.\n\n @method didSaveRecord\n @private\n @param {DS.Model} record the in-flight record\n @param {Object} data optional data (see above)\n */\n didSaveRecord: function(record, data) {\n if (data) {\n // normalize relationship IDs into records\n data = normalizeRelationships(this, record.constructor, data, record);\n\n this.updateId(record, data);\n }\n\n record.adapterDidCommit(data);\n },\n\n /**\n This method is called once the promise returned by an\n adapter's `createRecord`, `updateRecord` or `deleteRecord`\n is rejected with a `DS.InvalidError`.\n\n @method recordWasInvalid\n @private\n @param {DS.Model} record\n @param {Object} errors\n */\n recordWasInvalid: function(record, errors) {\n record.adapterDidInvalidate(errors);\n },\n\n /**\n This method is called once the promise returned by an\n adapter's `createRecord`, `updateRecord` or `deleteRecord`\n is rejected (with anything other than a `DS.InvalidError`).\n\n @method recordWasError\n @private\n @param {DS.Model} record\n */\n recordWasError: function(record) {\n record.adapterDidError();\n },\n\n /**\n When an adapter's `createRecord`, `updateRecord` or `deleteRecord`\n resolves with data, this method extracts the ID from the supplied\n data.\n\n @method updateId\n @private\n @param {DS.Model} record\n @param {Object} data\n */\n updateId: function(record, data) {\n var oldId = get(record, 'id'),\n id = coerceId(data.id);\n\n Ember.assert(\"An adapter cannot assign a new id to a record that already has an id. \" + record + \" had id: \" + oldId + \" and you tried to update it with \" + id + \". This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.\", oldId === null || id === oldId);\n\n this.typeMapFor(record.constructor).idToRecord[id] = record;\n\n set(record, 'id', id);\n },\n\n /**\n Returns a map of IDs to client IDs for a given type.\n\n @method typeMapFor\n @private\n @param type\n @return {Object} typeMap\n */\n typeMapFor: function(type) {\n var typeMaps = get(this, 'typeMaps'),\n guid = Ember.guidFor(type),\n typeMap;\n\n typeMap = typeMaps[guid];\n\n if (typeMap) { return typeMap; }\n\n typeMap = {\n idToRecord: {},\n records: [],\n metadata: {}\n };\n\n typeMaps[guid] = typeMap;\n\n return typeMap;\n },\n\n // ................\n // . LOADING DATA .\n // ................\n\n /**\n This internal method is used by `push`.\n\n @method _load\n @private\n @param {String or subclass of DS.Model} type\n @param {Object} data\n @param {Boolean} partial the data should be merged into\n the existing data, not replace it.\n */\n _load: function(type, data, partial) {\n var id = coerceId(data.id),\n record = this.recordForId(type, id);\n\n record.setupData(data, partial);\n this.recordArrayManager.recordDidChange(record);\n\n return record;\n },\n\n /**\n Returns a model class for a particular key. Used by\n methods that take a type key (like `find`, `createRecord`,\n etc.)\n\n @method modelFor\n @param {String or subclass of DS.Model} key\n @returns {subclass of DS.Model}\n */\n modelFor: function(key) {\n var factory;\n\n\n if (typeof key === 'string') {\n var normalizedKey = this.container.normalize('model:' + key);\n\n factory = this.container.lookupFactory(normalizedKey);\n if (!factory) { throw new Ember.Error(\"No model was found for '\" + key + \"'\"); }\n factory.typeKey = normalizedKey.split(':', 2)[1];\n } else {\n // A factory already supplied.\n factory = key;\n }\n\n factory.store = this;\n return factory;\n },\n\n /**\n Push some data for a given type into the store.\n\n This method expects normalized data:\n\n * The ID is a key named `id` (an ID is mandatory)\n * The names of attributes are the ones you used in\n your model's `DS.attr`s.\n * Your relationships must be:\n * represented as IDs or Arrays of IDs\n * represented as model instances\n * represented as URLs, under the `links` key\n\n For this model:\n\n ```js\n App.Person = DS.Model.extend({\n firstName: DS.attr(),\n lastName: DS.attr(),\n\n children: DS.hasMany('person')\n });\n ```\n\n To represent the children as IDs:\n\n ```js\n {\n id: 1,\n firstName: \"Tom\",\n lastName: \"Dale\",\n children: [1, 2, 3]\n }\n ```\n\n To represent the children relationship as a URL:\n\n ```js\n {\n id: 1,\n firstName: \"Tom\",\n lastName: \"Dale\",\n links: {\n children: \"/people/1/children\"\n }\n }\n ```\n\n If you're streaming data or implementing an adapter,\n make sure that you have converted the incoming data\n into this form.\n\n This method can be used both to push in brand new\n records, as well as to update existing records.\n\n @method push\n @param {String or subclass of DS.Model} type\n @param {Object} data\n @returns {DS.Model} the record that was created or\n updated.\n */\n push: function(type, data, _partial) {\n // _partial is an internal param used by `update`.\n // If passed, it means that the data should be\n // merged into the existing data, not replace it.\n\n Ember.assert(\"You must include an `id` in a hash passed to `push`\", data.id != null);\n\n type = this.modelFor(type);\n\n // normalize relationship IDs into records\n data = normalizeRelationships(this, type, data);\n\n this._load(type, data, _partial);\n\n return this.recordForId(type, data.id);\n },\n\n /**\n Push some raw data into the store.\n\n The data will be automatically deserialized using the\n serializer for the `type` param.\n\n This method can be used both to push in brand new\n records, as well as to update existing records.\n\n You can push in more than one type of object at once.\n All objects should be in the format expected by the\n serializer.\n\n ```js\n App.ApplicationSerializer = DS.ActiveModelSerializer;\n\n var pushData = {\n posts: [\n {id: 1, post_title: \"Great post\", comment_ids: [2]}\n ],\n comments: [\n {id: 2, comment_body: \"Insightful comment\"}\n ]\n }\n\n store.pushPayload('post', pushData);\n ```\n\n @method pushPayload\n @param {String} type\n @param {Object} payload\n @return {DS.Model} the record that was created or updated.\n */\n pushPayload: function (type, payload) {\n var serializer;\n if (!payload) {\n payload = type;\n serializer = defaultSerializer(this.container);\n Ember.assert(\"You cannot use `store#pushPayload` without a type unless your default serializer defines `pushPayload`\", serializer.pushPayload);\n } else {\n serializer = this.serializerFor(type);\n }\n serializer.pushPayload(this, payload);\n },\n\n update: function(type, data) {\n Ember.assert(\"You must include an `id` in a hash passed to `update`\", data.id != null);\n\n return this.push(type, data, true);\n },\n\n /**\n If you have an Array of normalized data to push,\n you can call `pushMany` with the Array, and it will\n call `push` repeatedly for you.\n\n @method pushMany\n @param {String or subclass of DS.Model} type\n @param {Array} datas\n @return {Array}\n */\n pushMany: function(type, datas) {\n return map(datas, function(data) {\n return this.push(type, data);\n }, this);\n },\n\n /**\n If you have some metadata to set for a type\n you can call `metaForType`.\n\n @method metaForType\n @param {String or subclass of DS.Model} type\n @param {Object} metadata\n */\n metaForType: function(type, metadata) {\n type = this.modelFor(type);\n\n Ember.merge(this.typeMapFor(type).metadata, metadata);\n },\n\n /**\n Build a brand new record for a given type, ID, and\n initial data.\n\n @method buildRecord\n @private\n @param {subclass of DS.Model} type\n @param {String} id\n @param {Object} data\n @returns {DS.Model} record\n */\n buildRecord: function(type, id, data) {\n var typeMap = this.typeMapFor(type),\n idToRecord = typeMap.idToRecord;\n\n Ember.assert('The id ' + id + ' has already been used with another record of type ' + type.toString() + '.', !id || !idToRecord[id]);\n\n // lookupFactory should really return an object that creates\n // instances with the injections applied\n var record = type._create({\n id: id,\n store: this,\n container: this.container\n });\n\n if (data) {\n record.setupData(data);\n }\n\n // if we're creating an item, this process will be done\n // later, once the object has been persisted.\n if (id) {\n idToRecord[id] = record;\n }\n\n typeMap.records.push(record);\n\n return record;\n },\n\n // ...............\n // . DESTRUCTION .\n // ...............\n\n /**\n When a record is destroyed, this un-indexes it and\n removes it from any record arrays so it can be GCed.\n\n @method dematerializeRecord\n @private\n @param {DS.Model} record\n */\n dematerializeRecord: function(record) {\n var type = record.constructor,\n typeMap = this.typeMapFor(type),\n id = get(record, 'id');\n\n record.updateRecordArrays();\n\n if (id) {\n delete typeMap.idToRecord[id];\n }\n\n var loc = indexOf(typeMap.records, record);\n typeMap.records.splice(loc, 1);\n },\n\n // ........................\n // . RELATIONSHIP CHANGES .\n // ........................\n\n addRelationshipChangeFor: function(childRecord, childKey, parentRecord, parentKey, change) {\n var clientId = childRecord.clientId,\n parentClientId = parentRecord ? parentRecord : parentRecord;\n var key = childKey + parentKey;\n var changes = this._relationshipChanges;\n if (!(clientId in changes)) {\n changes[clientId] = {};\n }\n if (!(parentClientId in changes[clientId])) {\n changes[clientId][parentClientId] = {};\n }\n if (!(key in changes[clientId][parentClientId])) {\n changes[clientId][parentClientId][key] = {};\n }\n changes[clientId][parentClientId][key][change.changeType] = change;\n },\n\n removeRelationshipChangeFor: function(clientRecord, childKey, parentRecord, parentKey, type) {\n var clientId = clientRecord.clientId,\n parentClientId = parentRecord ? parentRecord.clientId : parentRecord;\n var changes = this._relationshipChanges;\n var key = childKey + parentKey;\n if (!(clientId in changes) || !(parentClientId in changes[clientId]) || !(key in changes[clientId][parentClientId])){\n return;\n }\n delete changes[clientId][parentClientId][key][type];\n },\n\n relationshipChangePairsFor: function(record){\n var toReturn = [];\n\n if( !record ) { return toReturn; }\n\n //TODO(Igor) What about the other side\n var changesObject = this._relationshipChanges[record.clientId];\n for (var objKey in changesObject){\n if(changesObject.hasOwnProperty(objKey)){\n for (var changeKey in changesObject[objKey]){\n if(changesObject[objKey].hasOwnProperty(changeKey)){\n toReturn.push(changesObject[objKey][changeKey]);\n }\n }\n }\n }\n return toReturn;\n },\n\n // ......................\n // . PER-TYPE ADAPTERS\n // ......................\n\n /**\n Returns the adapter for a given type.\n\n @method adapterFor\n @private\n @param {subclass of DS.Model} type\n @returns DS.Adapter\n */\n adapterFor: function(type) {\n var container = this.container, adapter;\n\n if (container) {\n adapter = container.lookup('adapter:' + type.typeKey) || container.lookup('adapter:application');\n }\n\n return adapter || get(this, 'defaultAdapter');\n },\n\n // ..............................\n // . RECORD CHANGE NOTIFICATION .\n // ..............................\n\n /**\n Returns an instance of the serializer for a given type. For\n example, `serializerFor('person')` will return an instance of\n `App.PersonSerializer`.\n\n If no `App.PersonSerializer` is found, this method will look\n for an `App.ApplicationSerializer` (the default serializer for\n your entire application).\n\n If no `App.ApplicationSerializer` is found, it will fall back\n to an instance of `DS.JSONSerializer`.\n\n @method serializerFor\n @private\n @param {String} type the record to serialize\n @return {DS.Serializer}\n */\n serializerFor: function(type) {\n type = this.modelFor(type);\n var adapter = this.adapterFor(type);\n\n return serializerFor(this.container, type.typeKey, adapter && adapter.defaultSerializer);\n }\n});\n\nfunction normalizeRelationships(store, type, data, record) {\n type.eachRelationship(function(key, relationship) {\n // A link (usually a URL) was already provided in\n // normalized form\n if (data.links && data.links[key]) {\n if (record && relationship.options.async) { record._relationships[key] = null; }\n return;\n }\n\n var kind = relationship.kind,\n value = data[key];\n\n if (value == null) { return; }\n\n if (kind === 'belongsTo') {\n deserializeRecordId(store, data, key, relationship, value);\n } else if (kind === 'hasMany') {\n deserializeRecordIds(store, data, key, relationship, value);\n addUnsavedRecords(record, key, value);\n }\n });\n\n return data;\n}\n\nfunction deserializeRecordId(store, data, key, relationship, id) {\n if (isNone(id) || id instanceof DS.Model) {\n return;\n }\n\n var type;\n\n if (typeof id === 'number' || typeof id === 'string') {\n type = typeFor(relationship, key, data);\n data[key] = store.recordForId(type, id);\n } else if (typeof id === 'object') {\n // polymorphic\n data[key] = store.recordForId(id.type, id.id);\n }\n}\n\nfunction typeFor(relationship, key, data) {\n if (relationship.options.polymorphic) {\n return data[key + \"Type\"];\n } else {\n return relationship.type;\n }\n}\n\nfunction deserializeRecordIds(store, data, key, relationship, ids) {\n for (var i=0, l=ids.length; i<l; i++) {\n deserializeRecordId(store, ids, i, relationship, ids[i]);\n }\n}\n\n// If there are any unsaved records that are in a hasMany they won't be\n// in the payload, so add them back in manually.\nfunction addUnsavedRecords(record, key, data) {\n if(record) {\n data.pushObjects(record.get(key).filterBy('isNew'));\n }\n}\n\n// Delegation to the adapter and promise management\n/**\n A `PromiseArray` is an object that acts like both an `Ember.Array`\n and a promise. When the promise is resolved the the resulting value\n will be set to the `PromiseArray`'s `content` property. This makes\n it easy to create data bindings with the `PromiseArray` that will be\n updated when the promise resolves.\n\n For more information see the [Ember.PromiseProxyMixin\n documentation](/api/classes/Ember.PromiseProxyMixin.html).\n\n Example\n\n ```javascript\n var promiseArray = DS.PromiseArray.create({\n promise: $.getJSON('/some/remote/data.json')\n });\n\n promiseArray.get('length'); // 0\n\n promiseArray.then(function() {\n promiseArray.get('length'); // 100\n });\n ```\n\n @class PromiseArray\n @namespace DS\n @extends Ember.ArrayProxy\n @uses Ember.PromiseProxyMixin\n*/\nDS.PromiseArray = Ember.ArrayProxy.extend(Ember.PromiseProxyMixin);\n/**\n A `PromiseObject` is an object that acts like both an `Ember.Object`\n and a promise. When the promise is resolved the the resulting value\n will be set to the `PromiseObject`'s `content` property. This makes\n it easy to create data bindings with the `PromiseObject` that will\n be updated when the promise resolves.\n\n For more information see the [Ember.PromiseProxyMixin\n documentation](/api/classes/Ember.PromiseProxyMixin.html).\n\n Example\n\n ```javascript\n var promiseObject = DS.PromiseObject.create({\n promise: $.getJSON('/some/remote/data.json')\n });\n\n promiseObject.get('name'); // null\n\n promiseObject.then(function() {\n promiseObject.get('name'); // 'Tomster'\n });\n ```\n\n @class PromiseObject\n @namespace DS\n @extends Ember.ObjectProxy\n @uses Ember.PromiseProxyMixin\n*/\nDS.PromiseObject = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin);\n\nfunction promiseObject(promise) {\n return DS.PromiseObject.create({ promise: promise });\n}\n\nfunction promiseArray(promise) {\n return DS.PromiseArray.create({ promise: promise });\n}\n\nfunction isThenable(object) {\n return object && typeof object.then === 'function';\n}\n\nfunction serializerFor(container, type, defaultSerializer) {\n return container.lookup('serializer:'+type) ||\n container.lookup('serializer:application') ||\n container.lookup('serializer:' + defaultSerializer) ||\n container.lookup('serializer:-default');\n}\n\nfunction defaultSerializer(container) {\n return container.lookup('serializer:application') ||\n container.lookup('serializer:-default');\n}\n\nfunction serializerForAdapter(adapter, type) {\n var serializer = adapter.serializer,\n defaultSerializer = adapter.defaultSerializer,\n container = adapter.container;\n\n if (container && serializer === undefined) {\n serializer = serializerFor(container, type.typeKey, defaultSerializer);\n }\n\n if (serializer === null || serializer === undefined) {\n serializer = {\n extract: function(store, type, payload) { return payload; }\n };\n }\n\n return serializer;\n}\n\nfunction _find(adapter, store, type, id) {\n var promise = adapter.find(store, type, id),\n serializer = serializerForAdapter(adapter, type);\n\n return resolve(promise, \"DS: Handle Adapter#find of \" + type + \" with id: \" + id).then(function(payload) {\n Ember.assert(\"You made a request for a \" + type.typeKey + \" with id \" + id + \", but the adapter's response did not have any data\", payload);\n payload = serializer.extract(store, type, payload, id, 'find');\n\n return store.push(type, payload);\n }, function(error) {\n var record = store.getById(type, id);\n record.notFound();\n throw error;\n }, \"DS: Extract payload of '\" + type + \"'\");\n}\n\nfunction _findMany(adapter, store, type, ids, owner) {\n var promise = adapter.findMany(store, type, ids, owner),\n serializer = serializerForAdapter(adapter, type);\n\n return resolve(promise, \"DS: Handle Adapter#findMany of \" + type).then(function(payload) {\n payload = serializer.extract(store, type, payload, null, 'findMany');\n\n Ember.assert(\"The response from a findMany must be an Array, not \" + Ember.inspect(payload), Ember.typeOf(payload) === 'array');\n\n store.pushMany(type, payload);\n }, null, \"DS: Extract payload of \" + type);\n}\n\nfunction _findHasMany(adapter, store, record, link, relationship) {\n var promise = adapter.findHasMany(store, record, link, relationship),\n serializer = serializerForAdapter(adapter, relationship.type);\n\n return resolve(promise, \"DS: Handle Adapter#findHasMany of \" + record + \" : \" + relationship.type).then(function(payload) {\n payload = serializer.extract(store, relationship.type, payload, null, 'findHasMany');\n\n Ember.assert(\"The response from a findHasMany must be an Array, not \" + Ember.inspect(payload), Ember.typeOf(payload) === 'array');\n\n var records = store.pushMany(relationship.type, payload);\n record.updateHasMany(relationship.key, records);\n }, null, \"DS: Extract payload of \" + record + \" : hasMany \" + relationship.type);\n}\n\nfunction _findBelongsTo(adapter, store, record, link, relationship) {\n var promise = adapter.findBelongsTo(store, record, link, relationship),\n serializer = serializerForAdapter(adapter, relationship.type);\n\n return resolve(promise, \"DS: Handle Adapter#findBelongsTo of \" + record + \" : \" + relationship.type).then(function(payload) {\n payload = serializer.extract(store, relationship.type, payload, null, 'findBelongsTo');\n\n var record = store.push(relationship.type, payload);\n record.updateBelongsTo(relationship.key, record);\n return record;\n }, null, \"DS: Extract payload of \" + record + \" : \" + relationship.type);\n}\n\nfunction _findAll(adapter, store, type, sinceToken) {\n var promise = adapter.findAll(store, type, sinceToken),\n serializer = serializerForAdapter(adapter, type);\n\n return resolve(promise, \"DS: Handle Adapter#findAll of \" + type).then(function(payload) {\n payload = serializer.extract(store, type, payload, null, 'findAll');\n\n Ember.assert(\"The response from a findAll must be an Array, not \" + Ember.inspect(payload), Ember.typeOf(payload) === 'array');\n\n store.pushMany(type, payload);\n store.didUpdateAll(type);\n return store.all(type);\n }, null, \"DS: Extract payload of findAll \" + type);\n}\n\nfunction _findQuery(adapter, store, type, query, recordArray) {\n var promise = adapter.findQuery(store, type, query, recordArray),\n serializer = serializerForAdapter(adapter, type);\n\n return resolve(promise, \"DS: Handle Adapter#findQuery of \" + type).then(function(payload) {\n payload = serializer.extract(store, type, payload, null, 'findQuery');\n\n Ember.assert(\"The response from a findQuery must be an Array, not \" + Ember.inspect(payload), Ember.typeOf(payload) === 'array');\n\n recordArray.load(payload);\n return recordArray;\n }, null, \"DS: Extract payload of findQuery \" + type);\n}\n\nfunction _commit(adapter, store, operation, record) {\n var type = record.constructor,\n promise = adapter[operation](store, type, record),\n serializer = serializerForAdapter(adapter, type);\n\n Ember.assert(\"Your adapter's '\" + operation + \"' method must return a promise, but it returned \" + promise, isThenable(promise));\n\n return promise.then(function(payload) {\n if (payload) { payload = serializer.extract(store, type, payload, get(record, 'id'), operation); }\n store.didSaveRecord(record, payload);\n return record;\n }, function(reason) {\n if (reason instanceof DS.InvalidError) {\n store.recordWasInvalid(record, reason.errors);\n } else {\n store.recordWasError(record, reason);\n }\n\n throw reason;\n }, \"DS: Extract and notify about \" + operation + \" completion of \" + record);\n}\n\n})();\n//@ sourceURL=ember-data/system/store");minispade.register('ember-data/transforms/base', "(function() {/**\n The `DS.Transform` class is used to serialize and deserialize model\n attributes when they are saved or loaded from an\n adapter. Subclassing `DS.Transform` is useful for creating custom\n attributes. All subclasses of `DS.Transform` must implement a\n `serialize` and a `deserialize` method.\n\n Example\n\n ```javascript\n App.RawTransform = DS.Transform.extend({\n deserialize: function(serialized) {\n return serialized;\n },\n serialize: function(deserialized) {\n return deserialized;\n }\n });\n ```\n\n Usage\n\n ```javascript\n var attr = DS.attr;\n App.Requirement = DS.Model.extend({\n name: attr('string'),\n optionsArray: attr('raw')\n });\n ```\n\n @class Transform\n @namespace DS\n */\nDS.Transform = Ember.Object.extend({\n /**\n When given a deserialized value from a record attribute this\n method must return the serialized value.\n\n Example\n\n ```javascript\n serialize: function(deserialized) {\n return Ember.isEmpty(deserialized) ? null : Number(deserialized);\n }\n ```\n\n @method serialize\n @param deserialized The deserialized value\n @return The serialized value\n */\n serialize: Ember.required(),\n\n /**\n When given a serialize value from a JSON object this method must\n return the deserialized value for the record attribute.\n\n Example\n\n ```javascript\n deserialize: function(serialized) {\n return empty(serialized) ? null : Number(serialized);\n }\n ```\n\n @method deserialize\n @param serialized The serialized value\n @return The deserialized value\n */\n deserialize: Ember.required()\n\n});\n\n})();\n//@ sourceURL=ember-data/transforms/base");minispade.register('ember-data/transforms/boolean', "(function() {\n/**\n The `DS.BooleanTransform` class is used to serialize and deserialize\n boolean attributes on Ember Data record objects. This transform is\n used when `boolean` is passed as the type parameter to the\n [DS.attr](../../data#method_attr) function.\n\n Usage\n\n ```javascript\n var attr = DS.attr;\n App.User = DS.Model.extend({\n isAdmin: attr('boolean'),\n name: attr('string'),\n email: attr('string')\n });\n ```\n\n @class BooleanTransform\n @extends DS.Transform\n @namespace DS\n */\nDS.BooleanTransform = DS.Transform.extend({\n deserialize: function(serialized) {\n var type = typeof serialized;\n\n if (type === \"boolean\") {\n return serialized;\n } else if (type === \"string\") {\n return serialized.match(/^true$|^t$|^1$/i) !== null;\n } else if (type === \"number\") {\n return serialized === 1;\n } else {\n return false;\n }\n },\n\n serialize: function(deserialized) {\n return Boolean(deserialized);\n }\n});\n\n})();\n//@ sourceURL=ember-data/transforms/boolean");minispade.register('ember-data/transforms/date', "(function() {/**\n The `DS.DateTransform` class is used to serialize and deserialize\n date attributes on Ember Data record objects. This transform is used\n when `date` is passed as the type parameter to the\n [DS.attr](../../data#method_attr) function.\n\n ```javascript\n var attr = DS.attr;\n App.Score = DS.Model.extend({\n value: attr('number'),\n player: DS.belongsTo('player'),\n date: attr('date')\n });\n ```\n\n @class DateTransform\n @extends DS.Transform\n @namespace DS\n */\nDS.DateTransform = DS.Transform.extend({\n\n deserialize: function(serialized) {\n var type = typeof serialized;\n\n if (type === \"string\") {\n return new Date(Ember.Date.parse(serialized));\n } else if (type === \"number\") {\n return new Date(serialized);\n } else if (serialized === null || serialized === undefined) {\n // if the value is not present in the data,\n // return undefined, not null.\n return serialized;\n } else {\n return null;\n }\n },\n\n serialize: function(date) {\n if (date instanceof Date) {\n // Serialize it as a number to maintain millisecond precision\n return Number(date);\n } else {\n return null;\n }\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/transforms/date");minispade.register('ember-data/transforms/index', "(function() {minispade.require('ember-data/transforms/base');\nminispade.require('ember-data/transforms/boolean');\nminispade.require('ember-data/transforms/date');\nminispade.require('ember-data/transforms/number');\nminispade.require('ember-data/transforms/string');\n})();\n//@ sourceURL=ember-data/transforms/index");minispade.register('ember-data/transforms/number', "(function() {var empty = Ember.isEmpty;\n/**\n The `DS.NumberTransform` class is used to serialize and deserialize\n numeric attributes on Ember Data record objects. This transform is\n used when `number` is passed as the type parameter to the\n [DS.attr](../../data#method_attr) function.\n\n Usage\n\n ```javascript\n var attr = DS.attr;\n App.Score = DS.Model.extend({\n value: attr('number'),\n player: DS.belongsTo('player'),\n date: attr('date')\n });\n ```\n\n @class NumberTransform\n @extends DS.Transform\n @namespace DS\n */\nDS.NumberTransform = DS.Transform.extend({\n\n deserialize: function(serialized) {\n return empty(serialized) ? null : Number(serialized);\n },\n\n serialize: function(deserialized) {\n return empty(deserialized) ? null : Number(deserialized);\n }\n});\n\n})();\n//@ sourceURL=ember-data/transforms/number");minispade.register('ember-data/transforms/string', "(function() {var none = Ember.isNone;\n\n/**\n The `DS.StringTransform` class is used to serialize and deserialize\n string attributes on Ember Data record objects. This transform is\n used when `string` is passed as the type parameter to the\n [DS.attr](../../data#method_attr) function.\n\n Usage\n\n ```javascript\n var attr = DS.attr;\n App.User = DS.Model.extend({\n isAdmin: attr('boolean'),\n name: attr('string'),\n email: attr('string')\n });\n ```\n\n @class StringTransform\n @extends DS.Transform\n @namespace DS\n */\nDS.StringTransform = DS.Transform.extend({\n\n deserialize: function(serialized) {\n return none(serialized) ? null : String(serialized);\n },\n\n serialize: function(deserialized) {\n return none(deserialized) ? null : String(deserialized);\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/transforms/string");minispade.register('ember-inflector/ext/string', "(function() {minispade.require('ember-inflector/system/string');\n\nif (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) {\n /**\n See {{#crossLink \"Ember.String/pluralize\"}}{{/crossLink}}\n\n @method pluralize\n @for String\n */\n String.prototype.pluralize = function() {\n return Ember.String.pluralize(this);\n };\n\n /**\n See {{#crossLink \"Ember.String/singularize\"}}{{/crossLink}}\n\n @method singularize\n @for String\n */\n String.prototype.singularize = function() {\n return Ember.String.singularize(this);\n };\n}\n\n})();\n//@ sourceURL=ember-inflector/ext/string");minispade.register('ember-inflector', "(function() {minispade.require('ember-inflector/system');\n\n})();\n//@ sourceURL=ember-inflector");minispade.register('ember-inflector/system', "(function() {minispade.require('ember-inflector/system/string');\r\nminispade.require('ember-inflector/system/inflector');\r\nminispade.require('ember-inflector/system/inflections');\r\nminispade.require('ember-inflector/ext/string');\r\n\r\nEmber.Inflector.inflector = new Ember.Inflector(Ember.Inflector.defaultRules);\r\n\n})();\n//@ sourceURL=ember-inflector/system");minispade.register('ember-inflector/system/inflections', "(function() {Ember.Inflector.defaultRules = {\n plurals: [\n [/$/, 's'],\n [/s$/i, 's'],\n [/^(ax|test)is$/i, '$1es'],\n [/(octop|vir)us$/i, '$1i'],\n [/(octop|vir)i$/i, '$1i'],\n [/(alias|status)$/i, '$1es'],\n [/(bu)s$/i, '$1ses'],\n [/(buffal|tomat)o$/i, '$1oes'],\n [/([ti])um$/i, '$1a'],\n [/([ti])a$/i, '$1a'],\n [/sis$/i, 'ses'],\n [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'],\n [/(hive)$/i, '$1s'],\n [/([^aeiouy]|qu)y$/i, '$1ies'],\n [/(x|ch|ss|sh)$/i, '$1es'],\n [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'],\n [/^(m|l)ouse$/i, '$1ice'],\n [/^(m|l)ice$/i, '$1ice'],\n [/^(ox)$/i, '$1en'],\n [/^(oxen)$/i, '$1'],\n [/(quiz)$/i, '$1zes']\n ],\n\n singular: [\n [/s$/i, ''],\n [/(ss)$/i, '$1'],\n [/(n)ews$/i, '$1ews'],\n [/([ti])a$/i, '$1um'],\n [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'],\n [/(^analy)(sis|ses)$/i, '$1sis'],\n [/([^f])ves$/i, '$1fe'],\n [/(hive)s$/i, '$1'],\n [/(tive)s$/i, '$1'],\n [/([lr])ves$/i, '$1f'],\n [/([^aeiouy]|qu)ies$/i, '$1y'],\n [/(s)eries$/i, '$1eries'],\n [/(m)ovies$/i, '$1ovie'],\n [/(x|ch|ss|sh)es$/i, '$1'],\n [/^(m|l)ice$/i, '$1ouse'],\n [/(bus)(es)?$/i, '$1'],\n [/(o)es$/i, '$1'],\n [/(shoe)s$/i, '$1'],\n [/(cris|test)(is|es)$/i, '$1is'],\n [/^(a)x[ie]s$/i, '$1xis'],\n [/(octop|vir)(us|i)$/i, '$1us'],\n [/(alias|status)(es)?$/i, '$1'],\n [/^(ox)en/i, '$1'],\n [/(vert|ind)ices$/i, '$1ex'],\n [/(matr)ices$/i, '$1ix'],\n [/(quiz)zes$/i, '$1'],\n [/(database)s$/i, '$1']\n ],\n\n irregularPairs: [\n ['person', 'people'],\n ['man', 'men'],\n ['child', 'children'],\n ['sex', 'sexes'],\n ['move', 'moves'],\n ['cow', 'kine'],\n ['zombie', 'zombies']\n ],\n\n uncountable: [\n 'equipment',\n 'information',\n 'rice',\n 'money',\n 'species',\n 'series',\n 'fish',\n 'sheep',\n 'jeans',\n 'police'\n ]\n};\n\n})();\n//@ sourceURL=ember-inflector/system/inflections");minispade.register('ember-inflector/system/inflector', "(function() {var BLANK_REGEX = /^\\s*$/;\n\nfunction loadUncountable(rules, uncountable) {\n for (var i = 0, length = uncountable.length; i < length; i++) {\n rules.uncountable[uncountable[i].toLowerCase()] = true;\n }\n}\n\nfunction loadIrregular(rules, irregularPairs) {\n var pair;\n\n for (var i = 0, length = irregularPairs.length; i < length; i++) {\n pair = irregularPairs[i];\n\n rules.irregular[pair[0].toLowerCase()] = pair[1];\n rules.irregularInverse[pair[1].toLowerCase()] = pair[0];\n }\n}\n\n/**\n Inflector.Ember provides a mechanism for supplying inflection rules for your\n application. Ember includes a default set of inflection rules, and provides an\n API for providing additional rules.\n\n Examples:\n\n Creating an inflector with no rules.\n\n ```js\n var inflector = new Ember.Inflector();\n ```\n\n Creating an inflector with the default ember ruleset.\n\n ```js\n var inflector = new Ember.Inflector(Ember.Inflector.defaultRules);\n\n inflector.pluralize('cow') //=> 'kine'\n inflector.singularize('kine') //=> 'cow'\n ```\n\n Creating an inflector and adding rules later.\n\n ```javascript\n var inflector = Ember.Inflector.inflector;\n\n inflector.pluralize('advice') // => 'advices'\n inflector.uncountable('advice');\n inflector.pluralize('advice') // => 'advice'\n\n inflector.pluralize('formula') // => 'formulas'\n inflector.irregular('formula', 'formulae');\n inflector.pluralize('formula') // => 'formulae'\n\n // you would not need to add these as they are the default rules\n inflector.plural(/$/, 's');\n inflector.singular(/s$/i, '');\n ```\n\n Creating an inflector with a nondefault ruleset.\n\n ```javascript\n var rules = {\n plurals: [ /$/, 's' ],\n singular: [ /\\s$/, '' ],\n irregularPairs: [\n [ 'cow', 'kine' ]\n ],\n uncountable: [ 'fish' ]\n };\n\n var inflector = new Ember.Inflector(rules);\n ```\n\n @class Inflector\n @namespace Ember\n*/\nfunction Inflector(ruleSet) {\n ruleSet = ruleSet || {};\n ruleSet.uncountable = ruleSet.uncountable || {};\n ruleSet.irregularPairs = ruleSet.irregularPairs || {};\n\n var rules = this.rules = {\n plurals: ruleSet.plurals || [],\n singular: ruleSet.singular || [],\n irregular: {},\n irregularInverse: {},\n uncountable: {}\n };\n\n loadUncountable(rules, ruleSet.uncountable);\n loadIrregular(rules, ruleSet.irregularPairs);\n}\n\nInflector.prototype = {\n /**\n @method plural\n @param {RegExp} regex\n @param {String} string\n */\n plural: function(regex, string) {\n this.rules.plurals.push([regex, string.toLowerCase()]);\n },\n\n /**\n @method singular\n @param {RegExp} regex\n @param {String} string\n */\n singular: function(regex, string) {\n this.rules.singular.push([regex, string.toLowerCase()]);\n },\n\n /**\n @method uncountable\n @param {String} regex\n */\n uncountable: function(string) {\n loadUncountable(this.rules, [string.toLowerCase()]);\n },\n\n /**\n @method irregular\n @param {String} singular\n @param {String} plural\n */\n irregular: function (singular, plural) {\n loadIrregular(this.rules, [[singular, plural]]);\n },\n\n /**\n @method pluralize\n @param {String} word\n */\n pluralize: function(word) {\n return this.inflect(word, this.rules.plurals, this.rules.irregular);\n },\n\n /**\n @method singularize\n @param {String} word\n */\n singularize: function(word) {\n return this.inflect(word, this.rules.singular, this.rules.irregularInverse);\n },\n\n /**\n @protected\n\n @method inflect\n @param {String} word\n @param {Object} typeRules\n @param {Object} irregular\n */\n inflect: function(word, typeRules, irregular) {\n var inflection, substitution, result, lowercase, isBlank,\n isUncountable, isIrregular, isIrregularInverse, rule;\n\n isBlank = BLANK_REGEX.test(word);\n\n if (isBlank) {\n return word;\n }\n\n lowercase = word.toLowerCase();\n\n isUncountable = this.rules.uncountable[lowercase];\n\n if (isUncountable) {\n return word;\n }\n\n isIrregular = irregular && irregular[lowercase];\n\n if (isIrregular) {\n return isIrregular;\n }\n\n for (var i = typeRules.length, min = 0; i > min; i--) {\n inflection = typeRules[i-1];\n rule = inflection[0];\n\n if (rule.test(word)) {\n break;\n }\n }\n\n inflection = inflection || [];\n\n rule = inflection[0];\n substitution = inflection[1];\n\n result = word.replace(rule, substitution);\n\n return result;\n }\n};\n\nEmber.Inflector = Inflector;\n\n})();\n//@ sourceURL=ember-inflector/system/inflector");minispade.register('ember-inflector/system/string', "(function() {Ember.String.pluralize = function(word) {\n return Ember.Inflector.inflector.pluralize(word);\n};\n\nEmber.String.singularize = function(word) {\n return Ember.Inflector.inflector.singularize(word);\n};\n\n})();\n//@ sourceURL=ember-inflector/system/string");
@@ -3,7 +3,7 @@
3
3
  * @copyright Copyright 2011-2014 Tilde Inc. and contributors.
4
4
  * Portions Copyright 2011 LivingSocial Inc.
5
5
  * @license Licensed under MIT license (see license.js)
6
- * @version 1.0.0-beta.5
6
+ * @version 1.0.0-beta.6
7
7
  */
8
8
 
9
9
 
@@ -39,7 +39,9 @@ var JSHINTRC = {
39
39
  "async",
40
40
  "invokeAsync",
41
41
  "jQuery",
42
- "expectAssertion"
42
+ "expectAssertion",
43
+ "expectDeprecation"
44
+
43
45
  ],
44
46
 
45
47
  "node" : false,
@@ -71,4 +73,4 @@ var JSHINTRC = {
71
73
  }
72
74
  ;
73
75
 
74
- minispade.register('activemodel-adapter/~tests/integration/active_model_adapter_test', "(function() {var env, store, adapter, SuperUser;\nvar originalAjax, passedUrl, passedVerb, passedHash;\nmodule(\"integration/active_model_adapter - AMS Adapter\", {\n setup: function() {\n SuperUser = DS.Model.extend();\n\n env = setupStore({\n superUser: SuperUser,\n adapter: DS.ActiveModelAdapter\n });\n\n store = env.store;\n adapter = env.adapter;\n\n passedUrl = passedVerb = passedHash = null;\n }\n});\n\nfunction ajaxResponse(value) {\n adapter.ajax = function(url, verb, hash) {\n passedUrl = url;\n passedVerb = verb;\n passedHash = hash;\n\n return Ember.RSVP.resolve(value);\n };\n}\n\ntest('buildURL - decamelizes names', function() {\n equal(adapter.buildURL('superUser', 1), \"/super_users/1\");\n});\n\ntest('ajaxError - returns invalid error if 422 response', function() {\n var error = new DS.InvalidError({ name: \"can't be blank\" });\n\n var jqXHR = {\n status: 422,\n responseText: JSON.stringify({ errors: { name: \"can't be blank\" } })\n };\n\n equal(adapter.ajaxError(jqXHR), error.toString());\n});\n\ntest('ajaxError - invalid error has camelized keys', function() {\n var error = new DS.InvalidError({ firstName: \"can't be blank\" });\n\n var jqXHR = {\n status: 422,\n responseText: JSON.stringify({ errors: { first_name: \"can't be blank\" } })\n };\n\n equal(adapter.ajaxError(jqXHR), error.toString());\n});\n\ntest('ajaxError - returns ajax response if not 422 response', function() {\n var jqXHR = {\n status: 500,\n responseText: \"Something went wrong\"\n };\n\n equal(adapter.ajaxError(jqXHR), jqXHR);\n});\n\n})();\n//@ sourceURL=activemodel-adapter/~tests/integration/active_model_adapter_test");minispade.register('activemodel-adapter/~tests/integration/active_model_serializer_test', "(function() {var get = Ember.get, set = Ember.set;\nvar HomePlanet, league, SuperVillain, superVillain, EvilMinion, YellowMinion, DoomsdayDevice, MediocreVillain, env;\n\nmodule(\"integration/active_model - ActiveModelSerializer\", {\n setup: function() {\n SuperVillain = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n homePlanet: DS.belongsTo(\"homePlanet\"),\n evilMinions: DS.hasMany(\"evilMinion\")\n });\n HomePlanet = DS.Model.extend({\n name: DS.attr('string'),\n superVillains: DS.hasMany('superVillain', {async: true})\n });\n EvilMinion = DS.Model.extend({\n superVillain: DS.belongsTo('superVillain'),\n name: DS.attr('string')\n });\n YellowMinion = EvilMinion.extend();\n DoomsdayDevice = DS.Model.extend({\n name: DS.attr('string'),\n evilMinion: DS.belongsTo('evilMinion', {polymorphic: true})\n });\n MediocreVillain = DS.Model.extend({\n name: DS.attr('string'),\n evilMinions: DS.hasMany('evilMinion', {polymorphic: true})\n });\n env = setupStore({\n superVillain: SuperVillain,\n homePlanet: HomePlanet,\n evilMinion: EvilMinion,\n yellowMinion: YellowMinion,\n doomsdayDevice: DoomsdayDevice,\n mediocreVillain: MediocreVillain\n });\n env.store.modelFor('superVillain');\n env.store.modelFor('homePlanet');\n env.store.modelFor('evilMinion');\n env.store.modelFor('yellowMinion');\n env.store.modelFor('doomsdayDevice');\n env.store.modelFor('mediocreVillain');\n env.container.register('serializer:application', DS.ActiveModelSerializer);\n env.container.register('serializer:ams', DS.ActiveModelSerializer);\n env.container.register('adapter:ams', DS.ActiveModelAdapter);\n env.amsSerializer = env.container.lookup(\"serializer:ams\");\n env.amsAdapter = env.container.lookup(\"adapter:ams\");\n },\n\n teardown: function() {\n env.store.destroy();\n }\n});\n\ntest(\"serialize\", function() {\n league = env.store.createRecord(HomePlanet, { name: \"Villain League\", id: \"123\" });\n var tom = env.store.createRecord(SuperVillain, { firstName: \"Tom\", lastName: \"Dale\", homePlanet: league });\n\n var json = env.amsSerializer.serialize(tom);\n\n deepEqual(json, {\n first_name: \"Tom\",\n last_name: \"Dale\",\n home_planet_id: get(league, \"id\")\n });\n});\n\ntest(\"serializeIntoHash\", function() {\n league = env.store.createRecord(HomePlanet, { name: \"Umber\", id: \"123\" });\n var json = {};\n\n env.amsSerializer.serializeIntoHash(json, HomePlanet, league);\n\n deepEqual(json, {\n home_planet: {\n name: \"Umber\"\n }\n });\n});\n\ntest(\"normalize\", function() {\n var superVillain_hash = {first_name: \"Tom\", last_name: \"Dale\", home_planet_id: \"123\", evil_minion_ids: [1,2]};\n\n var json = env.amsSerializer.normalize(SuperVillain, superVillain_hash, \"superVillain\");\n\n deepEqual(json, {\n firstName: \"Tom\",\n lastName: \"Dale\",\n homePlanet: \"123\",\n evilMinions: [1,2]\n });\n});\n\ntest(\"normalize links\", function() {\n var home_planet = {\n id: \"1\",\n name: \"Umber\",\n links: { super_villains: \"/api/super_villians/1\" }\n };\n\n\n var json = env.amsSerializer.normalize(HomePlanet, home_planet, \"homePlanet\");\n\n equal(json.links.superVillains, \"/api/super_villians/1\", \"normalize links\");\n});\n\ntest(\"extractSingle\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n\n var json_hash = {\n home_planet: {id: \"1\", name: \"Umber\", super_villain_ids: [1]},\n super_villains: [{\n id: \"1\",\n first_name: \"Tom\",\n last_name: \"Dale\",\n home_planet_id: \"1\"\n }]\n };\n\n var json = env.amsSerializer.extractSingle(env.store, HomePlanet, json_hash);\n\n deepEqual(json, {\n \"id\": \"1\",\n \"name\": \"Umber\",\n \"superVillains\": [1]\n });\n\n env.store.find(\"superVillain\", 1).then(async(function(minion){\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"extractArray\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n\n var json_hash = {\n home_planets: [{id: \"1\", name: \"Umber\", super_villain_ids: [1]}],\n super_villains: [{id: \"1\", first_name: \"Tom\", last_name: \"Dale\", home_planet_id: \"1\"}]\n };\n\n var array = env.amsSerializer.extractArray(env.store, HomePlanet, json_hash);\n\n deepEqual(array, [{\n \"id\": \"1\",\n \"name\": \"Umber\",\n \"superVillains\": [1]\n }]);\n\n env.store.find(\"superVillain\", 1).then(async(function(minion){\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"serialize polymorphic\", function() {\n var tom = env.store.createRecord(YellowMinion, {name: \"Alex\", id: \"124\"});\n var ray = env.store.createRecord(DoomsdayDevice, {evilMinion: tom, name: \"DeathRay\"});\n\n var json = env.amsSerializer.serialize(ray);\n\n deepEqual(json, {\n name: \"DeathRay\",\n evil_minion_type: \"YellowMinion\",\n evil_minion_id: \"124\"\n });\n});\n\ntest(\"extractPolymorphic hasMany\", function() {\n env.container.register('adapter:yellowMinion', DS.ActiveModelAdapter);\n MediocreVillain.toString = function() { return \"MediocreVillain\"; };\n YellowMinion.toString = function() { return \"YellowMinion\"; };\n\n var json_hash = {\n mediocre_villain: {id: 1, name: \"Dr Horrible\", evil_minions: [{ type: \"yellow_minion\", id: 12}] },\n evil_minions: [{id: 12, name: \"Alex\", doomsday_device_ids: [1] }]\n };\n\n var json = env.amsSerializer.extractSingle(env.store, MediocreVillain, json_hash);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"Dr Horrible\",\n \"evilMinions\": [{\n type: \"yellowMinion\",\n id: 12\n }]\n });\n});\n\ntest(\"extractPolymorphic\", function() {\n env.container.register('adapter:yellowMinion', DS.ActiveModelAdapter);\n EvilMinion.toString = function() { return \"EvilMinion\"; };\n YellowMinion.toString = function() { return \"YellowMinion\"; };\n\n var json_hash = {\n doomsday_device: {id: 1, name: \"DeathRay\", evil_minion: { type: \"yellow_minion\", id: 12}},\n evil_minions: [{id: 12, name: \"Alex\", doomsday_device_ids: [1] }]\n };\n\n var json = env.amsSerializer.extractSingle(env.store, DoomsdayDevice, json_hash);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"DeathRay\",\n \"evilMinion\": {\n type: \"yellowMinion\",\n id: 12\n }\n });\n});\n\ntest(\"extractPolymorphic when the related data is not specified\", function() {\n var json = {\n doomsday_device: {id: 1, name: \"DeathRay\"},\n evil_minions: [{id: 12, name: \"Alex\", doomsday_device_ids: [1] }]\n };\n\n json = env.amsSerializer.extractSingle(env.store, DoomsdayDevice, json);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"DeathRay\",\n \"evilMinion\": undefined\n });\n});\n\ntest(\"extractPolymorphic hasMany when the related data is not specified\", function() {\n var json = {\n mediocre_villain: {id: 1, name: \"Dr Horrible\"}\n };\n\n json = env.amsSerializer.extractSingle(env.store, MediocreVillain, json);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"Dr Horrible\",\n \"evilMinions\": undefined\n });\n});\n\ntest(\"extractPolymorphic does not break hasMany relationships\", function() {\n var json = {\n mediocre_villain: {id: 1, name: \"Dr. Evil\", evil_minions: []}\n };\n\n json = env.amsSerializer.extractSingle(env.store, MediocreVillain, json);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"Dr. Evil\",\n \"evilMinions\": []\n });\n});\n\n})();\n//@ sourceURL=activemodel-adapter/~tests/integration/active_model_serializer_test");minispade.register('activemodel-adapter/~tests/integration/embedded_records_mixin_test', "(function() {var get = Ember.get, set = Ember.set;\nvar HomePlanet, league, SuperVillain, superVillain, EvilMinion, Comment, env;\n\nmodule(\"integration/embedded_records_mixin - EmbeddedRecordsMixin\", {\n setup: function() {\n SuperVillain = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n homePlanet: DS.belongsTo(\"homePlanet\"),\n evilMinions: DS.hasMany(\"evilMinion\")\n });\n HomePlanet = DS.Model.extend({\n name: DS.attr('string'),\n villains: DS.hasMany('superVillain')\n });\n EvilMinion = DS.Model.extend({\n superVillain: DS.belongsTo('superVillain'),\n name: DS.attr('string')\n });\n Comment = DS.Model.extend({\n body: DS.attr('string'),\n root: DS.attr('boolean'),\n children: DS.hasMany('comment')\n });\n env = setupStore({\n superVillain: SuperVillain,\n homePlanet: HomePlanet,\n evilMinion: EvilMinion,\n comment: Comment\n });\n env.store.modelFor('superVillain');\n env.store.modelFor('homePlanet');\n env.store.modelFor('evilMinion');\n env.store.modelFor('comment');\n env.container.register('serializer:application', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin));\n env.container.register('serializer:ams', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin));\n env.container.register('adapter:ams', DS.ActiveModelAdapter);\n env.amsSerializer = env.container.lookup(\"serializer:ams\");\n env.amsAdapter = env.container.lookup(\"adapter:ams\");\n },\n\n teardown: function() {\n env.store.destroy();\n }\n});\n\ntest(\"extractSingle with embedded objects\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n var json_hash = {\n home_planet: {\n id: \"1\",\n name: \"Umber\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\",\n last_name: \"Dale\"\n }]\n }\n };\n\n var json = serializer.extractSingle(env.store, HomePlanet, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n name: \"Umber\",\n villains: [\"1\"]\n });\n env.store.find(\"superVillain\", 1).then(async(function(minion) {\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"extractSingle with embedded objects inside embedded objects\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'}\n }\n }));\n env.container.register('serializer:superVillain', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n evilMinions: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n var json_hash = {\n home_planet: {\n id: \"1\",\n name: \"Umber\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\",\n last_name: \"Dale\",\n evil_minions: [{\n id: \"1\",\n name: \"Alex\"\n }]\n }]\n }\n };\n\n var json = serializer.extractSingle(env.store, HomePlanet, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n name: \"Umber\",\n villains: [\"1\"]\n });\n env.store.find(\"superVillain\", 1).then(async(function(villain) {\n equal(villain.get('firstName'), \"Tom\");\n equal(villain.get('evilMinions.length'), 1, \"Should load the embedded child\");\n equal(villain.get('evilMinions.firstObject.name'), \"Alex\", \"Should load the embedded child\");\n }));\n env.store.find(\"evilMinion\", 1).then(async(function(minion) {\n equal(minion.get('name'), \"Alex\");\n }));\n});\n\ntest(\"extractSingle with embedded objects of same type\", function() {\n env.container.register('adapter:comment', DS.ActiveModelAdapter);\n env.container.register('serializer:comment', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n children: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:comment\");\n var json_hash = {\n comment: {\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [{\n id: \"2\",\n body: \"World\",\n root: false\n },\n {\n id: \"3\",\n body: \"Foo\",\n root: false\n }]\n }\n };\n var json = serializer.extractSingle(env.store, Comment, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [\"2\", \"3\"]\n }, \"Primary record was correct\");\n equal(env.store.recordForId(\"comment\", \"2\").get(\"body\"), \"World\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"comment\", \"3\").get(\"body\"), \"Foo\", \"Secondary records found in the store\");\n});\n\ntest(\"extractSingle with embedded objects inside embedded objects of same type\", function() {\n env.container.register('adapter:comment', DS.ActiveModelAdapter);\n env.container.register('serializer:comment', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n children: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:comment\");\n var json_hash = {\n comment: {\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [{\n id: \"2\",\n body: \"World\",\n root: false,\n children: [{\n id: \"4\",\n body: \"Another\",\n root: false\n }]\n },\n {\n id: \"3\",\n body: \"Foo\",\n root: false\n }]\n }\n };\n var json = serializer.extractSingle(env.store, Comment, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [\"2\", \"3\"]\n }, \"Primary record was correct\");\n equal(env.store.recordForId(\"comment\", \"2\").get(\"body\"), \"World\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"comment\", \"3\").get(\"body\"), \"Foo\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"comment\", \"4\").get(\"body\"), \"Another\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"comment\", \"2\").get(\"children.length\"), 1, \"Should have one embedded record\");\n equal(env.store.recordForId(\"comment\", \"2\").get(\"children.firstObject.body\"), \"Another\", \"Should have one embedded record\");\n});\n\ntest(\"extractSingle with embedded objects of same type, but from separate attributes\", function() {\n HomePlanet.reopen({\n reformedVillains: DS.hasMany('superVillain')\n });\n\n env.container.register('adapter:home_planet', DS.ActiveModelAdapter);\n env.container.register('serializer:home_planet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'},\n reformedVillains: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:home_planet\");\n var json_hash = {\n home_planet: {\n id: \"1\",\n name: \"Earth\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\"\n }, {\n id: \"3\",\n first_name: \"Yehuda\"\n }],\n reformed_villains: [{\n id: \"2\",\n first_name: \"Alex\"\n },{\n id: \"4\",\n first_name: \"Erik\"\n }]\n }\n };\n var json = serializer.extractSingle(env.store, HomePlanet, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n name: \"Earth\",\n villains: [\"1\", \"3\"],\n reformedVillains: [\"2\", \"4\"]\n }, \"Primary array was correct\");\n\n equal(env.store.recordForId(\"superVillain\", \"1\").get(\"firstName\"), \"Tom\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"2\").get(\"firstName\"), \"Alex\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"3\").get(\"firstName\"), \"Yehuda\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"4\").get(\"firstName\"), \"Erik\", \"Secondary records found in the store\");\n});\n\ntest(\"extractArray with embedded objects\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n\n var json_hash = {\n home_planets: [{\n id: \"1\",\n name: \"Umber\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\",\n last_name: \"Dale\"\n }]\n }]\n };\n\n var array = serializer.extractArray(env.store, HomePlanet, json_hash);\n\n deepEqual(array, [{\n id: \"1\",\n name: \"Umber\",\n villains: [\"1\"]\n }]);\n\n env.store.find(\"superVillain\", 1).then(async(function(minion){\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"extractArray with embedded objects of same type as primary type\", function() {\n env.container.register('adapter:comment', DS.ActiveModelAdapter);\n env.container.register('serializer:comment', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n children: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:comment\");\n\n var json_hash = {\n comments: [{\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [{\n id: \"2\",\n body: \"World\",\n root: false\n },\n {\n id: \"3\",\n body: \"Foo\",\n root: false\n }]\n }]\n };\n\n var array = serializer.extractArray(env.store, Comment, json_hash);\n\n deepEqual(array, [{\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [\"2\", \"3\"]\n }], \"Primary array is correct\");\n\n equal(env.store.recordForId(\"comment\", \"2\").get(\"body\"), \"World\", \"Secondary record found in the store\");\n equal(env.store.recordForId(\"comment\", \"3\").get(\"body\"), \"Foo\", \"Secondary record found in the store\");\n});\n\ntest(\"extractArray with embedded objects of same type, but from separate attributes\", function() {\n HomePlanet.reopen({\n reformedVillains: DS.hasMany('superVillain')\n });\n\n env.container.register('adapter:homePlanet', DS.ActiveModelAdapter);\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'},\n reformedVillains: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n var json_hash = {\n home_planets: [{\n id: \"1\",\n name: \"Earth\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\"\n },{\n id: \"3\",\n first_name: \"Yehuda\"\n }],\n reformed_villains: [{\n id: \"2\",\n first_name: \"Alex\"\n },{\n id: \"4\",\n first_name: \"Erik\"\n }]\n },{\n id: \"2\",\n name: \"Mars\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\"\n },{\n id: \"3\",\n first_name: \"Yehuda\"\n }],\n reformed_villains: [{\n id: \"5\",\n first_name: \"Peter\"\n },{\n id: \"6\",\n first_name: \"Trek\"\n }]\n }]\n };\n var json = serializer.extractArray(env.store, HomePlanet, json_hash);\n\n deepEqual(json, [{\n id: \"1\",\n name: \"Earth\",\n villains: [\"1\", \"3\"],\n reformedVillains: [\"2\", \"4\"]\n },{\n id: \"2\",\n name: \"Mars\",\n villains: [\"1\", \"3\"],\n reformedVillains: [\"5\", \"6\"]\n }], \"Primary array was correct\");\n\n equal(env.store.recordForId(\"superVillain\", \"1\").get(\"firstName\"), \"Tom\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"2\").get(\"firstName\"), \"Alex\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"3\").get(\"firstName\"), \"Yehuda\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"4\").get(\"firstName\"), \"Erik\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"5\").get(\"firstName\"), \"Peter\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"6\").get(\"firstName\"), \"Trek\", \"Secondary records found in the store\");\n});\n\ntest(\"serialize with embedded objects\", function() {\n league = env.store.createRecord(HomePlanet, { name: \"Villain League\", id: \"123\" });\n var tom = env.store.createRecord(SuperVillain, { firstName: \"Tom\", lastName: \"Dale\", homePlanet: league });\n\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'}\n }\n }));\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n\n var json = serializer.serialize(league);\n\n deepEqual(json, {\n name: \"Villain League\",\n villains: [{\n id: get(tom, \"id\"),\n first_name: \"Tom\",\n last_name: \"Dale\",\n home_planet_id: get(league, \"id\")\n }]\n });\n});\n})();\n//@ sourceURL=activemodel-adapter/~tests/integration/embedded_records_mixin_test");minispade.register('ember-data/~tests/integration/adapter/find_all_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar Person, adapter, store, allRecords;\n\nmodule(\"integration/adapter/find_all - Finding All Records of a Type\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: DS.attr('string'),\n name: DS.attr('string'),\n firstName: DS.attr('string'),\n lastName: DS.attr('string')\n });\n\n allRecords = null;\n },\n\n teardown: function() {\n if (allRecords) { allRecords.destroy(); }\n store.destroy();\n }\n});\n\ntest(\"When all records for a type are requested, the store should call the adapter's `findAll` method.\", function() {\n expect(5);\n\n store = createStore({ adapter: DS.Adapter.extend({\n findAll: function(store, type, since) {\n // this will get called twice\n ok(true, \"the adapter's findAll method should be invoked\");\n\n return Ember.RSVP.resolve([{ id: 1, name: \"Braaaahm Dale\" }]);\n }\n })\n });\n\n var allRecords;\n\n store.find(Person).then(async(function(all) {\n allRecords = all;\n equal(get(all, 'length'), 1, \"the record array's length is 1 after a record is loaded into it\");\n equal(all.objectAt(0).get('name'), \"Braaaahm Dale\", \"the first item in the record array is Braaaahm Dale\");\n }));\n\n store.find(Person).then(async(function(all) {\n // Only one record array per type should ever be created (identity map)\n strictEqual(allRecords, all, \"the same record array is returned every time all records of a type are requested\");\n }));\n});\n\ntest(\"When all records for a type are requested, a rejection should reject the promise\", function() {\n expect(5);\n\n var count = 0;\n store = createStore({ adapter: DS.Adapter.extend({\n findAll: function(store, type, since) {\n // this will get called twice\n ok(true, \"the adapter's findAll method should be invoked\");\n\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve([{ id: 1, name: \"Braaaahm Dale\" }]);\n }\n }\n })\n });\n\n var allRecords;\n\n store.find(Person).then(null, async(function() {\n ok(true, \"The rejection should get here\");\n return store.find(Person);\n })).then(async(function(all) {\n allRecords = all;\n equal(get(all, 'length'), 1, \"the record array's length is 1 after a record is loaded into it\");\n equal(all.objectAt(0).get('name'), \"Braaaahm Dale\", \"the first item in the record array is Braaaahm Dale\");\n }));\n});\n\ntest(\"When all records for a type are requested, records that are already loaded should be returned immediately.\", function() {\n expect(3);\n\n // Load a record from the server\n store.push(Person, { id: 1, name: \"Jeremy Ashkenas\" });\n\n // Create a new, unsaved record in the store\n store.createRecord(Person, { name: \"Alex MacCaw\" });\n\n allRecords = store.all(Person);\n\n equal(get(allRecords, 'length'), 2, \"the record array's length is 2\");\n equal(allRecords.objectAt(0).get('name'), \"Jeremy Ashkenas\", \"the first item in the record array is Jeremy Ashkenas\");\n equal(allRecords.objectAt(1).get('name'), \"Alex MacCaw\", \"the second item in the record array is Alex MacCaw\");\n});\n\ntest(\"When all records for a type are requested, records that are created on the client should be added to the record array.\", function() {\n expect(3);\n\n allRecords = store.all(Person);\n\n equal(get(allRecords, 'length'), 0, \"precond - the record array's length is zero before any records are loaded\");\n\n store.createRecord(Person, { name: \"Carsten Nielsen\" });\n\n equal(get(allRecords, 'length'), 1, \"the record array's length is 1\");\n equal(allRecords.objectAt(0).get('name'), \"Carsten Nielsen\", \"the first item in the record array is Carsten Nielsen\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/find_all_test");minispade.register('ember-data/~tests/integration/adapter/find_test', "(function() {var get = Ember.get, set = Ember.set;\nvar Person, store, adapter;\n\nmodule(\"integration/adapter/find - Finding Records\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: DS.attr('string'),\n name: DS.attr('string'),\n firstName: DS.attr('string'),\n lastName: DS.attr('string')\n });\n },\n\n teardown: function() {\n store.destroy();\n }\n});\n\ntest(\"When a single record is requested, the adapter's find method should be called unless it's loaded.\", function() {\n expect(2);\n\n var count = 0;\n\n store = createStore({ adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n equal(type, Person, \"the find method is called with the correct type\");\n equal(count, 0, \"the find method is only called once\");\n\n count++;\n return { id: 1, name: \"Braaaahm Dale\" };\n }\n })\n });\n\n store.find(Person, 1);\n store.find(Person, 1);\n});\n\ntest(\"When a single record is requested multiple times, all .find() calls are resolved after the promise is resolved\", function() {\n var deferred = Ember.RSVP.defer();\n\n store = createStore({ adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n return deferred.promise;\n }\n })\n });\n\n store.find(Person, 1).then(async(function(person) {\n equal(person.get('id'), \"1\");\n equal(person.get('name'), \"Braaaahm Dale\");\n\n stop();\n deferred.promise.then(function(value){\n start();\n ok(true, 'expected deferred.promise to fulfill');\n },function(reason){\n start();\n ok(false, 'expected deferred.promise to fulfill, but rejected');\n });\n }));\n\n store.find(Person, 1).then(async(function(post) {\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Braaaahm Dale\");\n\n stop();\n deferred.promise.then(function(value){\n start();\n ok(true, 'expected deferred.promise to fulfill');\n }, function(reason){\n start();\n ok(false, 'expected deferred.promise to fulfill, but rejected');\n });\n\n }));\n\n Ember.run(function() {\n deferred.resolve({ id: 1, name: \"Braaaahm Dale\" });\n });\n});\n\ntest(\"When a single record is requested, and the promise is rejected, .find() is rejected.\", function() {\n var count = 0;\n\n store = createStore({ adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.reject();\n }\n })\n });\n\n store.find(Person, 1).then(null, async(function(reason) {\n ok(true, \"The rejection handler was called\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/find_test");minispade.register('ember-data/~tests/integration/adapter/fixture_adapter_test', "(function() {var get = Ember.get, set = Ember.set;\nvar env, Person, Phone, App;\n\nmodule(\"integration/adapter/fixture_adapter - DS.FixtureAdapter\", {\n setup: function() {\n Person = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n\n height: DS.attr('number'),\n\n phones: DS.hasMany('phone', { async: true })\n });\n\n Phone = DS.Model.extend({\n person: DS.belongsTo('person')\n });\n\n env = setupStore({ person: Person, phone: Phone, adapter: DS.FixtureAdapter });\n env.adapter.simulateRemoteResponse = true;\n\n // Enable setTimeout.\n Ember.testing = false;\n\n Person.FIXTURES = [];\n Phone.FIXTURES = [];\n },\n teardown: function() {\n Ember.testing = true;\n\n env.container.destroy();\n }\n});\n\ntest(\"should load data for a type asynchronously when it is requested\", function() {\n Person.FIXTURES = [{\n id: 'wycats',\n firstName: \"Yehuda\",\n lastName: \"Katz\",\n\n height: 65\n },\n\n {\n id: 'ebryn',\n firstName: \"Erik\",\n lastName: \"Brynjolffsosysdfon\",\n\n height: 70,\n phones: [1, 2]\n }];\n\n Phone.FIXTURES = [{\n id: 1,\n person: 'ebryn'\n }, {\n id: 2,\n person: 'ebryn'\n }];\n\n env.store.find('person', 'ebryn').then(async(function(ebryn) {\n equal(get(ebryn, 'isLoaded'), true, \"data loads asynchronously\");\n equal(get(ebryn, 'height'), 70, \"data from fixtures is loaded correctly\");\n\n return Ember.RSVP.hash({ ebryn: ebryn, wycats: env.store.find('person', 'wycats') });\n }, 1000)).then(async(function(records) {\n equal(get(records.wycats, 'isLoaded'), true, \"subsequent requests for records are returned asynchronously\");\n equal(get(records.wycats, 'height'), 65, \"subsequent requested records contain correct information\");\n\n return get(records.ebryn, 'phones');\n }, 1000)).then(async(function(phones) {\n equal(get(phones, 'length'), 2, \"relationships from fixtures is loaded correctly\");\n }, 1000));\n});\n\ntest(\"should load data asynchronously at the end of the runloop when simulateRemoteResponse is false\", function() {\n Person.FIXTURES = [{\n id: 'wycats',\n firstName: \"Yehuda\"\n }];\n\n env.adapter.simulateRemoteResponse = false;\n\n var wycats;\n\n Ember.run(function() {\n env.store.find('person', 'wycats').then(function(person) {\n wycats = person;\n });\n });\n\n ok(get(wycats, 'isLoaded'), 'isLoaded is true after runloop finishes');\n equal(get(wycats, 'firstName'), 'Yehuda', 'record properties are defined after runloop finishes');\n});\n\ntest(\"should create record asynchronously when it is committed\", function() {\n equal(Person.FIXTURES.length, 0, \"Fixtures is empty\");\n\n var paul = env.store.createRecord('person', {firstName: 'Paul', lastName: 'Chavard', height: 70});\n\n paul.on('didCreate', async(function() {\n equal(get(paul, 'isNew'), false, \"data loads asynchronously\");\n equal(get(paul, 'isDirty'), false, \"data loads asynchronously\");\n equal(get(paul, 'height'), 70, \"data from fixtures is saved correctly\");\n\n equal(Person.FIXTURES.length, 1, \"Record added to FIXTURES\");\n\n var fixture = Person.FIXTURES[0];\n\n ok(typeof fixture.id === 'string', \"The fixture has an ID generated for it\");\n equal(fixture.firstName, 'Paul');\n equal(fixture.lastName, 'Chavard');\n equal(fixture.height, 70);\n }));\n\n paul.save();\n});\n\ntest(\"should update record asynchronously when it is committed\", function() {\n equal(Person.FIXTURES.length, 0, \"Fixtures is empty\");\n\n var paul = env.store.push('person', { id: 1, firstName: 'Paul', lastName: 'Chavard', height: 70});\n\n paul.set('height', 80);\n\n paul.on('didUpdate', async(function() {\n equal(get(paul, 'isDirty'), false, \"data loads asynchronously\");\n equal(get(paul, 'height'), 80, \"data from fixtures is saved correctly\");\n\n equal(Person.FIXTURES.length, 1, \"Record FIXTURES updated\");\n\n var fixture = Person.FIXTURES[0];\n\n equal(fixture.firstName, 'Paul');\n equal(fixture.lastName, 'Chavard');\n equal(fixture.height, 80);\n }, 1000));\n\n paul.save();\n});\n\ntest(\"should delete record asynchronously when it is committed\", function() {\n stop();\n\n var timer = setTimeout(function() {\n start();\n ok(false, \"timeout exceeded waiting for fixture data\");\n }, 1000);\n\n equal(Person.FIXTURES.length, 0, \"Fixtures empty\");\n\n var paul = env.store.push('person', { id: 'paul', firstName: 'Paul', lastName: 'Chavard', height: 70 });\n\n paul.deleteRecord();\n\n paul.on('didDelete', function() {\n clearTimeout(timer);\n start();\n\n equal(get(paul, 'isDeleted'), true, \"data deleted asynchronously\");\n equal(get(paul, 'isDirty'), false, \"data deleted asynchronously\");\n\n equal(Person.FIXTURES.length, 0, \"Record removed from FIXTURES\");\n });\n\n paul.save();\n});\n\ntest(\"should follow isUpdating semantics\", function() {\n var timer = setTimeout(function() {\n start();\n ok(false, \"timeout exceeded waiting for fixture data\");\n }, 1000);\n\n stop();\n\n Person.FIXTURES = [{\n id: \"twinturbo\",\n firstName: \"Adam\",\n lastName: \"Hawkins\",\n height: 65\n }];\n\n var result = env.store.findAll('person');\n\n result.then(function(all) {\n clearTimeout(timer);\n start();\n equal(get(all, 'isUpdating'), false, \"isUpdating is set when it shouldn't be\");\n });\n});\n\ntest(\"should coerce integer ids into string\", function() {\n Person.FIXTURES = [{\n id: 1,\n firstName: \"Adam\",\n lastName: \"Hawkins\",\n height: 65\n }];\n\n env.store.find('person', 1).then(async(function(result) {\n strictEqual(get(result, 'id'), \"1\", \"should load integer model id as string\");\n }));\n});\n\ntest(\"should coerce belongsTo ids into string\", function() {\n Person.FIXTURES = [{\n id: 1,\n firstName: \"Adam\",\n lastName: \"Hawkins\",\n\n phones: [1]\n }];\n\n Phone.FIXTURES = [{\n id: 1,\n person: 1\n }];\n\n env.store.find('phone', 1).then(async(function(result) {\n var person = get(result, 'person');\n person.one('didLoad', async(function() {\n strictEqual(get(result, 'person.id'), \"1\", \"should load integer belongsTo id as string\");\n strictEqual(get(result, 'person.firstName'), \"Adam\", \"resolved relationship with an integer belongsTo id\");\n }));\n }));\n});\n\ntest(\"only coerce belongsTo ids to string if id is defined and not null\", function() {\n Person.FIXTURES = [];\n\n Phone.FIXTURES = [{\n id: 1\n }];\n\n env.store.find('phone', 1).then(async(function(phone) {\n equal(phone.get('person'), null);\n }));\n});\n\ntest(\"should throw if ids are not defined in the FIXTURES\", function() {\n Person.FIXTURES = [{\n firstName: \"Adam\",\n lastName: \"Hawkins\",\n height: 65\n }];\n\n raises(function(){\n env.store.find('person', 1);\n }, /the id property must be defined as a number or string for fixture/);\n\n Person.FIXTURES = [{\n id: 0\n }];\n\n env.store.find('person', 0).then(async(function() {\n ok(true, \"0 is an acceptable ID, so no exception was thrown\");\n }), function() {\n ok(false, \"should not get here\");\n });\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/fixture_adapter_test");minispade.register('ember-data/~tests/integration/adapter/queries_test', "(function() {var get = Ember.get, set = Ember.set;\nvar Person, env, store, adapter;\n\nmodule(\"integration/adapter/queries - Queries\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: DS.attr('string'),\n name: DS.attr('string'),\n firstName: DS.attr('string'),\n lastName: DS.attr('string')\n });\n\n env = setupStore({ person: Person });\n store = env.store;\n adapter = env.adapter;\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"When a query is made, the adapter should receive a record array it can populate with the results of the query.\", function() {\n adapter.findQuery = function(store, type, query, recordArray) {\n equal(type, Person, \"the find method is called with the correct type\");\n\n return Ember.RSVP.resolve([{ id: 1, name: \"Peter Wagenet\" }, { id: 2, name: \"Brohuda Katz\" }]);\n };\n\n store.find('person', { page: 1 }).then(async(function(queryResults) {\n equal(get(queryResults, 'length'), 2, \"the record array has a length of 2 after the results are loaded\");\n equal(get(queryResults, 'isLoaded'), true, \"the record array's `isLoaded` property should be true\");\n\n equal(queryResults.objectAt(0).get('name'), \"Peter Wagenet\", \"the first record is 'Peter Wagenet'\");\n equal(queryResults.objectAt(1).get('name'), \"Brohuda Katz\", \"the second record is 'Brohuda Katz'\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/queries_test");minispade.register('ember-data/~tests/integration/adapter/record_persistence_test', "(function() {var get = Ember.get, set = Ember.set, attr = DS.attr;\nvar Person, env, store;\n\nvar all = Ember.RSVP.all, hash = Ember.RSVP.hash, resolve = Ember.RSVP.resolve;\n\nfunction assertClean(promise) {\n return promise.then(async(function(record) {\n equal(record.get('isDirty'), false, \"The record is now clean\");\n return record;\n }));\n}\n\n\nmodule(\"integration/adapter/record_persistence - Persisting Records\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: attr('string'),\n name: attr('string'),\n firstName: attr('string'),\n lastName: attr('string')\n });\n Person.toString = function() { return \"Person\"; };\n\n env = setupStore({ person: Person });\n store = env.store;\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"When a store is committed, the adapter's `commit` method should be called with records that have been changed.\", function() {\n expect(2);\n\n env.adapter.updateRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n equal(record, tom, \"the record is correct\");\n\n return Ember.RSVP.resolve();\n };\n\n env.store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n\n var tom;\n\n env.store.find('person', 1).then(async(function(person) {\n tom = person;\n set(tom, \"name\", \"Tom Dale\");\n tom.save();\n }));\n});\n\ntest(\"When a store is committed, the adapter's `commit` method should be called with records that have been created.\", function() {\n expect(2);\n\n env.adapter.createRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n equal(record, tom, \"the record is correct\");\n\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\" });\n };\n\n var tom = env.store.createRecord('person', { name: \"Tom Dale\" });\n tom.save();\n});\n\ntest(\"After a created record has been assigned an ID, finding a record by that ID returns the original record.\", function() {\n expect(1);\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\" });\n };\n\n var tom = env.store.createRecord('person', { name: \"Tom Dale\" });\n tom.save();\n\n asyncEqual(tom, env.store.find('person', 1), \"the retrieved record is the same as the created record\");\n});\n\ntest(\"when a store is committed, the adapter's `commit` method should be called with records that have been deleted.\", function() {\n env.adapter.deleteRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n equal(record, tom, \"the record is correct\");\n\n return Ember.RSVP.resolve();\n };\n\n var tom;\n\n env.store.push('person', { id: 1, name: \"Tom Dale\" });\n env.store.find('person', 1).then(async(function(person) {\n tom = person;\n tom.deleteRecord();\n return tom.save();\n })).then(async(function(tom) {\n equal(get(tom, 'isDeleted'), true, \"record is marked as deleted\");\n }));\n});\n\ntest(\"An adapter can notify the store that records were updated by calling `didSaveRecords`.\", function() {\n expect(6);\n\n var tom, yehuda;\n\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n env.store.push('person', { id: 1 });\n env.store.push('person', { id: 2 });\n\n all([ env.store.find('person', 1), env.store.find('person', 2) ])\n .then(async(function(array) {\n tom = array[0];\n yehuda = array[1];\n\n tom.set('name', \"Michael Phelps\");\n yehuda.set('name', \"Usain Bolt\");\n\n ok(tom.get('isDirty'), \"tom is dirty\");\n ok(yehuda.get('isDirty'), \"yehuda is dirty\");\n\n assertClean(tom.save()).then(async(function(record) {\n equal(record, tom, \"The record is correct\");\n }));\n\n assertClean(yehuda.save()).then(async(function(record) {\n equal(record, yehuda, \"The record is correct\");\n }));\n }));\n});\n\ntest(\"An adapter can notify the store that records were updated and provide new data by calling `didSaveRecords`.\", function() {\n var tom, yehuda;\n\n env.adapter.updateRecord = function(store, type, record) {\n if (record.get('id') === \"1\") {\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", updatedAt: \"now\" });\n } else if (record.get('id') === \"2\") {\n return Ember.RSVP.resolve({ id: 2, name: \"Yehuda Katz\", updatedAt: \"now!\" });\n }\n };\n\n env.store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n env.store.push('person', { id: 2, name: \"Gentile Katz\" });\n\n hash({ tom: env.store.find('person', 1), yehuda: env.store.find('person', 2) }).then(async(function(people) {\n people.tom.set('name', \"Draaaaaahm Dale\");\n people.yehuda.set('name', \"Goy Katz\");\n\n return hash({ tom: people.tom.save(), yehuda: people.yehuda.save() });\n })).then(async(function(people) {\n equal(people.tom.get('name'), \"Tom Dale\", \"name attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.tom.get('updatedAt'), \"now\", \"updatedAt attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.yehuda.get('name'), \"Yehuda Katz\", \"name attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.yehuda.get('updatedAt'), \"now!\", \"updatedAt attribute should reflect value of hash passed to didSaveRecords\");\n }));\n});\n\ntest(\"An adapter can notify the store that a record was updated by calling `didSaveRecord`.\", function() {\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n store.push('person', { id: 1 });\n store.push('person', { id: 2 });\n\n hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(people) {\n people.tom.set('name', \"Tom Dale\");\n people.yehuda.set('name', \"Yehuda Katz\");\n\n ok(people.tom.get('isDirty'), \"tom is dirty\");\n ok(people.yehuda.get('isDirty'), \"yehuda is dirty\");\n\n assertClean(people.tom.save());\n assertClean(people.yehuda.save());\n }));\n\n});\n\ntest(\"An adapter can notify the store that a record was updated and provide new data by calling `didSaveRecord`.\", function() {\n env.adapter.updateRecord = function(store, type, record) {\n switch (record.get('id')) {\n case \"1\":\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", updatedAt: \"now\" });\n case \"2\":\n return Ember.RSVP.resolve({ id: 2, name: \"Yehuda Katz\", updatedAt: \"now!\" });\n }\n };\n\n env.store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n env.store.push('person', { id: 2, name: \"Gentile Katz\" });\n\n\n hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(people) {\n people.tom.set('name', \"Draaaaaahm Dale\");\n people.yehuda.set('name', \"Goy Katz\");\n\n return hash({ tom: people.tom.save(), yehuda: people.yehuda.save() });\n })).then(async(function(people) {\n equal(people.tom.get('name'), \"Tom Dale\", \"name attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.tom.get('updatedAt'), \"now\", \"updatedAt attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.yehuda.get('name'), \"Yehuda Katz\", \"name attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.yehuda.get('updatedAt'), \"now!\", \"updatedAt attribute should reflect value of hash passed to didSaveRecords\");\n }));\n\n});\n\ntest(\"An adapter can notify the store that records were deleted by calling `didSaveRecords`.\", function() {\n env.adapter.deleteRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n env.store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n env.store.push('person', { id: 2, name: \"Gentile Katz\" });\n\n hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(people) {\n people.tom.deleteRecord();\n people.yehuda.deleteRecord();\n\n assertClean(people.tom.save());\n assertClean(people.yehuda.save());\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/record_persistence_test");minispade.register('ember-data/~tests/integration/adapter/rest_adapter_test', "(function() {var env, store, adapter, Post, Person, Comment, SuperUser;\nvar originalAjax, passedUrl, passedVerb, passedHash;\n\nmodule(\"integration/adapter/rest_adapter - REST Adapter\", {\n setup: function() {\n Post = DS.Model.extend({\n name: DS.attr(\"string\")\n });\n\n Post.toString = function() {\n return \"Post\";\n };\n\n Comment = DS.Model.extend({\n name: DS.attr(\"string\")\n });\n\n SuperUser = DS.Model.extend();\n\n env = setupStore({\n post: Post,\n comment: Comment,\n superUser: SuperUser,\n adapter: DS.RESTAdapter\n });\n\n store = env.store;\n adapter = env.adapter;\n\n passedUrl = passedVerb = passedHash = null;\n }\n});\n\nfunction ajaxResponse(value) {\n adapter.ajax = function(url, verb, hash) {\n passedUrl = url;\n passedVerb = verb;\n passedHash = hash;\n\n return Ember.RSVP.resolve(value);\n };\n}\n\ntest(\"find - basic payload\", function() {\n ajaxResponse({ posts: [{ id: 1, name: \"Rails is omakase\" }] });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n }));\n});\n\ntest(\"find - basic payload (with legacy singular name)\", function() {\n ajaxResponse({ post: { id: 1, name: \"Rails is omakase\" } });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n }));\n});\ntest(\"find - payload with sideloaded records of the same type\", function() {\n var count = 0;\n\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ]\n });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n\n var post2 = store.getById('post', 2);\n equal(post2.get('id'), \"2\");\n equal(post2.get('name'), \"The Parley Letter\");\n }));\n});\n\ntest(\"find - payload with sideloaded records of a different type\", function() {\n ajaxResponse({\n posts: [{ id: 1, name: \"Rails is omakase\" }],\n comments: [{ id: 1, name: \"FIRST\" }]\n });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n\n var comment = store.getById('comment', 1);\n equal(comment.get('id'), \"1\");\n equal(comment.get('name'), \"FIRST\");\n }));\n});\n\ntest(\"find - payload with an serializer-specified primary key\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_'\n }));\n\n ajaxResponse({ posts: [{ \"_ID_\": 1, name: \"Rails is omakase\" }] });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n }));\n});\n\ntest(\"find - payload with a serializer-specified attribute mapping\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n attrs: {\n 'name': '_NAME_',\n 'createdAt': { key: '_CREATED_AT_', someOtherOption: 'option' }\n }\n }));\n\n Post.reopen({\n createdAt: DS.attr(\"number\")\n });\n\n ajaxResponse({ posts: [{ id: 1, _NAME_: \"Rails is omakase\", _CREATED_AT_: 2013 }] });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n equal(post.get('createdAt'), 2013);\n }));\n});\n\ntest(\"create - an empty payload is a basic success if an id was specified\", function() {\n ajaxResponse();\n\n var post = store.createRecord('post', { id: \"some-uuid\", name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"POST\");\n deepEqual(passedHash.data, { post: { id: \"some-uuid\", name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"The Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"create - a payload with a new ID and data applies the updates\", function() {\n ajaxResponse({ posts: [{ id: \"1\", name: \"Dat Parley Letter\" }] });\n var post = store.createRecord('post', { name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"POST\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('id'), \"1\", \"the post has the updated ID\");\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"create - a payload with a new ID and data applies the updates (with legacy singular name)\", function() {\n ajaxResponse({ post: { id: \"1\", name: \"Dat Parley Letter\" } });\n var post = store.createRecord('post', { name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"POST\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('id'), \"1\", \"the post has the updated ID\");\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"create - findMany doesn't overwrite owner\", function() {\n ajaxResponse({ comment: { id: \"1\", name: \"Dat Parley Letter\", post: 1 } });\n\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [] });\n var post = store.getById('post', 1);\n\n var comment = store.createRecord('comment', { name: \"The Parley Letter\" });\n post.get('comments').pushObject(comment);\n\n equal(comment.get('post'), post, \"the post has been set correctly\");\n\n comment.save().then(async(function(comment) {\n equal(comment.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(comment.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n equal(comment.get('post'), post, \"the post is still set\");\n }));\n});\n\ntest(\"create - a serializer's primary key and attributes are consulted when building the payload\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_id_',\n\n attrs: {\n name: '_name_'\n }\n }));\n\n ajaxResponse();\n\n var post = store.createRecord('post', { id: \"some-uuid\", name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n deepEqual(passedHash.data, { post: { _id_: 'some-uuid', '_name_': \"The Parley Letter\" } });\n }));\n});\n\ntest(\"create - a serializer's attributes are consulted when building the payload if no id is pre-defined\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primarykey: '_id_',\n\n attrs: {\n name: '_name_'\n }\n }));\n\n ajaxResponse();\n\n var post = store.createRecord('post', { name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n deepEqual(passedHash.data, { post: { '_name_': \"The Parley Letter\" } });\n }));\n});\n\ntest(\"create - a record on the many side of a hasMany relationship should update relationships when data is sideloaded\", function() {\n expect(3);\n\n ajaxResponse({\n posts: [{\n id: \"1\",\n name: \"Rails is omakase\",\n comments: [1,2]\n }],\n comments: [{\n id: \"1\",\n name: \"Dat Parley Letter\",\n post: 1\n },{\n id: \"2\",\n name: \"Another Comment\",\n post: 1\n }]\n // My API is returning a comment:{} as well as a comments:[{...},...]\n //, comment: {\n // id: \"2\",\n // name: \"Another Comment\",\n // post: 1\n // }\n });\n\n Post.reopen({ comments: DS.hasMany('comment') });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [1] });\n store.push('comment', { id: 1, name: \"Dat Parlay Letter\", post: 1 });\n\n var post = store.getById('post', 1);\n var commentCount = post.get('comments.length');\n equal(commentCount, 1, \"the post starts life with a comment\");\n\n var comment = store.createRecord('comment', { name: \"Another Comment\", post: post });\n\n comment.save().then(async(function(comment) {\n equal(comment.get('post'), post, \"the comment is related to the post\");\n }));\n\n post.reload().then(async(function(post) {\n equal(post.get('comments.length'), 2, \"Post comment count has been updated\");\n }));\n});\n\ntest(\"update - an empty payload is a basic success\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse();\n\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"PUT\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"The Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"update - a payload with updates applies the updates\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ posts: [{ id: 1, name: \"Dat Parley Letter\" }] });\n\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"PUT\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"update - a payload with updates applies the updates (with legacy singular name)\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ post: { id: 1, name: \"Dat Parley Letter\" } });\n\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"PUT\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"update - a payload with sideloaded updates pushes the updates\", function() {\n ajaxResponse({\n posts: [{ id: 1, name: \"Dat Parley Letter\" }],\n comments: [{ id: 1, name: \"FIRST\" }]\n });\n var post = store.createRecord('post', { name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"POST\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('id'), \"1\", \"the post has the updated ID\");\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n\n var comment = store.getById('comment', 1);\n equal(comment.get('name'), \"FIRST\", \"The comment was sideloaded\");\n }));\n});\n\n\ntest(\"update - a payload with sideloaded updates pushes the updates\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n posts: [{ id: 1, name: \"Dat Parley Letter\" }],\n comments: [{ id: 1, name: \"FIRST\" }]\n });\n\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"PUT\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n\n var comment = store.getById('comment', 1);\n equal(comment.get('name'), \"FIRST\", \"The comment was sideloaded\");\n }));\n});\n\ntest(\"update - a serializer's primary key and attributes are consulted when building the payload\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_id_',\n\n attrs: {\n name: '_name_'\n }\n }));\n\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n ajaxResponse();\n\n store.find('post', 1).then(async(function(post) {\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n deepEqual(passedHash.data, { post: { '_name_': \"The Parley Letter\" } });\n }));\n});\n\ntest(\"delete - an empty payload is a basic success\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse();\n\n post.deleteRecord();\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"DELETE\");\n equal(passedHash, undefined);\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('isDeleted'), true, \"the post is now deleted\");\n }));\n});\n\ntest(\"delete - a payload with sideloaded updates pushes the updates\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ comments: [{ id: 1, name: \"FIRST\" }] });\n\n post.deleteRecord();\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"DELETE\");\n equal(passedHash, undefined);\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('isDeleted'), true, \"the post is now deleted\");\n\n var comment = store.getById('comment', 1);\n equal(comment.get('name'), \"FIRST\", \"The comment was sideloaded\");\n }));\n});\n\ntest(\"findAll - returning an array populates the array\", function() {\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ]\n });\n\n store.findAll('post').then(async(function(posts) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"GET\");\n equal(passedHash.data, undefined);\n\n var post1 = store.getById('post', 1),\n post2 = store.getById('post', 2);\n\n deepEqual(\n post1.getProperties('id', 'name'),\n { id: \"1\", name: \"Rails is omakase\" },\n \"Post 1 is loaded\"\n );\n\n deepEqual(\n post2.getProperties('id', 'name'),\n { id: \"2\", name: \"The Parley Letter\" },\n \"Post 2 is loaded\"\n );\n\n equal(posts.get('length'), 2, \"The posts are in the array\");\n equal(posts.get('isLoaded'), true, \"The RecordArray is loaded\");\n deepEqual(\n posts.toArray(),\n [ post1, post2 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findAll - returning sideloaded data loads the data\", function() {\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ],\n comments: [{ id: 1, name: \"FIRST\" }] });\n\n store.findAll('post').then(async(function(posts) {\n var comment = store.getById('comment', 1);\n\n deepEqual(comment.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n }));\n});\n\ntest(\"findAll - data is normalized through custom serializers\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n ajaxResponse({\n posts: [\n { _ID_: 1, _NAME_: \"Rails is omakase\" },\n { _ID_: 2, _NAME_: \"The Parley Letter\" }\n ]\n });\n\n store.findAll('post').then(async(function(posts) {\n var post1 = store.getById('post', 1),\n post2 = store.getById('post', 2);\n\n deepEqual(\n post1.getProperties('id', 'name'),\n { id: \"1\", name: \"Rails is omakase\" },\n \"Post 1 is loaded\"\n );\n deepEqual(\n post2.getProperties('id', 'name'),\n { id: \"2\", name: \"The Parley Letter\" },\n \"Post 2 is loaded\"\n );\n\n equal(posts.get('length'), 2, \"The posts are in the array\");\n equal(posts.get('isLoaded'), true, \"The RecordArray is loaded\");\n deepEqual(\n posts.toArray(),\n [ post1, post2 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findAll - since token is passed to the adapter\", function() {\n ajaxResponse({\n meta: { since: 'later'},\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ]\n });\n\n store.metaForType('post', { since: 'now' });\n\n store.findAll('post').then(async(function(posts) {\n equal(passedUrl, '/posts');\n equal(passedVerb, 'GET');\n equal(store.typeMapFor(Post).metadata.since, 'later');\n deepEqual(passedHash.data, { since: 'now' });\n }));\n});\n\ntest(\"metadata is accessible\", function() {\n ajaxResponse({\n meta: { offset: 5 },\n posts: [{id: 1, name: \"Rails is very expensive sushi\"}]\n });\n\n store.findAll('post').then(async(function(posts) {\n equal(\n store.metadataFor('post').offset,\n 5,\n \"Metadata can be accessed with metadataFor.\"\n );\n }));\n});\n\ntest(\"findQuery - payload 'meta' is accessible on the record array\", function() {\n ajaxResponse({\n meta: { offset: 5 },\n posts: [{id: 1, name: \"Rails is very expensive sushi\"}]\n });\n\n store.findQuery('post', { page: 2 }).then(async(function(posts) {\n equal(\n posts.get('meta.offset'),\n 5,\n \"Reponse metadata can be accessed with recordArray.meta\"\n );\n }));\n});\n\ntest(\"findQuery - returning an array populates the array\", function() {\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }]\n });\n\n store.findQuery('post', { page: 1 }).then(async(function(posts) {\n equal(passedUrl, '/posts');\n equal(passedVerb, 'GET');\n deepEqual(passedHash.data, { page: 1 });\n\n var post1 = store.getById('post', 1),\n post2 = store.getById('post', 2);\n\n deepEqual(\n post1.getProperties('id', 'name'),\n { id: \"1\", name: \"Rails is omakase\" },\n \"Post 1 is loaded\"\n );\n deepEqual(\n post2.getProperties('id', 'name'),\n { id: \"2\", name: \"The Parley Letter\" },\n \"Post 2 is loaded\"\n );\n\n equal(posts.get('length'), 2, \"The posts are in the array\");\n equal(posts.get('isLoaded'), true, \"The RecordArray is loaded\");\n deepEqual(\n posts.toArray(),\n [ post1, post2 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findQuery - returning sideloaded data loads the data\", function() {\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ],\n comments: [{ id: 1, name: \"FIRST\" }]\n });\n\n store.findQuery('post', { page: 1 }).then(async(function(posts) {\n var comment = store.getById('comment', 1);\n\n deepEqual(comment.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n }));\n});\n\ntest(\"findQuery - data is normalized through custom serializers\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n ajaxResponse({\n posts: [{ _ID_: 1, _NAME_: \"Rails is omakase\" },\n { _ID_: 2, _NAME_: \"The Parley Letter\" }]\n });\n\n store.findQuery('post', { page: 1 }).then(async(function(posts) {\n var post1 = store.getById('post', 1),\n post2 = store.getById('post', 2);\n\n deepEqual(\n post1.getProperties('id', 'name'),\n { id: \"1\", name: \"Rails is omakase\" },\n \"Post 1 is loaded\"\n );\n\n deepEqual(\n post2.getProperties('id', 'name'),\n { id: \"2\", name: \"The Parley Letter\" },\n \"Post 2 is loaded\"\n );\n\n equal(posts.get('length'), 2, \"The posts are in the array\");\n equal(posts.get('isLoaded'), true, \"The RecordArray is loaded\");\n deepEqual(\n posts.toArray(),\n [ post1, post2 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findMany - returning an array populates the array\", function() {\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [ 1, 2, 3 ] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { id: 1, name: \"FIRST\" },\n { id: 2, name: \"Rails is unagi\" },\n { id: 3, name: \"What is omakase?\" }\n ]\n });\n\nreturn post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3);\n\n deepEqual(comment1.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n deepEqual(comment2.getProperties('id', 'name'), { id: \"2\", name: \"Rails is unagi\" });\n deepEqual(comment3.getProperties('id', 'name'), { id: \"3\", name: \"What is omakase?\" });\n\n deepEqual(\n comments.toArray(),\n [ comment1, comment2, comment3 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findMany - returning sideloaded data loads the data\", function() {\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [ 1, 2, 3 ] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { id: 1, name: \"FIRST\" },\n { id: 2, name: \"Rails is unagi\" },\n { id: 3, name: \"What is omakase?\" },\n { id: 4, name: \"Unrelated comment\" }\n ],\n posts: [{ id: 2, name: \"The Parley Letter\" }]\n });\n\n return post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3),\n comment4 = store.getById('comment', 4),\n post2 = store.getById('post', 2);\n\n deepEqual(\n comments.toArray(),\n [ comment1, comment2, comment3 ],\n \"The correct records are in the array\"\n );\n\n deepEqual(comment4.getProperties('id', 'name'), { id: \"4\", name: \"Unrelated comment\" });\n deepEqual(post2.getProperties('id', 'name'), { id: \"2\", name: \"The Parley Letter\" });\n }));\n});\n\ntest(\"findMany - a custom serializer is used if present\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n env.container.register('serializer:comment', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [ 1, 2, 3 ] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { _ID_: 1, _NAME_: \"FIRST\" },\n { _ID_: 2, _NAME_: \"Rails is unagi\" },\n { _ID_: 3, _NAME_: \"What is omakase?\" }]\n });\n\n return post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3);\n\n deepEqual(comment1.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n deepEqual(comment2.getProperties('id', 'name'), { id: \"2\", name: \"Rails is unagi\" });\n deepEqual(comment3.getProperties('id', 'name'), { id: \"3\", name: \"What is omakase?\" });\n\n deepEqual(comments.toArray(), [ comment1, comment2, comment3 ], \"The correct records are in the array\");\n }));\n});\n\ntest(\"findHasMany - returning an array populates the array\", function() {\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push(\n 'post',\n {\n id: 1,\n name: \"Rails is omakase\",\n links: { comments: '/posts/1/comments' }\n }\n );\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { id: 1, name: \"FIRST\" },\n { id: 2, name: \"Rails is unagi\" },\n { id: 3, name: \"What is omakase?\" }\n ]\n });\n\n return post.get('comments');\n })).then(async(function(comments) {\n equal(passedUrl, '/posts/1/comments');\n equal(passedVerb, 'GET');\n equal(passedHash, undefined);\n\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3);\n\n deepEqual(comment1.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n deepEqual(comment2.getProperties('id', 'name'), { id: \"2\", name: \"Rails is unagi\" });\n deepEqual(comment3.getProperties('id', 'name'), { id: \"3\", name: \"What is omakase?\" });\n\n deepEqual(comments.toArray(), [ comment1, comment2, comment3 ], \"The correct records are in the array\");\n }));\n});\n\ntest(\"findMany - returning sideloaded data loads the data\", function() {\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push(\n 'post',\n {\n id: 1,\n name: \"Rails is omakase\",\n links: { comments: '/posts/1/comments' }\n }\n );\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { id: 1, name: \"FIRST\" },\n { id: 2, name: \"Rails is unagi\" },\n { id: 3, name: \"What is omakase?\" }\n ],\n posts: [{ id: 2, name: \"The Parley Letter\" }]\n });\n\n return post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3),\n post2 = store.getById('post', 2);\n\n deepEqual(comments.toArray(), [ comment1, comment2, comment3 ], \"The correct records are in the array\");\n\n deepEqual(post2.getProperties('id', 'name'), { id: \"2\", name: \"The Parley Letter\" });\n }));\n});\n\ntest(\"findMany - a custom serializer is used if present\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n env.container.register('serializer:comment', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push(\n 'post',\n {\n id: 1,\n name: \"Rails is omakase\",\n links: { comments: '/posts/1/comments' }\n }\n );\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { _ID_: 1, _NAME_: \"FIRST\" },\n { _ID_: 2, _NAME_: \"Rails is unagi\" },\n { _ID_: 3, _NAME_: \"What is omakase?\" }\n ]\n });\n return post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3);\n\n deepEqual(comment1.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n deepEqual(comment2.getProperties('id', 'name'), { id: \"2\", name: \"Rails is unagi\" });\n deepEqual(comment3.getProperties('id', 'name'), { id: \"3\", name: \"What is omakase?\" });\n\n deepEqual(comments.toArray(), [ comment1, comment2, comment3 ], \"The correct records are in the array\");\n }));\n});\n\ntest('buildURL - with host and namespace', function() {\n adapter.setProperties({\n host: 'http://example.com',\n namespace: 'api/v1'\n });\n\n ajaxResponse({ posts: [{ id: 1 }] });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"http://example.com/api/v1/posts/1\");\n }));\n});\n\ntest('buildURL - with relative paths in links', function() {\n adapter.setProperties({\n host: 'http://example.com',\n namespace: 'api/v1'\n });\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n ajaxResponse({ posts: [{ id: 1, links: { comments: 'comments' } }] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ comments: [{ id: 1 }] });\n return post.get('comments');\n })).then(async(function (comments) {\n equal(passedUrl, \"http://example.com/api/v1/posts/1/comments\");\n }));\n});\n\ntest('buildURL - with absolute paths in links', function() {\n adapter.setProperties({\n host: 'http://example.com',\n namespace: 'api/v1'\n });\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n ajaxResponse({ posts: [{ id: 1, links: { comments: '/api/v1/posts/1/comments' } }] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ comments: [{ id: 1 }] });\n return post.get('comments');\n })).then(async(function (comments) {\n equal(passedUrl, \"http://example.com/api/v1/posts/1/comments\");\n }));\n});\n\ntest('buildURL - with full URLs in links', function() {\n adapter.setProperties({\n host: 'http://example.com',\n namespace: 'api/v1'\n });\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n ajaxResponse({\n posts: [\n { id: 1,\n links: { comments: 'http://example.com/api/v1/posts/1/comments' }\n }\n ]\n });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ comments: [{ id: 1 }] });\n return post.get('comments');\n })).then(async(function (comments) {\n equal(passedUrl, \"http://example.com/api/v1/posts/1/comments\");\n }));\n});\n\ntest('buildURL - with camelized names', function() {\n adapter.setProperties({\n pathForType: function(type) {\n var decamelized = Ember.String.decamelize(type);\n return Ember.String.pluralize(decamelized);\n }\n });\n\n ajaxResponse({ superUsers: [{ id: 1 }] });\n\n store.find('superUser', 1).then(async(function(post) {\n equal(passedUrl, \"/super_users/1\");\n }));\n});\n\ntest('normalizeKey - to set up _ids and _id', function() {\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n keyForAttribute: function(attr) {\n //if (kind === 'hasMany') {\n //key = key.replace(/_ids$/, '');\n //key = Ember.String.pluralize(key);\n //} else if (kind === 'belongsTo') {\n //key = key.replace(/_id$/, '');\n //}\n\n return Ember.String.underscore(attr);\n },\n\n keyForBelongsTo: function(belongsTo) {\n },\n\n keyForRelationship: function(rel, kind) {\n if (kind === 'belongsTo') {\n var underscored = Ember.String.underscore(rel);\n return underscored + '_id';\n } else {\n var singular = Ember.String.singularize(rel);\n return Ember.String.underscore(singular) + '_ids';\n }\n }\n }));\n\n env.container.register('model:post', DS.Model.extend({\n name: DS.attr(),\n authorName: DS.attr(),\n author: DS.belongsTo('user'),\n comments: DS.hasMany('comment')\n }));\n\n env.container.register('model:user', DS.Model.extend({\n createdAt: DS.attr(),\n name: DS.attr()\n }));\n\n env.container.register('model:comment', DS.Model.extend({\n body: DS.attr()\n }));\n\n ajaxResponse({\n posts: [{\n id: \"1\",\n name: \"Rails is omakase\",\n author_name: \"@d2h\",\n author_id: \"1\",\n comment_ids: [ \"1\", \"2\" ]\n }],\n\n users: [{\n id: \"1\",\n name: \"D2H\"\n }],\n\n comments: [{\n id: \"1\",\n body: \"Rails is unagi\"\n }, {\n id: \"2\",\n body: \"What is omakase?\"\n }]\n });\n\n store.find('post', 1).then(async(function(post) {\n equal(post.get('authorName'), \"@d2h\");\n equal(post.get('author.name'), \"D2H\");\n deepEqual(post.get('comments').mapBy('body'), [\"Rails is unagi\", \"What is omakase?\"]);\n }));\n});\n\n//test(\"creating a record with a 422 error marks the records as invalid\", function(){\n //expect(1);\n\n //var mockXHR = {\n //status: 422,\n //responseText: JSON.stringify({ errors: { name: [\"can't be blank\"]} })\n //};\n\n //jQuery.ajax = function(hash) {\n //hash.error.call(hash.context, mockXHR, \"Unprocessable Entity\");\n //};\n\n //var post = store.createRecord(Post, { name: \"\" });\n\n //post.on(\"becameInvalid\", function() {\n //ok(true, \"becameInvalid is called\");\n //});\n\n //post.on(\"becameError\", function() {\n //ok(false, \"becameError is not called\");\n //});\n\n //post.save();\n//});\n\n//test(\"changing A=>null=>A should clean up the record\", function() {\n //var store = DS.Store.create({\n //adapter: DS.RESTAdapter\n //});\n //var Kidney = DS.Model.extend();\n //var Person = DS.Model.extend();\n\n //Kidney.reopen({\n //person: DS.belongsTo(Person)\n //});\n //Kidney.toString = function() { return \"Kidney\"; };\n\n //Person.reopen({\n //name: DS.attr('string'),\n //kidneys: DS.hasMany(Kidney)\n //});\n //Person.toString = function() { return \"Person\"; };\n\n //store.load(Person, { id: 1, kidneys: [1, 2] });\n //store.load(Kidney, { id: 1, person: 1 });\n //store.load(Kidney, { id: 2, person: 1 });\n\n //var person = store.find(Person, 1);\n //var kidney1 = store.find(Kidney, 1);\n //var kidney2 = store.find(Kidney, 2);\n\n //deepEqual(person.get('kidneys').toArray(), [kidney1, kidney2], \"precond - person should have both kidneys\");\n //equal(kidney1.get('person'), person, \"precond - first kidney should be in the person\");\n\n //person.get('kidneys').removeObject(kidney1);\n\n //ok(person.get('isDirty'), \"precond - person should be dirty after operation\");\n //ok(kidney1.get('isDirty'), \"precond - first kidney should be dirty after operation\");\n\n //deepEqual(person.get('kidneys').toArray(), [kidney2], \"precond - person should have only the second kidney\");\n //equal(kidney1.get('person'), null, \"precond - first kidney should be on the operating table\");\n\n //person.get('kidneys').addObject(kidney1);\n\n //ok(!person.get('isDirty'), \"person should be clean after restoration\");\n //ok(!kidney1.get('isDirty'), \"first kidney should be clean after restoration\");\n\n //deepEqual(person.get('kidneys').toArray(), [kidney2, kidney1], \"person should have both kidneys again\");\n //equal(kidney1.get('person'), person, \"first kidney should be in the person again\");\n//});\n\n//test(\"changing A=>B=>A should clean up the record\", function() {\n //var store = DS.Store.create({\n //adapter: DS.RESTAdapter\n //});\n //var Kidney = DS.Model.extend();\n //var Person = DS.Model.extend();\n\n //Kidney.reopen({\n //person: DS.belongsTo(Person)\n //});\n //Kidney.toString = function() { return \"Kidney\"; };\n\n //Person.reopen({\n //name: DS.attr('string'),\n //kidneys: DS.hasMany(Kidney)\n //});\n //Person.toString = function() { return \"Person\"; };\n\n //store.load(Person, { person: { id: 1, name: \"John Doe\", kidneys: [1, 2] }});\n //store.load(Person, { person: { id: 2, name: \"Jane Doe\", kidneys: [3]} });\n //store.load(Kidney, { kidney: { id: 1, person_id: 1 } });\n //store.load(Kidney, { kidney: { id: 2, person_id: 1 } });\n //store.load(Kidney, { kidney: { id: 3, person_id: 2 } });\n\n //var john = store.find(Person, 1);\n //var jane = store.find(Person, 2);\n //var kidney1 = store.find(Kidney, 1);\n //var kidney2 = store.find(Kidney, 2);\n //var kidney3 = store.find(Kidney, 3);\n\n //deepEqual(john.get('kidneys').toArray(), [kidney1, kidney2], \"precond - john should have the first two kidneys\");\n //deepEqual(jane.get('kidneys').toArray(), [kidney3], \"precond - jane should have the third kidney\");\n //equal(kidney2.get('person'), john, \"precond - second kidney should be in john\");\n\n //kidney2.set('person', jane);\n\n //ok(john.get('isDirty'), \"precond - john should be dirty after operation\");\n //ok(jane.get('isDirty'), \"precond - jane should be dirty after operation\");\n //ok(kidney2.get('isDirty'), \"precond - second kidney should be dirty after operation\");\n\n //deepEqual(john.get('kidneys').toArray(), [kidney1], \"precond - john should have only the first kidney\");\n //deepEqual(jane.get('kidneys').toArray(), [kidney3, kidney2], \"precond - jane should have the other two kidneys\");\n //equal(kidney2.get('person'), jane, \"precond - second kidney should be in jane\");\n\n //kidney2.set('person', john);\n\n //ok(!john.get('isDirty'), \"john should be clean after restoration\");\n //ok(!jane.get('isDirty'), \"jane should be clean after restoration\");\n //ok(!kidney2.get('isDirty'), \"second kidney should be clean after restoration\");\n\n //deepEqual(john.get('kidneys').toArray(), [kidney1, kidney2], \"john should have the first two kidneys again\");\n //deepEqual(jane.get('kidneys').toArray(), [kidney3], \"jane should have the third kidney again\");\n //equal(kidney2.get('person'), john, \"second kidney should be in john again\");\n//});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/rest_adapter_test");minispade.register('ember-data/~tests/integration/adapter/store_adapter_test', "(function() {/**\n This is an integration test that tests the communication between a store\n and its adapter.\n\n Typically, when a method is invoked on the store, it calls a related\n method on its adapter. The adapter notifies the store that it has\n completed the assigned task, either synchronously or asynchronously,\n by calling a method on the store.\n\n These tests ensure that the proper methods get called, and, if applicable,\n the given record orrecord arrayay changes state appropriately.\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar Person, Dog, env, store, adapter;\n\nmodule(\"integration/adapter/store_adapter - DS.Store and DS.Adapter integration test\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: DS.attr('string'),\n name: DS.attr('string'),\n firstName: DS.attr('string'),\n lastName: DS.attr('string')\n });\n\n Dog = DS.Model.extend({\n name: DS.attr('string')\n });\n\n env = setupStore({ person: Person, dog: Dog });\n store = env.store;\n adapter = env.adapter;\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"Records loaded multiple times and retrieved in recordArray are ready to send state events\", function() {\n adapter.findQuery = function(store, type, query, recordArray) {\n return Ember.RSVP.resolve([{\n id: 1,\n name: \"Mickael Ramírez\"\n }, {\n id: 2,\n name: \"Johny Fontana\"\n }]);\n };\n\n store.findQuery('person', {q: 'bla'}).then(async(function(people) {\n var people2 = store.findQuery('person', { q: 'bla2' });\n\n return Ember.RSVP.hash({ people: people, people2: people2 });\n })).then(async(function(results) {\n equal(results.people2.get('length'), 2, 'return the elements' );\n ok( results.people2.get('isLoaded'), 'array is loaded' );\n\n var person = results.people.objectAt(0);\n ok(person.get('isLoaded'), 'record is loaded');\n\n // delete record will not throw exception\n person.deleteRecord();\n }));\n\n});\n\ntest(\"by default, createRecords calls createRecord once per record\", function() {\n var count = 1;\n\n adapter.createRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (count === 1) {\n equal(get(record, 'name'), \"Tom Dale\");\n } else if (count === 2) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n } else {\n ok(false, \"should not have invoked more than 2 times\");\n }\n\n var hash = get(record, 'data');\n hash.id = count;\n hash.updatedAt = \"now\";\n\n count++;\n return Ember.RSVP.resolve(hash);\n };\n\n var tom = store.createRecord('person', { name: \"Tom Dale\" });\n var yehuda = store.createRecord('person', { name: \"Yehuda Katz\" });\n\n Ember.RSVP.hash({ tom: tom.save(), yehuda: yehuda.save() }).then(async(function(records) {\n tom = records.tom;\n yehuda = records.yehuda;\n\n asyncEqual(tom, store.find('person', 1), \"Once an ID is in, find returns the same object\");\n asyncEqual(yehuda, store.find('person', 2), \"Once an ID is in, find returns the same object\");\n equal(get(tom, 'updatedAt'), \"now\", \"The new information is received\");\n equal(get(yehuda, 'updatedAt'), \"now\", \"The new information is received\");\n }));\n});\n\ntest(\"by default, updateRecords calls updateRecord once per record\", function() {\n var count = 0;\n\n adapter.updateRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (count === 0) {\n equal(get(record, 'name'), \"Tom Dale\");\n } else if (count === 1) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n } else {\n ok(false, \"should not get here\");\n }\n\n count++;\n\n equal(record.get('isSaving'), true, \"record is saving\");\n\n return Ember.RSVP.resolve();\n };\n\n store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n store.push('person', { id: 2, name: \"Brohuda Katz\" });\n\n Ember.RSVP.hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n set(tom, \"name\", \"Tom Dale\");\n set(yehuda, \"name\", \"Yehuda Katz\");\n\n return Ember.RSVP.hash({ tom: tom.save(), yehuda: yehuda.save() });\n })).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n equal(tom.get('isSaving'), false, \"record is no longer saving\");\n equal(tom.get('isLoaded'), true, \"record is loaded\");\n\n equal(yehuda.get('isSaving'), false, \"record is no longer saving\");\n equal(yehuda.get('isLoaded'), true, \"record is loaded\");\n }));\n});\n\ntest(\"calling store.didSaveRecord can provide an optional hash\", function() {\n var count = 0;\n\n adapter.updateRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n count++;\n if (count === 1) {\n equal(get(record, 'name'), \"Tom Dale\");\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", updatedAt: \"now\" });\n } else if (count === 2) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n return Ember.RSVP.resolve({ id: 2, name: \"Yehuda Katz\", updatedAt: \"now!\" });\n } else {\n ok(false, \"should not get here\");\n }\n };\n\n store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n store.push('person', { id: 2, name: \"Brohuda Katz\" });\n\n Ember.RSVP.hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n set(tom, \"name\", \"Tom Dale\");\n set(yehuda, \"name\", \"Yehuda Katz\");\n\n return Ember.RSVP.hash({ tom: tom.save(), yehuda: yehuda.save() });\n })).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n equal(get(tom, 'isDirty'), false, \"the record should not be dirty\");\n equal(get(tom, 'updatedAt'), \"now\", \"the hash was updated\");\n\n equal(get(yehuda, 'isDirty'), false, \"the record should not be dirty\");\n equal(get(yehuda, 'updatedAt'), \"now!\", \"the hash was updated\");\n }));\n});\n\ntest(\"by default, deleteRecord calls deleteRecord once per record\", function() {\n expect(4);\n\n var count = 0;\n\n adapter.deleteRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (count === 0) {\n equal(get(record, 'name'), \"Tom Dale\");\n } else if (count === 1) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n } else {\n ok(false, \"should not get here\");\n }\n\n count++;\n\n return Ember.RSVP.resolve();\n };\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n store.push('person', { id: 2, name: \"Yehuda Katz\" });\n\n Ember.RSVP.hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n tom.deleteRecord();\n yehuda.deleteRecord();\n\n tom.save();\n yehuda.save();\n }));\n});\n\ntest(\"by default, destroyRecord calls deleteRecord once per record without requiring .save\", function() {\n expect(4);\n\n var count = 0;\n\n adapter.deleteRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (count === 0) {\n equal(get(record, 'name'), \"Tom Dale\");\n } else if (count === 1) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n } else {\n ok(false, \"should not get here\");\n }\n\n count++;\n\n return Ember.RSVP.resolve();\n };\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n store.push('person', { id: 2, name: \"Yehuda Katz\" });\n\n Ember.RSVP.hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n tom.destroyRecord();\n yehuda.destroyRecord();\n }));\n});\n\ntest(\"if an existing model is edited then deleted, deleteRecord is called on the adapter\", function() {\n expect(5);\n\n var count = 0;\n\n adapter.deleteRecord = function(store, type, record) {\n count++;\n equal(get(record, 'id'), 'deleted-record', \"should pass correct record to deleteRecord\");\n equal(count, 1, \"should only call deleteRecord method of adapter once\");\n\n return Ember.RSVP.resolve();\n };\n\n adapter.updateRecord = function() {\n ok(false, \"should not have called updateRecord method of adapter\");\n };\n\n // Load data for a record into the store.\n store.push('person', { id: 'deleted-record', name: \"Tom Dale\" });\n\n // Retrieve that loaded record and edit it so it becomes dirty\n store.find('person', 'deleted-record').then(async(function(tom) {\n tom.set('name', \"Tom Mothereffin' Dale\");\n\n equal(get(tom, 'isDirty'), true, \"precond - record should be dirty after editing\");\n\n tom.deleteRecord();\n return tom.save();\n })).then(async(function(tom) {\n equal(get(tom, 'isDirty'), false, \"record should not be dirty\");\n equal(get(tom, 'isDeleted'), true, \"record should be considered deleted\");\n }));\n});\n\ntest(\"if a deleted record errors, it enters the error state\", function() {\n var count = 0;\n\n adapter.deleteRecord = function(store, type, record) {\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve();\n }\n };\n\n store.push('person', { id: 'deleted-record', name: \"Tom Dale\" });\n\n var tom;\n\n store.find('person', 'deleted-record').then(async(function(person) {\n tom = person;\n person.deleteRecord();\n return person.save();\n })).then(null, async(function() {\n equal(tom.get('isError'), true, \"Tom is now errored\");\n\n // this time it succeeds\n return tom.save();\n })).then(async(function() {\n equal(tom.get('isError'), false, \"Tom is not errored anymore\");\n }));\n});\n\ntest(\"if a created record is marked as invalid by the server, it enters an error state\", function() {\n adapter.createRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (get(record, 'name').indexOf('Bro') === -1) {\n return Ember.RSVP.reject(new DS.InvalidError({ name: ['common... name requires a \"bro\"'] }));\n } else {\n return Ember.RSVP.resolve();\n }\n };\n\n var yehuda = store.createRecord('person', { id: 1, name: \"Yehuda Katz\" });\n\n // Wrap this in an Ember.run so that all chained async behavior is set up\n // before flushing any scheduled behavior.\n Ember.run(function() {\n yehuda.save().then(null, async(function(error) {\n equal(get(yehuda, 'isValid'), false, \"the record is invalid\");\n ok(get(yehuda, 'errors.name'), \"The errors.name property exists\");\n\n set(yehuda, 'updatedAt', true);\n equal(get(yehuda, 'isValid'), false, \"the record is still invalid\");\n\n // This tests that we handle undefined values without blowing up\n var errors = get(yehuda, 'errors');\n set(errors, 'other_bound_property', undefined);\n set(yehuda, 'errors', errors);\n set(yehuda, 'name', \"Brohuda Brokatz\");\n\n equal(get(yehuda, 'isValid'), true, \"the record is no longer invalid after changing\");\n equal(get(yehuda, 'isDirty'), true, \"the record has outstanding changes\");\n\n equal(get(yehuda, 'isNew'), true, \"precond - record is still new\");\n\n return yehuda.save();\n })).then(async(function(person) {\n strictEqual(person, yehuda, \"The promise resolves with the saved record\");\n\n equal(get(yehuda, 'isValid'), true, \"record remains valid after committing\");\n equal(get(yehuda, 'isNew'), false, \"record is no longer new\");\n }));\n });\n});\n\ntest(\"if a created record is marked as erred by the server, it enters an error state\", function() {\n adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n Ember.run(function() {\n var person = store.createRecord('person', { id: 1, name: \"John Doe\" });\n\n person.save().then(null, async(function() {\n ok(get(person, 'isError'), \"the record is in the error state\");\n }));\n });\n});\n\ntest(\"if an updated record is marked as invalid by the server, it enters an error state\", function() {\n adapter.updateRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (get(record, 'name').indexOf('Bro') === -1) {\n return Ember.RSVP.reject(new DS.InvalidError({ name: ['common... name requires a \"bro\"'] }));\n } else {\n return Ember.RSVP.resolve();\n }\n };\n\n var yehuda = store.push('person', { id: 1, name: \"Brohuda Brokatz\" });\n\n Ember.run(function() {\n store.find('person', 1).then(async(function(person) {\n equal(person, yehuda, \"The same object is passed through\");\n\n equal(get(yehuda, 'isValid'), true, \"precond - the record is valid\");\n set(yehuda, 'name', \"Yehuda Katz\");\n equal(get(yehuda, 'isValid'), true, \"precond - the record is still valid as far as we know\");\n\n equal(get(yehuda, 'isDirty'), true, \"the record is dirty\");\n\n return yehuda.save();\n })).then(null, async(function(reason) {\n equal(get(yehuda, 'isDirty'), true, \"the record is still dirty\");\n equal(get(yehuda, 'isValid'), false, \"the record is invalid\");\n\n set(yehuda, 'updatedAt', true);\n equal(get(yehuda, 'isValid'), false, \"the record is still invalid\");\n\n set(yehuda, 'name', \"Brohuda Brokatz\");\n equal(get(yehuda, 'isValid'), true, \"the record is no longer invalid after changing\");\n equal(get(yehuda, 'isDirty'), true, \"the record has outstanding changes\");\n\n return yehuda.save();\n })).then(async(function(yehuda) {\n equal(get(yehuda, 'isValid'), true, \"record remains valid after committing\");\n equal(get(yehuda, 'isDirty'), false, \"record is no longer new\");\n }));\n });\n});\n\ntest(\"if a updated record is marked as erred by the server, it enters an error state\", function() {\n adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n var person = store.push(Person, { id: 1, name: \"John Doe\" });\n\n store.find('person', 1).then(async(function(record) {\n equal(record, person, \"The person was resolved\");\n person.set('name', \"Jonathan Doe\");\n return person.save();\n })).then(null, async(function(reason) {\n ok(get(person, 'isError'), \"the record is in the error state\");\n }));\n});\n\ntest(\"can be created after the DS.Store\", function() {\n expect(1);\n\n adapter.find = function(store, type) {\n equal(type, Person, \"the type is correct\");\n return Ember.RSVP.resolve({ id: 1 });\n };\n\n store.find('person', 1);\n});\n\ntest(\"the filter method can optionally take a server query as well\", function() {\n adapter.findQuery = function(store, type, query, array) {\n return Ember.RSVP.resolve([\n { id: 1, name: \"Yehuda Katz\" },\n { id: 2, name: \"Tom Dale\" }\n ]);\n };\n\n var asyncFilter = store.filter('person', { page: 1 }, function(data) {\n return data.get('name') === \"Tom Dale\";\n });\n\n var loadedFilter;\n\n asyncFilter.then(async(function(filter) {\n loadedFilter = filter;\n return store.find('person', 2);\n })).then(async(function(tom) {\n equal(get(loadedFilter, 'length'), 1, \"The filter has an item in it\");\n deepEqual(loadedFilter.toArray(), [ tom ], \"The filter has a single entry in it\");\n }));\n});\n\ntest(\"relationships returned via `commit` do not trigger additional findManys\", function() {\n Person.reopen({\n dogs: DS.hasMany()\n });\n\n store.push('dog', { id: 1, name: \"Scruffy\" });\n\n adapter.find = function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", dogs: [1] });\n };\n\n adapter.updateRecord = function(store, type, record) {\n return new Ember.RSVP.Promise(function(resolve, reject) {\n store.push('person', { id: 1, name: \"Tom Dale\", dogs: [1, 2] });\n store.push('dog', { id: 2, name: \"Scruffles\" });\n resolve({ id: 1, name: \"Scruffy\" });\n });\n };\n\n adapter.findMany = function(store, type, ids) {\n ok(false, \"Should not get here\");\n };\n\n store.find('person', 1).then(async(function(person) {\n return Ember.RSVP.hash({ tom: person, dog: store.find('dog', 1) });\n })).then(async(function(records) {\n records.tom.get('dogs');\n return records.dog.save();\n })).then(async(function(tom) {\n ok(true, \"Tom was saved\");\n }));\n});\n\ntest(\"relationships don't get reset if the links is the same\", function() {\n Person.reopen({\n dogs: DS.hasMany({ async: true })\n });\n\n var count = 0;\n\n adapter.findHasMany = function() {\n ok(count++ === 0, \"findHasMany is only called once\");\n\n return Ember.RSVP.resolve([{ id: 1, name: \"Scruffy\" }]);\n };\n\n store.push('person', { id: 1, name: \"Tom Dale\", links: { dogs: \"/dogs\" } });\n\n var tom, dogs;\n\n store.find('person', 1).then(async(function(person) {\n tom = person;\n dogs = tom.get('dogs');\n return dogs;\n })).then(async(function(dogs) {\n equal(dogs.get('length'), 1, \"The dogs are loaded\");\n store.push('person', { id: 1, name: \"Tom Dale\", links: { dogs: \"/dogs\" } });\n ok(tom.get('dogs') instanceof DS.PromiseArray, 'dogs is a promise');\n return tom.get('dogs');\n })).then(async(function(dogs) {\n equal(dogs.get('length'), 1, \"The same dogs are loaded\");\n }));\n});\n\n\ntest(\"async hasMany always returns a promise\", function() {\n Person.reopen({\n dogs: DS.hasMany({ async: true })\n });\n\n adapter.createRecord = function(store, type, record) {\n var hash = { name: \"Tom Dale\" };\n hash.dogs = Ember.A();\n hash.id = 1;\n return Ember.RSVP.resolve(hash);\n };\n\n var tom = store.createRecord('person', { name: \"Tom Dale\" });\n ok(tom.get('dogs') instanceof DS.PromiseArray, \"dogs is a promise before save\");\n\n tom.save().then(async(function() {\n ok(tom.get('dogs') instanceof DS.PromiseArray, \"dogs is a promise after save\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/store_adapter_test");minispade.register('ember-data/~tests/integration/all_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar Person, store, array, moreArray;\n\nmodule(\"integration/all - DS.Store#all()\", {\n setup: function() {\n array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }];\n moreArray = [{ id: 3, name: \"Scumbag Bryn\" }];\n Person = DS.Model.extend({ name: DS.attr('string') });\n\n store = createStore({ person: Person });\n },\n teardown: function() {\n store.destroy();\n Person = null;\n array = null;\n }\n});\n\ntest(\"store.all('person') should return all records and should update with new ones\", function() {\n store.pushMany('person', array);\n\n var all = store.all('person');\n equal(get(all, 'length'), 2);\n\n store.pushMany('person', moreArray);\n\n equal(get(all, 'length'), 3);\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/all_test");minispade.register('ember-data/~tests/integration/application_test', "(function() {var app, container;\n\n/**\n These tests ensure that Ember Data works with Ember.js' application\n initialization and dependency injection APIs.\n*/\n\nmodule(\"integration/application - Injecting a Custom Store\", {\n setup: function() {\n Ember.run(function() {\n app = Ember.Application.create({\n Store: DS.Store.extend({ isCustom: true }),\n FooController: Ember.Controller.extend(),\n ApplicationView: Ember.View.extend(),\n BazController: {},\n ApplicationController: Ember.View.extend()\n });\n });\n\n container = app.__container__;\n },\n\n teardown: function() {\n app.destroy();\n Ember.BOOTED = false;\n }\n});\n\ntest(\"If a Store property exists on an Ember.Application, it should be instantiated.\", function() {\n ok(container.lookup('store:main').get('isCustom'), \"the custom store was instantiated\");\n});\n\ntest(\"If a store is instantiated, it should be made available to each controller.\", function() {\n var fooController = container.lookup('controller:foo');\n ok(fooController.get('store.isCustom'), \"the custom store was injected\");\n});\n\nmodule(\"integration/application - Injecting the Default Store\", {\n setup: function() {\n Ember.run(function() {\n app = Ember.Application.create({\n FooController: Ember.Controller.extend(),\n ApplicationView: Ember.View.extend(),\n BazController: {},\n ApplicationController: Ember.View.extend()\n });\n });\n\n container = app.__container__;\n },\n\n teardown: function() {\n app.destroy();\n Ember.BOOTED = false;\n }\n});\n\ntest(\"If a Store property exists on an Ember.Application, it should be instantiated.\", function() {\n ok(container.lookup('store:main') instanceof DS.Store, \"the store was instantiated\");\n});\n\ntest(\"If a store is instantiated, it should be made available to each controller.\", function() {\n var fooController = container.lookup('controller:foo');\n ok(fooController.get('store') instanceof DS.Store, \"the store was injected\");\n});\n\ntest(\"the DS namespace should be accessible\", function() {\n ok(Ember.Namespace.byName('DS') instanceof Ember.Namespace, \"the DS namespace is accessible\");\n});\n})();\n//@ sourceURL=ember-data/~tests/integration/application_test");minispade.register('ember-data/~tests/integration/client_id_generation_test', "(function() {var get = Ember.get, set = Ember.set;\nvar serializer, adapter, store;\nvar Post, Comment, env;\n\nmodule(\"integration/client_id_generation - Client-side ID Generation\", {\n setup: function() {\n Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n\n Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n env = setupStore({\n post: Post,\n comment: Comment\n });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"If an adapter implements the `generateIdForRecord` method, the store should be able to assign IDs without saving to the persistence layer.\", function() {\n expect(6);\n\n var idCount = 1;\n\n env.adapter.generateIdForRecord = function(passedStore, record) {\n equal(env.store, passedStore, \"store is the first parameter\");\n\n return \"id-\" + idCount++;\n };\n\n env.adapter.createRecord = function(store, type, record) {\n if (type === Comment) {\n equal(get(record, 'id'), 'id-1', \"Comment passed to `createRecord` has 'id-1' assigned\");\n return Ember.RSVP.resolve();\n } else {\n equal(get(record, 'id'), 'id-2', \"Post passed to `createRecord` has 'id-2' assigned\");\n return Ember.RSVP.resolve();\n }\n };\n\n var comment = env.store.createRecord('comment');\n var post = env.store.createRecord('post');\n\n equal(get(comment, 'id'), 'id-1', \"comment is assigned id 'id-1'\");\n equal(get(post, 'id'), 'id-2', \"post is assigned id 'id-2'\");\n\n // Despite client-generated IDs, calling commit() on the store should still\n // invoke the adapter's `createRecord` method.\n comment.save();\n post.save();\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/client_id_generation_test");minispade.register('ember-data/~tests/integration/debug_adapter_test', "(function() {var App, store, debugAdapter, get = Ember.get;\n\nmodule(\"DS.DebugAdapter\", {\n setup: function() {\n Ember.run(function() {\n App = Ember.Application.create({\n toString: function() { return 'App'; }\n });\n\n App.Store = DS.Store.extend({\n adapter: DS.Adapter.extend()\n });\n\n App.Post = DS.Model.extend({\n title: DS.attr('string')\n });\n\n App.advanceReadiness();\n });\n\n store = App.__container__.lookup('store:main');\n debugAdapter = App.__container__.lookup('dataAdapter:main');\n\n debugAdapter.reopen({\n getModelTypes: function() {\n return Ember.A([App.Post]);\n }\n });\n },\n teardown: function() {\n App.destroy();\n }\n});\n\ntest(\"Watching Model Types\", function() {\n expect(5);\n\n var added = function(types) {\n equal(types.length, 1);\n equal(types[0].name, 'App.Post');\n equal(types[0].count, 0);\n strictEqual(types[0].object, App.Post);\n };\n\n var updated = function(types) {\n equal(types[0].count, 1);\n };\n\n debugAdapter.watchModelTypes(added, updated);\n\n store.push('post', {id: 1, title: 'Post Title'});\n});\n\ntest(\"Watching Records\", function() {\n var post, args, record;\n\n Ember.run(function() {\n store.push('post', { id: '1', title: 'Clean Post'});\n });\n\n var callback = function() {\n args = arguments;\n };\n\n debugAdapter.watchRecords(App.Post, callback, callback, callback);\n\n equal(get(args[0], 'length'), 1);\n record = args[0][0];\n deepEqual(record.columnValues, { id: '1', title: 'Clean Post'} );\n deepEqual(record.filterValues, { isNew: false, isModified: false, isClean: true } );\n deepEqual(record.searchKeywords, ['1', 'Clean Post'] );\n deepEqual(record.color, 'black' );\n\n Ember.run(function() {\n post = store.find('post', 1);\n });\n\n Ember.run(function() {\n post.set('title', 'Modified Post');\n });\n\n record = args[0][0];\n deepEqual(record.columnValues, { id: '1', title: 'Modified Post'});\n deepEqual(record.filterValues, { isNew: false, isModified: true, isClean: false });\n deepEqual(record.searchKeywords, ['1', 'Modified Post'] );\n deepEqual(record.color, 'blue' );\n\n post = store.createRecord('post', { id: '2', title: 'New Post' });\n record = args[0][0];\n deepEqual(record.columnValues, { id: '2', title: 'New Post'});\n deepEqual(record.filterValues, { isNew: true, isModified: false, isClean: false });\n deepEqual(record.searchKeywords, ['2', 'New Post'] );\n deepEqual(record.color, 'green' );\n\n Ember.run(post, 'deleteRecord');\n\n var index = args[0];\n var count = args[1];\n equal(index, 1);\n equal(count, 1);\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/debug_adapter_test");minispade.register('ember-data/~tests/integration/filter_test', "(function() {var get = Ember.get, set = Ember.set;\nvar forEach = Ember.EnumerableUtils.forEach;\nvar indexOf = Ember.EnumerableUtils.indexOf;\n\nvar Person, store, env, array, recordArray;\n\nvar shouldContain = function(array, item) {\n ok(indexOf(array, item) !== -1, \"array should contain \"+item.get('name'));\n};\n\nvar shouldNotContain = function(array, item) {\n ok(indexOf(array, item) === -1, \"array should not contain \"+item.get('name'));\n};\n\nmodule(\"integration/filter - DS.Model updating\", {\n setup: function() {\n array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n Person = DS.Model.extend({ name: DS.attr('string') });\n\n env = setupStore({ person: Person });\n store = env.store;\n },\n teardown: function() {\n store.destroy();\n Person = null;\n array = null;\n }\n});\n\ntest(\"when a DS.Model updates its attributes, its changes affect its filtered Array membership\", function() {\n store.pushMany('person', array);\n\n var people = store.filter('person', function(hash) {\n if (hash.get('name').match(/Katz$/)) { return true; }\n });\n\n equal(get(people, 'length'), 1, \"precond - one item is in the RecordArray\");\n\n var person = people.objectAt(0);\n\n equal(get(person, 'name'), \"Scumbag Katz\", \"precond - the item is correct\");\n\n set(person, 'name', \"Yehuda Katz\");\n\n equal(get(people, 'length'), 1, \"there is still one item\");\n equal(get(person, 'name'), \"Yehuda Katz\", \"it has the updated item\");\n\n set(person, 'name', \"Yehuda Katz-Foo\");\n\n equal(get(people, 'length'), 0, \"there are now no items\");\n});\n\ntest(\"a record array can have a filter on it\", function() {\n store.pushMany('person', array);\n\n var recordArray = store.filter('person', function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n });\n\n equal(get(recordArray, 'length'), 2, \"The Record Array should have the filtered objects on it\");\n\n store.push('person', { id: 4, name: \"Scumbag Koz\" });\n\n equal(get(recordArray, 'length'), 3, \"The Record Array should be updated as new items are added to the store\");\n\n store.push('person', { id: 1, name: \"Scumbag Tom\" });\n\n equal(get(recordArray, 'length'), 2, \"The Record Array should be updated as existing members are updated\");\n});\n\ntest(\"a filtered record array includes created elements\", function() {\n store.pushMany('person', array);\n\n var recordArray = store.filter('person', function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n });\n\n equal(get(recordArray, 'length'), 2, \"precond - The Record Array should have the filtered objects on it\");\n\n store.createRecord('person', { name: \"Scumbag Koz\" });\n\n equal(get(recordArray, 'length'), 3, \"The record array has the new object on it\");\n});\n\ntest(\"a Record Array can update its filter\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n deleteRecord: function(store, type, record) {\n return Ember.RSVP.resolve();\n }\n }));\n\n store.pushMany('person', array);\n\n var dickens = store.createRecord('person', { id: 4, name: \"Scumbag Dickens\" });\n dickens.deleteRecord();\n\n var asyncDale = store.find('person', 1);\n var asyncKatz = store.find('person', 2);\n var asyncBryn = store.find('person', 3);\n\n store.filter(Person, function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n }).then(async(function(recordArray) {\n\n Ember.RSVP.hash({ dale: asyncDale, katz: asyncKatz, bryn: asyncBryn }).then(async(function(records) {\n shouldContain(recordArray, records.dale);\n shouldContain(recordArray, records.katz);\n shouldNotContain(recordArray, records.bryn);\n shouldNotContain(recordArray, dickens);\n\n recordArray.set('filterFunction', function(hash) {\n if (hash.get('name').match(/Katz/)) { return true; }\n });\n\n equal(get(recordArray, 'length'), 1, \"The Record Array should have one object on it\");\n\n Ember.run(function() {\n store.push('person', { id: 5, name: \"Other Katz\" });\n });\n\n equal(get(recordArray, 'length'), 2, \"The Record Array now has the new object matching the filter\");\n\n Ember.run(function() {\n store.push('person', { id: 6, name: \"Scumbag Demon\" });\n });\n\n equal(get(recordArray, 'length'), 2, \"The Record Array doesn't have objects matching the old filter\");\n }));\n }));\n});\n\ntest(\"a Record Array can update its filter and notify array observers\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n deleteRecord: function(store, type, record) {\n return Ember.RSVP.resolve();\n }\n }));\n\n store.pushMany('person', array);\n\n var dickens = store.createRecord('person', { id: 4, name: \"Scumbag Dickens\" });\n dickens.deleteRecord();\n\n var asyncDale = store.find('person', 1);\n var asyncKatz = store.find('person', 2);\n var asyncBryn = store.find('person', 3);\n\n store.filter(Person, function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n }).then(async(function(recordArray) {\n\n var didChangeIdx, didChangeRemoved = 0, didChangeAdded = 0;\n\n var arrayObserver = {\n arrayWillChange: Ember.K,\n\n arrayDidChange: function(array, idx, removed, added) {\n didChangeIdx = idx;\n didChangeRemoved += removed;\n didChangeAdded += added;\n }\n };\n\n recordArray.addArrayObserver(arrayObserver);\n\n recordArray.set('filterFunction', function(hash) {\n if (hash.get('name').match(/Katz/)) { return true; }\n });\n\n Ember.RSVP.all([ asyncDale, asyncKatz, asyncBryn ]).then(async(function() {\n equal(didChangeRemoved, 1, \"removed one item from array\");\n didChangeRemoved = 0;\n\n Ember.run(function() {\n store.push('person', { id: 5, name: \"Other Katz\" });\n });\n\n equal(didChangeAdded, 1, \"one item was added\");\n didChangeAdded = 0;\n\n equal(recordArray.objectAt(didChangeIdx).get('name'), \"Other Katz\");\n\n Ember.run(function() {\n store.push('person', { id: 6, name: \"Scumbag Demon\" });\n });\n\n equal(didChangeAdded, 0, \"did not get called when an object that doesn't match is added\");\n\n Ember.run(function() {\n recordArray.set('filterFunction', function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n });\n });\n\n equal(didChangeAdded, 2, \"one item is added when going back\");\n equal(recordArray.objectAt(didChangeIdx).get('name'), \"Scumbag Demon\");\n equal(recordArray.objectAt(didChangeIdx-1).get('name'), \"Scumbag Dale\");\n }));\n }));\n});\n\ntest(\"it is possible to filter by computed properties\", function() {\n Person.reopen({\n name: DS.attr('string'),\n upperName: Ember.computed(function() {\n return this.get('name').toUpperCase();\n }).property('name')\n });\n\n var filter = store.filter('person', function(person) {\n return person.get('upperName') === \"TOM DALE\";\n });\n\n equal(filter.get('length'), 0, \"precond - the filter starts empty\");\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n\n equal(filter.get('length'), 1, \"the filter now has a record in it\");\n\n store.find('person', 1).then(async(function(person) {\n Ember.run(function() {\n person.set('name', \"Yehuda Katz\");\n });\n\n equal(filter.get('length'), 0, \"the filter is empty again\");\n }));\n});\n\ntest(\"a filter created after a record is already loaded works\", function() {\n Person.reopen({\n name: DS.attr('string'),\n upperName: Ember.computed(function() {\n return this.get('name').toUpperCase();\n }).property('name')\n });\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n\n var filter = store.filter('person', function(person) {\n return person.get('upperName') === \"TOM DALE\";\n });\n\n equal(filter.get('length'), 1, \"the filter now has a record in it\");\n asyncEqual(filter.objectAt(0), store.find('person', 1));\n});\n\ntest(\"it is possible to filter by state flags\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: id, name: \"Tom Dale\" });\n }\n }));\n\n var filter = store.filter(Person, function(person) {\n return person.get('isLoaded');\n });\n\n equal(filter.get('length'), 0, \"precond - there are no records yet\");\n\n Ember.run(function() {\n var asyncPerson = store.find('person', 1);\n\n // Ember.run will block `find` from being synchronously\n // resolved in test mode\n\n equal(filter.get('length'), 0, \"the unloaded record isn't in the filter\");\n\n asyncPerson.then(async(function(person) {\n equal(filter.get('length'), 1, \"the now-loaded record is in the filter\");\n asyncEqual(filter.objectAt(0), store.find('person', 1));\n }));\n });\n});\n\ntest(\"it is possible to filter loaded records by dirtiness\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n updateRecord: function() {\n return Ember.RSVP.resolve();\n }\n }));\n\n var filter = store.filter('person', function(person) {\n return !person.get('isDirty');\n });\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n\n store.find('person', 1).then(async(function(person) {\n equal(filter.get('length'), 1, \"the clean record is in the filter\");\n\n // Force synchronous update of the filter, even though\n // we're already inside a run loop\n Ember.run(function() {\n person.set('name', \"Yehuda Katz\");\n });\n\n equal(filter.get('length'), 0, \"the now-dirty record is not in the filter\");\n\n return person.save();\n })).then(async(function(person) {\n equal(filter.get('length'), 1, \"the clean record is back in the filter\");\n }));\n});\n\ntest(\"it is possible to filter created records by dirtiness\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n createRecord: function() {\n return Ember.RSVP.resolve();\n }\n }));\n\n var filter = store.filter('person', function(person) {\n return !person.get('isDirty');\n });\n\n var person = store.createRecord('person', {\n id: 1,\n name: \"Tom Dale\"\n });\n\n equal(filter.get('length'), 0, \"the dirty record is not in the filter\");\n\n person.save().then(async(function(person) {\n equal(filter.get('length'), 1, \"the clean record is in the filter\");\n }));\n});\n\n\n// SERVER SIDE TESTS\nvar edited;\n\nvar clientEdits = function(ids) {\n edited = [];\n\n forEach(ids, function(id) {\n // wrap in an Ember.run to guarantee coalescence of the\n // iterated `set` calls and promise resolution.\n Ember.run(function() {\n store.find('person', id).then(function(person) {\n edited.push(person);\n person.set('name', 'Client-side ' + id );\n });\n });\n });\n};\n\nvar clientCreates = function(names) {\n edited = [];\n\n // wrap in an Ember.run to guarantee coalescence of the\n // iterated `set` calls.\n Ember.run( function() {\n forEach(names, function( name ) {\n edited.push(store.createRecord('person', { name: 'Client-side ' + name }));\n });\n });\n};\n\nvar serverResponds = function(){\n forEach(edited, function(person) { person.save(); });\n};\n\nvar setup = function(serverCallbacks) {\n set(store, 'adapter', DS.Adapter.extend(serverCallbacks));\n\n store.pushMany('person', array);\n\n recordArray = store.filter('person', function(hash) {\n if (hash.get('name').match(/Scumbag/)) { return true; }\n });\n\n equal(get(recordArray, 'length'), 3, \"The filter function should work\");\n};\n\ntest(\"a Record Array can update its filter after server-side updates one record\", function() {\n setup({\n updateRecord: function(store, type, record) {\n return Ember.RSVP.resolve({id: 1, name: \"Scumbag Server-side Dale\"});\n }\n });\n\n clientEdits([1]);\n equal(get(recordArray, 'length'), 2, \"The record array updates when the client changes records\");\n\n serverResponds();\n equal(get(recordArray, 'length'), 3, \"The record array updates when the server changes one record\");\n});\n\ntest(\"a Record Array can update its filter after server-side updates multiple records\", function() {\n setup({\n updateRecord: function(store, type, record) {\n switch (record.get('id')) {\n case \"1\":\n return Ember.RSVP.resolve({ id: 1, name: \"Scumbag Server-side Dale\" });\n case \"2\":\n return Ember.RSVP.resolve({ id: 2, name: \"Scumbag Server-side Katz\" });\n }\n }\n });\n\n clientEdits([1,2]);\n equal(get(recordArray, 'length'), 1, \"The record array updates when the client changes records\");\n\n serverResponds();\n equal(get(recordArray, 'length'), 3, \"The record array updates when the server changes multiple records\");\n});\n\ntest(\"a Record Array can update its filter after server-side creates one record\", function() {\n setup({\n createRecord: function(store, type, record) {\n return Ember.RSVP.resolve({id: 4, name: \"Scumbag Server-side Tim\"});\n }\n });\n\n clientCreates([\"Tim\"]);\n equal(get(recordArray, 'length'), 3, \"The record array does not include non-matching records\");\n\n serverResponds();\n equal(get(recordArray, 'length'), 4, \"The record array updates when the server creates a record\");\n});\n\ntest(\"a Record Array can update its filter after server-side creates multiple records\", function() {\n setup({\n createRecord: function(store, type, record) {\n switch (record.get('name')) {\n case \"Client-side Mike\":\n return Ember.RSVP.resolve({id: 4, name: \"Scumbag Server-side Mike\"});\n case \"Client-side David\":\n return Ember.RSVP.resolve({id: 5, name: \"Scumbag Server-side David\"});\n }\n }\n });\n\n clientCreates([\"Mike\", \"David\"]);\n equal(get(recordArray, 'length'), 3, \"The record array does not include non-matching records\");\n\n serverResponds();\n equal(get(recordArray, 'length'), 5, \"The record array updates when the server creates multiple records\");\n});\n\n\n})();\n//@ sourceURL=ember-data/~tests/integration/filter_test");minispade.register('ember-data/~tests/integration/lifecycle_hooks_test', "(function() {var Person, env;\nvar attr = DS.attr;\nvar resolve = Ember.RSVP.resolve;\n\nmodule(\"integration/lifecycle_hooks - Lifecycle Hooks\", {\n setup: function() {\n Person = DS.Model.extend({\n name: attr('string')\n });\n\n env = setupStore({\n person: Person\n });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\nasyncTest(\"When the adapter acknowledges that a record has been created, a `didCreate` event is triggered.\", function() {\n expect(3);\n\n env.adapter.createRecord = function(store, type, record) {\n return resolve({ id: 99, name: \"Yehuda Katz\" });\n };\n\n var person = env.store.createRecord(Person, { name: \"Yehuda Katz\" });\n\n person.on('didCreate', function() {\n equal(this, person, \"this is bound to the record\");\n equal(this.get('id'), \"99\", \"the ID has been assigned\");\n equal(this.get('name'), \"Yehuda Katz\", \"the attribute has been assigned\");\n start();\n });\n\n person.save();\n});\n\ntest(\"When the adapter acknowledges that a record has been created without a new data payload, a `didCreate` event is triggered.\", function() {\n expect(3);\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n var person = env.store.createRecord(Person, { id: 99, name: \"Yehuda Katz\" });\n\n person.on('didCreate', function() {\n equal(this, person, \"this is bound to the record\");\n equal(this.get('id'), \"99\", \"the ID has been assigned\");\n equal(this.get('name'), \"Yehuda Katz\", \"the attribute has been assigned\");\n });\n\n person.save();\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/lifecycle_hooks_test");minispade.register('ember-data/~tests/integration/records/collection_save_test', "(function() {var Comment, Post, env;\n\nmodule(\"integration/records/collection_save - Save Collection of Records\", {\n setup: function() {\n var Post = DS.Model.extend({\n title: DS.attr('string')\n });\n\n Post.toString = function() { return \"Post\"; };\n\n env = setupStore({ post: Post });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"Collection will resolve save on success\", function() {\n expect(1);\n env.store.createRecord('post', {title: 'Hello'});\n env.store.createRecord('post', {title: 'World'});\n\n var posts = env.store.all('post');\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.resolve({ id: 123 });\n };\n\n posts.save().then(async(function() {\n ok(true, 'save operation was resolved');\n }));\n});\n\ntest(\"Collection will reject save on error\", function() {\n env.store.createRecord('post', {title: 'Hello'});\n env.store.createRecord('post', {title: 'World'});\n\n var posts = env.store.all('post');\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n posts.save().then(function() {}, async(function() {\n ok(true, 'save operation was rejected');\n }));\n});\n\ntest(\"Retry is allowed in a failure handler\", function() {\n env.store.createRecord('post', {title: 'Hello'});\n env.store.createRecord('post', {title: 'World'});\n\n var posts = env.store.all('post');\n\n var count = 0;\n\n env.adapter.createRecord = function(store, type, record) {\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve({ id: 123 });\n }\n };\n\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.resolve({ id: 123 });\n };\n\n posts.save().then(function() {}, async(function() {\n return posts.save();\n })).then(async(function(post) {\n equal(posts.get('firstObject.id'), '123', \"The post ID made it through\");\n }));\n});\n\ntest(\"Collection will reject save on invalid\", function() {\n expect(1);\n env.store.createRecord('post', {title: 'Hello'});\n env.store.createRecord('post', {title: 'World'});\n\n var posts = env.store.all('post');\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject({ title: 'invalid' });\n };\n\n posts.save().then(function() {}, async(function() {\n ok(true, 'save operation was rejected');\n }));\n});\n})();\n//@ sourceURL=ember-data/~tests/integration/records/collection_save_test");minispade.register('ember-data/~tests/integration/records/delete_record_test', "(function() {var get = Ember.get, set = Ember.set;\nvar attr = DS.attr;\nvar Person, env;\n\nmodule(\"integration/deletedRecord - Deleting Records\", {\n setup: function() {\n Person = DS.Model.extend({\n name: attr('string')\n });\n\n Person.toString = function() { return \"Person\"; };\n\n env = setupStore({\n person: Person\n });\n },\n\n teardown: function() {\n Ember.run(function(){\n env.container.destroy();\n });\n }\n});\n\ntest(\"records can be deleted during record array enumeration\", function () {\n var adam = env.store.push('person', {id: 1, name: \"Adam Sunderland\"});\n var dave = env.store.push('person', {id: 2, name: \"Dave Sunderland\"});\n var all = env.store.all('person');\n\n // pre-condition\n equal(all.get('length'), 2, 'expected 2 records');\n\n Ember.run(function(){\n all.forEach(function(record) {\n record.deleteRecord();\n });\n });\n\n equal(all.get('length'), 0, 'expected 0 records');\n});\n\ntest(\"when deleted records are rolled back, they are still in their previous record arrays\", function () {\n var jaime = env.store.push('person', {id: 1, name: \"Jaime Lannister\"});\n var cersei = env.store.push('person', {id: 2, name: \"Cersei Lannister\"});\n var all = env.store.all('person');\n var filtered = env.store.filter('person', function () {\n return true;\n });\n\n equal(all.get('length'), 2, 'precond - we start with two people');\n equal(filtered.get('length'), 2, 'precond - we start with two people');\n\n Ember.run(function () {\n jaime.deleteRecord();\n jaime.rollback();\n });\n\n equal(all.get('length'), 2, 'record was not removed');\n equal(filtered.get('length'), 2, 'record was not removed');\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/records/delete_record_test");minispade.register('ember-data/~tests/integration/records/reload_test', "(function() {var get = Ember.get, set = Ember.set;\nvar attr = DS.attr;\nvar Person, env;\n\nmodule(\"integration/reload - Reloading Records\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: attr('string'),\n name: attr('string'),\n firstName: attr('string'),\n lastName: attr('string')\n });\n\n Person.toString = function() { return \"Person\"; };\n\n env = setupStore({ person: Person });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"When a single record is requested, the adapter's find method should be called unless it's loaded.\", function() {\n var count = 0;\n\n env.adapter.find = function(store, type, id) {\n if (count === 0) {\n count++;\n return Ember.RSVP.resolve({ id: id, name: \"Tom Dale\" });\n } else if (count === 1) {\n count++;\n return Ember.RSVP.resolve({ id: id, name: \"Braaaahm Dale\" });\n } else {\n ok(false, \"Should not get here\");\n }\n };\n\n env.store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is loaded with the right name\");\n equal(get(person, 'isLoaded'), true, \"The person is now loaded\");\n var promise = person.reload();\n equal(get(person, 'isReloading'), true, \"The person is now reloading\");\n return promise;\n })).then(async(function(person) {\n equal(get(person, 'isReloading'), false, \"The person is no longer reloading\");\n equal(get(person, 'name'), \"Braaaahm Dale\", \"The person is now updated with the right name\");\n }));\n});\n\ntest(\"When a record is reloaded and fails, it can try again\", function() {\n var tom = env.store.push('person', { id: 1, name: \"Tom Dale\" });\n\n var count = 0;\n env.adapter.find = function(store, type, id) {\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve({ id: 1, name: \"Thomas Dale\" });\n }\n };\n\n tom.reload().then(null, async(function() {\n equal(tom.get('isError'), true, \"Tom is now errored\");\n return tom.reload();\n })).then(async(function(person) {\n equal(person, tom, \"The resolved value is the record\");\n equal(tom.get('isError'), false, \"Tom is no longer errored\");\n equal(tom.get('name'), \"Thomas Dale\", \"the updates apply\");\n }));\n});\n\ntest(\"When a record is loaded a second time, isLoaded stays true\", function() {\n env.store.push('person', { id: 1, name: \"Tom Dale\" });\n\n env.store.find('person', 1).then(async(function(person) {\n equal(get(person, 'isLoaded'), true, \"The person is loaded\");\n person.addObserver('isLoaded', isLoadedDidChange);\n\n // Reload the record\n env.store.push('person', { id: 1, name: \"Tom Dale\" });\n equal(get(person, 'isLoaded'), true, \"The person is still loaded after load\");\n\n person.removeObserver('isLoaded', isLoadedDidChange);\n }));\n\n function isLoadedDidChange() {\n // This shouldn't be hit\n equal(get(this, 'isLoaded'), true, \"The person is still loaded after change\");\n }\n});\n\ntest(\"When a record is reloaded, its async hasMany relationships still work\", function() {\n env.container.register('model:person', DS.Model.extend({\n name: DS.attr(),\n tags: DS.hasMany('tag', { async: true })\n }));\n\n env.container.register('model:tag', DS.Model.extend({\n name: DS.attr()\n }));\n\n var tags = { 1: \"hipster\", 2: \"hair\" };\n\n env.adapter.find = function(store, type, id) {\n switch (type.typeKey) {\n case 'person':\n return Ember.RSVP.resolve({ id: 1, name: \"Tom\", tags: [1, 2] });\n case 'tag':\n return Ember.RSVP.resolve({ id: id, name: tags[id] });\n }\n };\n\n var tom;\n\n env.store.find('person', 1).then(async(function(person) {\n tom = person;\n equal(person.get('name'), \"Tom\", \"precond\");\n\n return person.get('tags');\n })).then(async(function(tags) {\n deepEqual(tags.mapBy('name'), [ 'hipster', 'hair' ]);\n\n return tom.reload();\n })).then(async(function(person) {\n equal(person.get('name'), \"Tom\", \"precond\");\n\n return person.get('tags');\n })).then(async(function(tags) {\n deepEqual(tags.mapBy('name'), [ 'hipster', 'hair' ], \"The tags are still there\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/records/reload_test");minispade.register('ember-data/~tests/integration/records/save_test', "(function() {var Comment, Post, env;\n\nmodule(\"integration/records/save - Save Record\", {\n setup: function() {\n var Post = DS.Model.extend({\n title: DS.attr('string')\n });\n\n Post.toString = function() { return \"Post\"; };\n\n env = setupStore({ post: Post });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"Will resolve save on success\", function() {\n expect(1);\n var post = env.store.createRecord('post', {title: 'toto'});\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.resolve({ id: 123 });\n };\n\n post.save().then(async(function() {\n ok(true, 'save operation was resolved');\n }));\n});\n\ntest(\"Will reject save on error\", function() {\n var post = env.store.createRecord('post', {title: 'toto'});\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n post.save().then(function() {}, async(function() {\n ok(true, 'save operation was rejected');\n }));\n});\n\ntest(\"Retry is allowed in a failure handler\", function() {\n var post = env.store.createRecord('post', {title: 'toto'});\n\n var count = 0;\n\n env.adapter.createRecord = function(store, type, record) {\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve({ id: 123 });\n }\n };\n\n post.save().then(function() {}, async(function() {\n return post.save();\n })).then(async(function(post) {\n equal(post.get('id'), '123', \"The post ID made it through\");\n }));\n});\n\ntest(\"Will reject save on invalid\", function() {\n expect(1);\n var post = env.store.createRecord('post', {title: 'toto'});\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject({ title: 'invalid' });\n };\n\n post.save().then(function() {}, async(function() {\n ok(true, 'save operation was rejected');\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/records/save_test");minispade.register('ember-data/~tests/integration/records/unload_test', "(function() {var get = Ember.get, set = Ember.set;\nvar attr = DS.attr;\nvar Person, env;\n\nmodule(\"integration/unload - Unloading Records\", {\n setup: function() {\n Person = DS.Model.extend({\n name: attr('string')\n });\n\n Person.toString = function() { return \"Person\"; };\n\n env = setupStore({ person: Person });\n },\n\n teardown: function() {\n Ember.run(function(){\n env.container.destroy();\n });\n }\n});\n\ntest(\"can unload a single record\", function () {\n var adam = env.store.push('person', {id: 1, name: \"Adam Sunderland\"});\n\n Ember.run(function(){\n adam.unloadRecord();\n });\n\n equal(env.store.all('person').get('length'), 0);\n});\n\ntest(\"can unload all records for a given type\", function () {\n var adam = env.store.push('person', {id: 1, name: \"Adam Sunderland\"});\n var bob = env.store.push('person', {id: 2, name: \"Bob Bobson\"});\n\n Ember.run(function(){\n env.store.unloadAll('person');\n });\n\n equal(env.store.all('person').get('length'), 0);\n});\n\ntest(\"removes findAllCache after unloading all records\", function () {\n var adam = env.store.push('person', {id: 1, name: \"Adam Sunderland\"});\n var bob = env.store.push('person', {id: 2, name: \"Bob Bobson\"});\n\n Ember.run(function(){\n env.store.all('person');\n env.store.unloadAll('person');\n });\n\n equal(env.store.all('person').get('length'), 0);\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/records/unload_test");minispade.register('ember-data/~tests/integration/relationships/belongs_to_test', "(function() {var env, store, User, Message, Post, Comment;\nvar get = Ember.get, set = Ember.set;\n\nvar attr = DS.attr, hasMany = DS.hasMany, belongsTo = DS.belongsTo;\nvar resolve = Ember.RSVP.resolve, hash = Ember.RSVP.hash;\n\nfunction stringify(string) {\n return function() { return string; };\n}\n\nmodule(\"integration/relationship/belongs_to Belongs-To Relationships\", {\n setup: function() {\n User = DS.Model.extend({\n name: attr('string'),\n messages: hasMany('message', {polymorphic: true}),\n favouriteMessage: belongsTo('message', {polymorphic: true})\n });\n User.toString = stringify('User');\n\n Message = DS.Model.extend({\n user: belongsTo('user'),\n created_at: attr('date')\n });\n Message.toString = stringify('Message');\n\n Post = Message.extend({\n title: attr('string'),\n comments: hasMany('comment')\n });\n Post.toString = stringify('Post');\n\n Comment = Message.extend({\n body: DS.attr('string'),\n message: DS.belongsTo('message', { polymorphic: true })\n });\n Comment.toString = stringify('Comment');\n\n env = setupStore({\n user: User,\n post: Post,\n comment: Comment,\n message: Message\n });\n\n env.container.register('serializer:user', DS.JSONSerializer.extend({\n attrs: {\n favouriteMessage: { embedded: 'always' }\n }\n }));\n\n store = env.store;\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"The store can materialize a non loaded monomorphic belongsTo association\", function() {\n expect(1);\n\n env.store.modelFor('post').reopen({\n user: DS.belongsTo('user', { async: true })\n });\n\n env.adapter.find = function(store, type, id) {\n ok(true, \"The adapter's find method should be called\");\n return Ember.RSVP.resolve({ id: 1 });\n };\n\n env.store.push('post', { id: 1, user: 2});\n\n env.store.find('post', 1).then(async(function(post) {\n post.get('user');\n }));\n});\n\ntest(\"Only a record of the same type can be used with a monomorphic belongsTo relationship\", function() {\n expect(1);\n\n store.push('post', { id: 1 });\n store.push('comment', { id: 2 });\n\n hash({ post: store.find('post', 1), comment: store.find('comment', 2) }).then(async(function(records) {\n expectAssertion(function() {\n records.post.set('user', records.comment);\n }, /You can only add a 'user' record to this relationship/);\n }));\n});\n\ntest(\"Only a record of the same base type can be used with a polymorphic belongsTo relationship\", function() {\n expect(1);\n store.push('comment', { id: 1 });\n store.push('comment', { id: 2 });\n store.push('post', { id: 1 });\n store.push('user', { id: 3 });\n\n var asyncRecords = hash({\n user: store.find('user', 3),\n post: store.find('post', 1),\n comment: store.find('comment', 1),\n anotherComment: store.find('comment', 2)\n });\n\n asyncRecords.then(async(function(records) {\n var comment = records.comment;\n\n comment.set('message', records.anotherComment);\n comment.set('message', records.post);\n comment.set('message', null);\n\n expectAssertion(function() {\n comment.set('message', records.user);\n }, /You can only add a 'message' record to this relationship/);\n }));\n});\n\ntest(\"The store can load a polymorphic belongsTo association\", function() {\n env.store.push('post', { id: 1 });\n env.store.push('comment', { id: 2, message: 1, messageType: 'post' });\n\n hash({ message: store.find('post', 1), comment: store.find('comment', 2) }).then(async(function(records) {\n equal(records.comment.get('message'), records.message);\n }));\n});\n\ntest(\"The store can serialize a polymorphic belongsTo association\", function() {\n env.serializer.serializePolymorphicType = function(record, json, relationship) {\n ok(true, \"The serializer's serializePolymorphicType method should be called\");\n json[\"message_type\"] = \"post\";\n };\n env.store.push('post', { id: 1 });\n env.store.push('comment', { id: 2, message: 1, messageType: 'post' });\n\n store.find('comment', 2).then(async(function(comment) {\n var serialized = store.serialize(comment, { includeId: true });\n equal(serialized['message'], 1);\n equal(serialized['message_type'], 'post');\n }));\n});\n\ntest(\"A serializer can materialize a belongsTo as a link that gets sent back to findBelongsTo\", function() {\n var Group = DS.Model.extend({\n people: DS.hasMany()\n });\n\n var Person = DS.Model.extend({\n group: DS.belongsTo({ async: true })\n });\n\n env.container.register('model:group', Group);\n env.container.register('model:person', Person);\n\n store.push('person', { id: 1, links: { group: '/people/1/group' } });\n\n env.adapter.find = function() {\n throw new Error(\"Adapter's find method should not be called\");\n };\n\n env.adapter.findBelongsTo = async(function(store, record, link, relationship) {\n equal(relationship.type, Group);\n equal(relationship.key, 'group');\n equal(link, \"/people/1/group\");\n\n return Ember.RSVP.resolve({ id: 1, people: [1] });\n });\n\n env.store.find('person', 1).then(async(function(person) {\n return person.get('group');\n })).then(async(function(group) {\n ok(group instanceof Group, \"A group object is loaded\");\n ok(group.get('id') === '1', 'It is the group we are expecting');\n }));\n});\n\ntest('A record with an async belongsTo relationship always returns a promise for that relationship', function () {\n var Seat = DS.Model.extend({\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n seat: DS.belongsTo('seat', { async: true })\n });\n\n env.container.register('model:seat', Seat);\n env.container.register('model:person', Person);\n\n store.push('person', { id: 1, links: { seat: '/people/1/seat' } });\n\n env.adapter.find = function() {\n throw new Error(\"Adapter's find method should not be called\");\n };\n\n env.adapter.findBelongsTo = async(function(store, record, link, relationship) {\n return Ember.RSVP.resolve({ id: 1});\n });\n\n env.store.find('person', 1).then(async(function(person) {\n person.get('seat').then(async(function(seat) {\n // this assertion fails too\n // ok(seat.get('person') === person, 'parent relationship should be populated');\n seat.set('person', person);\n ok(person.get('seat').then, 'seat should be a PromiseObject');\n }));\n }));\n});\n\ntest(\"TODO (embedded): The store can load an embedded polymorphic belongsTo association\", function() {\n expect(0);\n //serializer.keyForEmbeddedType = function() {\n //return 'embeddedType';\n //};\n\n //adapter.load(store, App.User, { id: 2, favourite_message: { id: 1, embeddedType: 'comment'}});\n\n //var user = store.find(App.User, 2),\n //message = store.find(App.Comment, 1);\n\n //equal(user.get('favouriteMessage'), message);\n});\n\ntest(\"TODO (embedded): The store can serialize an embedded polymorphic belongsTo association\", function() {\n expect(0);\n //serializer.keyForEmbeddedType = function() {\n //return 'embeddedType';\n //};\n //adapter.load(store, App.User, { id: 2, favourite_message: { id: 1, embeddedType: 'comment'}});\n\n //var user = store.find(App.User, 2),\n //serialized = store.serialize(user, {includeId: true});\n\n //ok(serialized.hasOwnProperty('favourite_message'));\n //equal(serialized.favourite_message.id, 1);\n //equal(serialized.favourite_message.embeddedType, 'comment');\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/relationships/belongs_to_test");minispade.register('ember-data/~tests/integration/relationships/has_many_test', "(function() {var env, User, Contact, Email, Phone, Message, Post, Comment;\nvar get = Ember.get, set = Ember.set;\n\nvar attr = DS.attr, hasMany = DS.hasMany, belongsTo = DS.belongsTo;\n\nfunction stringify(string) {\n return function() { return string; };\n}\n\nmodule(\"integration/relationships/has_many - Has-Many Relationships\", {\n setup: function() {\n User = DS.Model.extend({\n name: attr('string'),\n messages: hasMany('message', { polymorphic: true }),\n contacts: hasMany()\n });\n\n Contact = DS.Model.extend({\n user: belongsTo('user')\n });\n\n Email = Contact.extend({\n email: attr('string')\n });\n\n Phone = Contact.extend({\n number: attr('string')\n });\n\n Message = DS.Model.extend({\n user: belongsTo('user'),\n created_at: attr('date')\n });\n Message.toString = stringify('Message');\n\n Post = Message.extend({\n title: attr('string'),\n comments: hasMany('comment')\n });\n Post.toString = stringify('Post');\n\n Comment = Message.extend({\n body: DS.attr('string'),\n message: DS.belongsTo('post', { polymorphic: true })\n });\n Comment.toString = stringify('Comment');\n\n env = setupStore({\n user: User,\n contact: Contact,\n email: Email,\n phone: Phone,\n post: Post,\n comment: Comment,\n message: Message\n });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"When a hasMany relationship is accessed, the adapter's findMany method should not be called if all the records in the relationship are already loaded\", function() {\n expect(0);\n\n env.adapter.findMany = function() {\n ok(false, \"The adapter's find method should not be called\");\n };\n\n env.store.push('post', { id: 1, comments: [ 1 ] });\n env.store.push('comment', { id: 1 });\n\n env.store.find('post', 1).then(async(function(post) {\n post.get('comments');\n }));\n});\n\n// This tests the case where a serializer materializes a has-many\n// relationship as a reference that it can fetch lazily. The most\n// common use case of this is to provide a URL to a collection that\n// is loaded later.\ntest(\"A serializer can materialize a hasMany as an opaque token that can be lazily fetched via the adapter's findHasMany hook\", function() {\n Post.reopen({\n comments: DS.hasMany('comment', { async: true })\n });\n\n // When the store asks the adapter for the record with ID 1,\n // provide some fake data.\n env.adapter.find = function(store, type, id) {\n equal(type, Post, \"find type was Post\");\n equal(id, \"1\", \"find id was 1\");\n\n return Ember.RSVP.resolve({ id: 1, links: { comments: \"/posts/1/comments\" } });\n };\n\n env.adapter.findMany = function() {\n throw new Error(\"Adapter's findMany should not be called\");\n };\n\n env.adapter.findHasMany = function(store, record, link, relationship) {\n equal(relationship.type, Comment, \"findHasMany relationship type was Comment\");\n equal(relationship.key, 'comments', \"findHasMany relationship key was comments\");\n equal(link, \"/posts/1/comments\", \"findHasMany link was /posts/1/comments\");\n\n return Ember.RSVP.resolve([\n { id: 1, body: \"First\" },\n { id: 2, body: \"Second\" }\n ]);\n };\n\n env.store.find('post', 1).then(async(function(post) {\n return post.get('comments');\n })).then(async(function(comments) {\n equal(comments.get('isLoaded'), true, \"comments are loaded\");\n equal(comments.get('length'), 2, \"comments have 2 length\");\n }));\n});\n\ntest(\"An updated `links` value should invalidate a relationship cache\", function() {\n Post.reopen({\n comments: DS.hasMany('comment', { async: true })\n });\n\n env.adapter.createRecord = function(store, type, record) {\n var data = record.serialize();\n return Ember.RSVP.resolve({ id: 1, links: { comments: \"/posts/1/comments\" } });\n };\n\n env.adapter.findHasMany = function(store, record, link, relationship) {\n equal(relationship.type, Comment, \"findHasMany relationship type was Comment\");\n equal(relationship.key, 'comments', \"findHasMany relationship key was comments\");\n equal(link, \"/posts/1/comments\", \"findHasMany link was /posts/1/comments\");\n\n return Ember.RSVP.resolve([\n { id: 1, body: \"First\" },\n { id: 2, body: \"Second\" }\n ]);\n };\n\n env.store.createRecord('post', {}).save().then(async(function(post) {\n return post.get('comments');\n })).then(async(function(comments) {\n equal(comments.get('isLoaded'), true, \"comments are loaded\");\n equal(comments.get('length'), 2, \"comments have 2 length\");\n }));\n});\n\ntest(\"When a polymorphic hasMany relationship is accessed, the adapter's findMany method should not be called if all the records in the relationship are already loaded\", function() {\n expect(1);\n\n env.adapter.findMany = function() {\n ok(false, \"The adapter's find method should not be called\");\n };\n\n env.store.push('user', { id: 1, messages: [ {id: 1, type: 'post'}, {id: 3, type: 'comment'} ] });\n env.store.push('post', { id: 1 });\n env.store.push('comment', { id: 3 });\n\n env.store.find('user', 1).then(async(function(user) {\n var messages = user.get('messages');\n equal(messages.get('length'), 2, \"The messages are correctly loaded\");\n }));\n});\n\ntest(\"When a polymorphic hasMany relationship is accessed, the store can call multiple adapters' findMany method if the records are not loaded\", function() {\n User.reopen({\n messages: hasMany('message', { polymorphic: true, async: true })\n });\n\n env.adapter.findMany = function(store, type) {\n if (type === Post) {\n return Ember.RSVP.resolve([{ id: 1 }]);\n } else if (type === Comment) {\n return Ember.RSVP.resolve([{ id: 3 }]);\n }\n };\n\n env.store.push('user', { id: 1, messages: [ {id: 1, type: 'post'}, {id: 3, type: 'comment'} ] });\n\n env.store.find('user', 1).then(async(function(user) {\n return user.get('messages');\n })).then(async(function(messages) {\n equal(messages.get('length'), 2, \"The messages are correctly loaded\");\n }));\n});\n\ntest(\"Type can be inferred from the key of a hasMany relationship\", function() {\n expect(1);\n env.store.push('user', { id: 1, contacts: [ 1 ] });\n env.store.push('contact', { id: 1 });\n env.store.find('user', 1).then(async(function(user) {\n return user.get('contacts');\n })).then(async(function(contacts) {\n equal(contacts.get('length'), 1, \"The contacts relationship is correctly set up\");\n }));\n});\n\ntest(\"Type can be inferred from the key of an async hasMany relationship\", function() {\n User.reopen({\n contacts: DS.hasMany({ async: true })\n });\n\n expect(1);\n env.store.push('user', { id: 1, contacts: [ 1 ] });\n env.store.push('contact', { id: 1 });\n env.store.find('user', 1).then(async(function(user) {\n return user.get('contacts');\n })).then(async(function(contacts) {\n equal(contacts.get('length'), 1, \"The contacts relationship is correctly set up\");\n }));\n});\n\ntest(\"Polymorphic relationships work with a hasMany whose type is inferred\", function() {\n User.reopen({\n contacts: DS.hasMany({ polymorphic: true })\n });\n\n expect(1);\n env.store.push('user', { id: 1, contacts: [ { id: 1, type: 'email' }, { id: 2, type: 'phone' } ] });\n env.store.push('email', { id: 1 });\n env.store.push('phone', { id: 2 });\n env.store.find('user', 1).then(async(function(user) {\n return user.get('contacts');\n })).then(async(function(contacts) {\n equal(contacts.get('length'), 2, \"The contacts relationship is correctly set up\");\n }));\n});\n\ntest(\"A record can't be created from a polymorphic hasMany relationship\", function() {\n env.store.push('user', { id: 1, messages: [] });\n\n env.store.find('user', 1).then(async(function(user) {\n return user.get('messages');\n })).then(async(function(messages) {\n expectAssertion(function() {\n messages.createRecord();\n }, /You cannot add 'message' records to this polymorphic relationship/);\n }));\n});\n\ntest(\"Only records of the same type can be added to a monomorphic hasMany relationship\", function() {\n expect(1);\n env.store.push('post', { id: 1, comments: [] });\n env.store.push('post', { id: 2 });\n\n Ember.RSVP.all([ env.store.find('post', 1), env.store.find('post', 2) ]).then(async(function(records) {\n expectAssertion(function() {\n records[0].get('comments').pushObject(records[1]);\n }, /You cannot add 'post' records to this relationship/);\n }));\n\n});\n\ntest(\"Only records of the same base type can be added to a polymorphic hasMany relationship\", function() {\n expect(2);\n env.store.push('user', { id: 1, messages: [] });\n env.store.push('user', { id: 2, messages: [] });\n env.store.push('post', { id: 1, comments: [] });\n env.store.push('comment', { id: 3 });\n\n var asyncRecords = Ember.RSVP.hash({\n user: env.store.find('user', 1),\n anotherUser: env.store.find('user', 2),\n post: env.store.find('post', 1),\n comment: env.store.find('comment', 3)\n });\n\n asyncRecords.then(async(function(records) {\n records.messages = records.user.get('messages');\n return Ember.RSVP.hash(records);\n })).then(async(function(records) {\n records.messages.pushObject(records.post);\n records.messages.pushObject(records.comment);\n equal(records.messages.get('length'), 2, \"The messages are correctly added\");\n\n expectAssertion(function() {\n records.messages.pushObject(records.anotherUser);\n }, /You cannot add 'user' records to this relationship/);\n }));\n});\n\ntest(\"A record can be removed from a polymorphic association\", function() {\n expect(3);\n\n env.store.push('user', { id: 1 , messages: [{id: 3, type: 'comment'}]});\n env.store.push('comment', { id: 3 });\n\n var asyncRecords = Ember.RSVP.hash({\n user: env.store.find('user', 1),\n comment: env.store.find('comment', 3)\n });\n\n asyncRecords.then(async(function(records) {\n records.messages = records.user.get('messages');\n return Ember.RSVP.hash(records);\n })).then(async(function(records) {\n equal(records.messages.get('length'), 1, \"The user has 1 message\");\n\n var removedObject = records.messages.popObject();\n\n equal(removedObject, records.comment, \"The message is correctly removed\");\n equal(records.messages.get('length'), 0, \"The user does not have any messages\");\n }));\n});\n\ntest(\"When a record is created on the client, its hasMany arrays should be in a loaded state\", function() {\n expect(3);\n\n var post;\n\n Ember.run(function() {\n post = env.store.createRecord('post');\n });\n\n ok(get(post, 'isLoaded'), \"The post should have isLoaded flag\");\n\n var comments = get(post, 'comments');\n\n equal(get(comments, 'length'), 0, \"The comments should be an empty array\");\n\n ok(get(comments, 'isLoaded'), \"The comments should have isLoaded flag\");\n\n});\n\ntest(\"When a record is created on the client, its async hasMany arrays should be in a loaded state\", function() {\n expect(4);\n\n Post.reopen({\n comments: DS.hasMany('comment', { async: true })\n });\n\n var post;\n\n Ember.run(function() {\n post = env.store.createRecord('post');\n });\n\n ok(get(post, 'isLoaded'), \"The post should have isLoaded flag\");\n\n get(post, 'comments').then(function(comments) {\n ok(true, \"Comments array successfully resolves\");\n equal(get(comments, 'length'), 0, \"The comments should be an empty array\");\n ok(get(comments, 'isLoaded'), \"The comments should have isLoaded flag\");\n });\n\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/relationships/has_many_test");minispade.register('ember-data/~tests/integration/relationships/inverse_relationships_test', "(function() {var Post, Comment, Message, User, store, env;\n\nmodule('integration/relationships/inverse_relationships - Inverse Relationships');\n\ntest(\"When a record is added to a has-many relationship, the inverse belongsTo is determined automatically\", function() {\n Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n\n var env = setupStore({ post: Post, comment: Comment }),\n store = env.store;\n\n var comment = store.createRecord('comment');\n var post = store.createRecord('post');\n\n equal(comment.get('post'), null, \"no post has been set on the comment\");\n\n post.get('comments').pushObject(comment);\n equal(comment.get('post'), post, \"post was set on the comment\");\n});\n\ntest(\"Inverse relationships can be explicitly nullable\", function () {\n User = DS.Model.extend();\n\n Post = DS.Model.extend({\n lastParticipant: DS.belongsTo(User, { inverse: null }),\n participants: DS.hasMany(User, { inverse: 'posts' })\n });\n\n User.reopen({\n posts: DS.hasMany(Post, { inverse: 'participants' })\n });\n\n equal(User.inverseFor('posts').name, 'participants', 'User.posts inverse is Post.participants');\n equal(Post.inverseFor('lastParticipant'), null, 'Post.lastParticipant has no inverse');\n equal(Post.inverseFor('participants').name, 'posts', 'Post.participants inverse is User.posts');\n});\n\ntest(\"When a record is added to a has-many relationship, the inverse belongsTo can be set explicitly\", function() {\n Post = DS.Model.extend({\n comments: DS.hasMany('comment', { inverse: 'redPost' })\n });\n\n Comment = DS.Model.extend({\n onePost: DS.belongsTo('post'),\n twoPost: DS.belongsTo('post'),\n redPost: DS.belongsTo('post'),\n bluePost: DS.belongsTo('post')\n });\n\n var env = setupStore({ post: Post, comment: Comment }),\n store = env.store;\n\n var comment = store.createRecord('comment');\n var post = store.createRecord('post');\n\n equal(comment.get('onePost'), null, \"onePost has not been set on the comment\");\n equal(comment.get('twoPost'), null, \"twoPost has not been set on the comment\");\n equal(comment.get('redPost'), null, \"redPost has not been set on the comment\");\n equal(comment.get('bluePost'), null, \"bluePost has not been set on the comment\");\n\n post.get('comments').pushObject(comment);\n\n equal(comment.get('onePost'), null, \"onePost has not been set on the comment\");\n equal(comment.get('twoPost'), null, \"twoPost has not been set on the comment\");\n equal(comment.get('redPost'), post, \"redPost has been set on the comment\");\n equal(comment.get('bluePost'), null, \"bluePost has not been set on the comment\");\n});\n\ntest(\"When a record's belongsTo relationship is set, it can specify the inverse hasMany to which the new child should be added\", function() {\n Post = DS.Model.extend({\n meComments: DS.hasMany('comment'),\n youComments: DS.hasMany('comment'),\n everyoneWeKnowComments: DS.hasMany('comment')\n });\n\n Comment = DS.Model.extend({\n post: DS.belongsTo('post', { inverse: 'youComments' })\n });\n\n var env = setupStore({ post: Post, comment: Comment }),\n store = env.store;\n\n var comment = store.createRecord('comment');\n var post = store.createRecord('post');\n\n equal(post.get('meComments.length'), 0, \"meComments has no posts\");\n equal(post.get('youComments.length'), 0, \"youComments has no posts\");\n equal(post.get('everyoneWeKnowComments.length'), 0, \"everyoneWeKnowComments has no posts\");\n\n comment.set('post', post);\n\n equal(post.get('meComments.length'), 0, \"meComments has no posts\");\n equal(post.get('youComments.length'), 1, \"youComments had the post added\");\n equal(post.get('everyoneWeKnowComments.length'), 0, \"everyoneWeKnowComments has no posts\");\n});\n\ntest(\"When a record is added to or removed from a polymorphic has-many relationship, the inverse belongsTo can be set explicitly\", function() {\n User = DS.Model.extend({\n messages: DS.hasMany('message', {\n inverse: 'redUser',\n polymorphic: true\n })\n });\n\n Message = DS.Model.extend({\n oneUser: DS.belongsTo('user'),\n twoUser: DS.belongsTo('user'),\n redUser: DS.belongsTo('user'),\n blueUser: DS.belongsTo('user')\n });\n\n Post = Message.extend();\n\n var env = setupStore({ user: User, message: Message, post: Post }),\n store = env.store;\n\n var post = store.createRecord('post');\n var user = store.createRecord('user');\n\n equal(post.get('oneUser'), null, \"oneUser has not been set on the user\");\n equal(post.get('twoUser'), null, \"twoUser has not been set on the user\");\n equal(post.get('redUser'), null, \"redUser has not been set on the user\");\n equal(post.get('blueUser'), null, \"blueUser has not been set on the user\");\n\n user.get('messages').pushObject(post);\n\n equal(post.get('oneUser'), null, \"oneUser has not been set on the user\");\n equal(post.get('twoUser'), null, \"twoUser has not been set on the user\");\n equal(post.get('redUser'), user, \"redUser has been set on the user\");\n equal(post.get('blueUser'), null, \"blueUser has not been set on the user\");\n\n user.get('messages').popObject();\n\n equal(post.get('oneUser'), null, \"oneUser has not been set on the user\");\n equal(post.get('twoUser'), null, \"twoUser has not been set on the user\");\n equal(post.get('redUser'), null, \"redUser has bot been set on the user\");\n equal(post.get('blueUser'), null, \"blueUser has not been set on the user\");\n});\n\ntest(\"When a record's belongsTo relationship is set, it can specify the inverse polymorphic hasMany to which the new child should be added or removed\", function() {\n User = DS.Model.extend({\n meMessages: DS.hasMany('message', { polymorphic: true }),\n youMessages: DS.hasMany('message', { polymorphic: true }),\n everyoneWeKnowMessages: DS.hasMany('message', { polymorphic: true })\n });\n\n Message = DS.Model.extend({\n user: DS.belongsTo('user', { inverse: 'youMessages' })\n });\n\n Post = Message.extend();\n\n var env = setupStore({ user: User, message: Message, post: Post }),\n store = env.store;\n\n var user = store.createRecord('user');\n var post = store.createRecord('post');\n\n equal(user.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(user.get('youMessages.length'), 0, \"youMessages has no posts\");\n equal(user.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n\n post.set('user', user);\n\n equal(user.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(user.get('youMessages.length'), 1, \"youMessages had the post added\");\n equal(user.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n\n post.set('user', null);\n\n equal(user.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(user.get('youMessages.length'), 0, \"youMessages has no posts\");\n equal(user.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n});\n\ntest(\"When a record's polymorphic belongsTo relationship is set, it can specify the inverse hasMany to which the new child should be added\", function() {\n Message = DS.Model.extend({\n meMessages: DS.hasMany('comment'),\n youMessages: DS.hasMany('comment'),\n everyoneWeKnowMessages: DS.hasMany('comment')\n });\n\n Post = Message.extend();\n\n Comment = Message.extend({\n message: DS.belongsTo('message', {\n polymorphic: true,\n inverse: 'youMessages'\n })\n });\n\n var env = setupStore({ comment: Comment, message: Message, post: Post }),\n store = env.store;\n\n var comment = store.createRecord('comment');\n var post = store.createRecord('post');\n\n equal(post.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(post.get('youMessages.length'), 0, \"youMessages has no posts\");\n equal(post.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n\n comment.set('message', post);\n\n equal(post.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(post.get('youMessages.length'), 1, \"youMessages had the post added\");\n equal(post.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n\n comment.set('message', null);\n\n equal(post.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(post.get('youMessages.length'), 0, \"youMessages has no posts\");\n equal(post.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/relationships/inverse_relationships_test");minispade.register('ember-data/~tests/integration/serializers/json_serializer_test', "(function() {var get = Ember.get, set = Ember.set;\nvar Post, post, Comment, comment, env;\n\nmodule(\"integration/serializer/json - JSONSerializer\", {\n setup: function() {\n Post = DS.Model.extend({\n title: DS.attr('string')\n });\n Comment = DS.Model.extend({\n body: DS.attr('string'),\n post: DS.belongsTo('post')\n });\n env = setupStore({\n post: Post,\n comment: Comment\n });\n env.store.modelFor('post');\n env.store.modelFor('comment');\n },\n\n teardown: function() {\n env.store.destroy();\n }\n});\n\ntest(\"serializeAttribute\", function() {\n post = env.store.createRecord(\"post\", { title: \"Rails is omakase\"});\n var json = {};\n\n env.serializer.serializeAttribute(post, json, \"title\", {type: \"string\"});\n\n deepEqual(json, {\n title: \"Rails is omakase\"\n });\n});\n\ntest(\"serializeAttribute respects keyForAttribute\", function() {\n env.container.register('serializer:post', DS.JSONSerializer.extend({\n keyForAttribute: function(key) {\n return key.toUpperCase();\n }\n }));\n\n post = env.store.createRecord(\"post\", { title: \"Rails is omakase\"});\n var json = {};\n\n env.container.lookup(\"serializer:post\").serializeAttribute(post, json, \"title\", {type: \"string\"});\n\n\n deepEqual(json, {\n TITLE: \"Rails is omakase\"\n });\n});\n\ntest(\"serializeBelongsTo\", function() {\n post = env.store.createRecord(Post, { title: \"Rails is omakase\", id: \"1\"});\n comment = env.store.createRecord(Comment, { body: \"Omakase is delicious\", post: post});\n var json = {};\n\n env.serializer.serializeBelongsTo(comment, json, {key: \"post\", options: {}});\n\n deepEqual(json, {\n post: \"1\"\n });\n\n json = {};\n\n set(comment, 'post', null);\n\n env.serializer.serializeBelongsTo(comment, json, {key: \"post\", options: {}});\n\n deepEqual(json, {\n post: null\n }, \"Can set a belongsTo to a null value\");\n\n});\n\ntest(\"serializeBelongsTo respects keyForRelationship\", function() {\n env.container.register('serializer:post', DS.JSONSerializer.extend({\n keyForRelationship: function(key, type) {\n return key.toUpperCase();\n }\n }));\n post = env.store.createRecord(Post, { title: \"Rails is omakase\", id: \"1\"});\n comment = env.store.createRecord(Comment, { body: \"Omakase is delicious\", post: post});\n var json = {};\n\n env.container.lookup(\"serializer:post\").serializeBelongsTo(comment, json, {key: \"post\", options: {}});\n\n deepEqual(json, {\n POST: \"1\"\n });\n});\n\ntest(\"serializePolymorphicType\", function() {\n env.container.register('serializer:comment', DS.JSONSerializer.extend({\n serializePolymorphicType: function(record, json, relationship) {\n var key = relationship.key,\n belongsTo = get(record, key);\n json[relationship.key + \"TYPE\"] = belongsTo.constructor.typeKey;\n }\n }));\n\n post = env.store.createRecord(Post, { title: \"Rails is omakase\", id: \"1\"});\n comment = env.store.createRecord(Comment, { body: \"Omakase is delicious\", post: post});\n var json = {};\n\n env.container.lookup(\"serializer:comment\").serializeBelongsTo(comment, json, {key: \"post\", options: { polymorphic: true}});\n\n deepEqual(json, {\n post: \"1\",\n postTYPE: \"post\"\n });\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/serializers/json_serializer_test");minispade.register('ember-data/~tests/integration/serializers/rest_serializer_test', "(function() {var get = Ember.get, set = Ember.set;\nvar HomePlanet, league, SuperVillain, superVillain, EvilMinion, YellowMinion, DoomsdayDevice, Comment, env;\n\nmodule(\"integration/serializer/rest - RESTSerializer\", {\n setup: function() {\n HomePlanet = DS.Model.extend({\n name: DS.attr('string'),\n superVillains: DS.hasMany('superVillain')\n });\n SuperVillain = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n homePlanet: DS.belongsTo(\"homePlanet\"),\n evilMinions: DS.hasMany(\"evilMinion\")\n });\n EvilMinion = DS.Model.extend({\n superVillain: DS.belongsTo('superVillain'),\n name: DS.attr('string')\n });\n YellowMinion = EvilMinion.extend();\n DoomsdayDevice = DS.Model.extend({\n name: DS.attr('string'),\n evilMinion: DS.belongsTo('evilMinion', {polymorphic: true})\n });\n Comment = DS.Model.extend({\n body: DS.attr('string'),\n root: DS.attr('boolean'),\n children: DS.hasMany('comment')\n });\n env = setupStore({\n superVillain: SuperVillain,\n homePlanet: HomePlanet,\n evilMinion: EvilMinion,\n yellowMinion: YellowMinion,\n doomsdayDevice: DoomsdayDevice,\n comment: Comment\n });\n env.store.modelFor('superVillain');\n env.store.modelFor('homePlanet');\n env.store.modelFor('evilMinion');\n env.store.modelFor('yellowMinion');\n env.store.modelFor('doomsdayDevice');\n env.store.modelFor('comment');\n },\n\n teardown: function() {\n env.store.destroy();\n }\n});\n\ntest(\"extractArray with custom typeForRoot\", function() {\n env.restSerializer.typeForRoot = function(root) {\n var camelized = Ember.String.camelize(root);\n return Ember.String.singularize(camelized);\n };\n\n var json_hash = {\n home_planets: [{id: \"1\", name: \"Umber\", superVillains: [1]}],\n super_villains: [{id: \"1\", firstName: \"Tom\", lastName: \"Dale\", homePlanet: \"1\"}]\n };\n\n var array = env.restSerializer.extractArray(env.store, HomePlanet, json_hash);\n\n deepEqual(array, [{\n \"id\": \"1\",\n \"name\": \"Umber\",\n \"superVillains\": [1]\n }]);\n\n env.store.find(\"superVillain\", 1).then(async(function(minion){\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"extractArray failure with custom typeForRoot\", function() {\n env.restSerializer.typeForRoot = function(root) {\n //should be camelized too, but, whoops, the developer forgot!\n return Ember.String.singularize(root);\n };\n\n var json_hash = {\n home_planets: [{id: \"1\", name: \"Umber\", superVillains: [1]}],\n super_villains: [{id: \"1\", firstName: \"Tom\", lastName: \"Dale\", homePlanet: \"1\"}]\n };\n\n raises(function(){\n env.restSerializer.extractArray(env.store, HomePlanet, json_hash);\n }, \"No model was found for 'home_planets'\",\n \"raised error message expected to contain \\\"No model was found for 'home_planets'\\\"\");\n});\n\ntest(\"serialize polymorphicType\", function() {\n var tom = env.store.createRecord(YellowMinion, {name: \"Alex\", id: \"124\"});\n var ray = env.store.createRecord(DoomsdayDevice, {evilMinion: tom, name: \"DeathRay\"});\n\n var json = env.restSerializer.serialize(ray);\n\n deepEqual(json, {\n name: \"DeathRay\",\n evilMinionType: \"yellowMinion\",\n evilMinion: \"124\"\n });\n});\n\ntest(\"extractArray can load secondary records of the same type without affecting the query count\", function() {\n var json_hash = {\n comments: [{id: \"1\", body: \"Parent Comment\", root: true, children: [2, 3]}],\n _comments: [\n { id: \"2\", body: \"Child Comment 1\", root: false },\n { id: \"3\", body: \"Child Comment 2\", root: false }\n ]\n };\n\n var array = env.restSerializer.extractArray(env.store, Comment, json_hash);\n\n deepEqual(array, [{\n \"id\": \"1\",\n \"body\": \"Parent Comment\",\n \"root\": true,\n \"children\": [2, 3]\n }]);\n\n equal(array.length, 1, \"The query count is unaffected\");\n\n equal(env.store.recordForId(\"comment\", \"2\").get(\"body\"), \"Child Comment 1\", \"Secondary records are in the store\");\n equal(env.store.recordForId(\"comment\", \"3\").get(\"body\"), \"Child Comment 2\", \"Secondary records are in the store\");\n});\n\ntest(\"extractSingle loads secondary records with correct serializer\", function() {\n var superVillainNormalizeCount = 0;\n\n env.container.register('serializer:superVillain', DS.RESTSerializer.extend({\n normalize: function() {\n superVillainNormalizeCount++;\n return this._super.apply(this, arguments);\n }\n }));\n\n var json_hash = {\n evilMinion: {id: \"1\", name: \"Tom Dale\", superVillain: 1},\n superVillains: [{id: \"1\", firstName: \"Yehuda\", lastName: \"Katz\", homePlanet: \"1\"}]\n };\n\n var array = env.restSerializer.extractSingle(env.store, EvilMinion, json_hash);\n\n equal(superVillainNormalizeCount, 1, \"superVillain is normalized once\");\n});\n\ntest(\"extractArray loads secondary records with correct serializer\", function() {\n var superVillainNormalizeCount = 0;\n\n env.container.register('serializer:superVillain', DS.RESTSerializer.extend({\n normalize: function() {\n superVillainNormalizeCount++;\n return this._super.apply(this, arguments);\n }\n }));\n\n var json_hash = {\n evilMinions: [{id: \"1\", name: \"Tom Dale\", superVillain: 1}],\n superVillains: [{id: \"1\", firstName: \"Yehuda\", lastName: \"Katz\", homePlanet: \"1\"}]\n };\n\n var array = env.restSerializer.extractArray(env.store, EvilMinion, json_hash);\n\n equal(superVillainNormalizeCount, 1, \"superVillain is normalized once\");\n});\n\ntest('normalizeHash normalizes specific parts of the payload', function(){\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n normalizeHash: {\n homePlanets: function(hash) {\n hash.id = hash._id;\n delete hash._id;\n return hash;\n }\n }\n }));\n\n var jsonHash = { homePlanets: [{_id: \"1\", name: \"Umber\", superVillains: [1]}] };\n\n var array = env.restSerializer.extractArray(env.store, HomePlanet, jsonHash);\n\n deepEqual(array, [{\n \"id\": \"1\",\n \"name\": \"Umber\",\n \"superVillains\": [1]\n }]);\n});\n\ntest('normalizeHash works with transforms', function(){\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n normalizeHash: {\n evilMinions: function(hash) {\n hash.condition = hash._condition;\n delete hash._condition;\n return hash;\n }\n }\n }));\n\n env.container.register('transform:condition', DS.Transform.extend({\n deserialize: function(serialized) {\n if (serialized === 1) {\n return \"healing\";\n } else {\n return \"unknown\";\n }\n },\n serialize: function(deserialized) {\n if (deserialized === \"healing\") {\n return 1;\n } else {\n return 2;\n }\n }\n }));\n\n EvilMinion.reopen({ condition: DS.attr('condition') });\n\n var jsonHash = {\n evilMinions: [{id: \"1\", name: \"Tom Dale\", superVillain: 1, _condition: 1}]\n };\n\n var array = env.restSerializer.extractArray(env.store, EvilMinion, jsonHash);\n\n equal(array[0].condition, \"healing\");\n});\n\ntest('normalize should allow for different levels of normalization', function(){\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n attrs: {\n superVillain: 'is_super_villain'\n },\n keyForAttribute: function(attr) {\n return Ember.String.decamelize(attr);\n }\n }));\n\n var jsonHash = {\n evilMinions: [{id: \"1\", name: \"Tom Dale\", is_super_villain: 1}]\n };\n\n var array = env.restSerializer.extractArray(env.store, EvilMinion, jsonHash);\n\n equal(array[0].superVillain, 1);\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/serializers/rest_serializer_test");minispade.register('ember-data/~tests/unit/debug_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar store;\n\nvar TestAdapter = DS.Adapter.extend();\n\nmodule(\"Debug\", {\n setup: function() {\n store = DS.Store.create({\n adapter: TestAdapter.extend()\n });\n },\n\n teardown: function() {\n store.destroy();\n store = null;\n }\n});\n\ntest(\"_debugInfo groups the attributes and relationships correctly\", function() {\n var MaritalStatus = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Post = DS.Model.extend({\n title: DS.attr('string')\n });\n\n var User = DS.Model.extend({\n name: DS.attr('string'),\n isDrugAddict: DS.attr('boolean'),\n maritalStatus: DS.belongsTo(MaritalStatus),\n posts: DS.hasMany(Post)\n });\n\n var record = store.createRecord(User);\n\n var propertyInfo = record._debugInfo().propertyInfo;\n\n equal(propertyInfo.groups.length, 4);\n deepEqual(propertyInfo.groups[0].properties, ['id', 'name', 'isDrugAddict']);\n deepEqual(propertyInfo.groups[1].properties, ['maritalStatus']);\n deepEqual(propertyInfo.groups[2].properties, ['posts']);\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/debug_test");minispade.register('ember-data/~tests/unit/model/errors_test', "(function() {var errors;\n\nmodule(\"unit/model/errors\", {\n setup: function() {\n errors = DS.Errors.create();\n },\n\n teardown: function() {\n }\n});\n\nfunction becameInvalid(eventName) {\n if (eventName === 'becameInvalid') {\n ok(true, 'becameInvalid send');\n } else {\n ok(false, eventName + ' is send instead of becameInvalid');\n }\n}\n\nfunction becameValid(eventName) {\n if (eventName === 'becameValid') {\n ok(true, 'becameValid send');\n } else {\n ok(false, eventName + ' is send instead of becameValid');\n }\n}\n\nfunction unexpectedSend(eventName) {\n ok(false, 'unexpected send : ' + eventName);\n}\n\ntest(\"add error\", function() {\n expect(6);\n errors.trigger = becameInvalid;\n errors.add('firstName', 'error');\n errors.trigger = unexpectedSend;\n ok(errors.has('firstName'), 'it has firstName errors');\n equal(errors.get('length'), 1, 'it has 1 error');\n errors.add('firstName', ['error1', 'error2']);\n equal(errors.get('length'), 3, 'it has 3 errors');\n ok(!errors.get('isEmpty'), 'it is not empty');\n errors.add('lastName', 'error');\n errors.add('lastName', 'error');\n equal(errors.get('length'), 4, 'it has 4 errors');\n});\n\ntest(\"get error\", function() {\n expect(8);\n ok(errors.get('firstObject') === undefined, 'returns undefined');\n errors.trigger = becameInvalid;\n errors.add('firstName', 'error');\n errors.trigger = unexpectedSend;\n ok(errors.get('firstName').length === 1, 'returns errors');\n deepEqual(errors.get('firstObject'), {attribute: 'firstName', message: 'error'});\n errors.add('firstName', 'error2');\n ok(errors.get('firstName').length === 2, 'returns errors');\n errors.add('lastName', 'error3');\n deepEqual(errors.toArray(), [\n { attribute: 'firstName', message: 'error' },\n { attribute: 'firstName', message: 'error2' },\n { attribute: 'lastName', message: 'error3' }\n ]);\n deepEqual(errors.get('firstName'), [\n { attribute: 'firstName', message: 'error' },\n { attribute: 'firstName', message: 'error2' }\n ]);\n deepEqual(errors.get('messages'), ['error', 'error2', 'error3']);\n});\n\ntest(\"remove error\", function() {\n expect(5);\n errors.trigger = becameInvalid;\n errors.add('firstName', 'error');\n errors.trigger = becameValid;\n errors.remove('firstName');\n errors.trigger = unexpectedSend;\n ok(!errors.has('firstName'), 'it has no firstName errors');\n equal(errors.get('length'), 0, 'it has 0 error');\n ok(errors.get('isEmpty'), 'it is empty');\n errors.remove('firstName');\n});\n\ntest(\"remove same errors from different attributes\", function() {\n expect(5);\n errors.trigger = becameInvalid;\n errors.add('firstName', 'error');\n errors.add('lastName', 'error');\n errors.trigger = unexpectedSend;\n equal(errors.get('length'), 2, 'it has 2 error');\n errors.remove('firstName');\n equal(errors.get('length'), 1, 'it has 1 error');\n errors.trigger = becameValid;\n errors.remove('lastName');\n ok(errors.get('isEmpty'), 'it is empty');\n});\n\ntest(\"clear errors\", function() {\n expect(5);\n errors.trigger = becameInvalid;\n errors.add('firstName', ['error', 'error1']);\n equal(errors.get('length'), 2, 'it has 2 errors');\n errors.trigger = becameValid;\n errors.clear();\n errors.trigger = unexpectedSend;\n ok(!errors.has('firstName'), 'it has no firstName errors');\n equal(errors.get('length'), 0, 'it has 0 error');\n errors.clear();\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/errors_test");minispade.register('ember-data/~tests/unit/model/lifecycle_callbacks_test', "(function() {var get = Ember.get, set = Ember.set;\n\nmodule(\"unit/model/lifecycle_callbacks - Lifecycle Callbacks\");\n\ntest(\"a record receives a didLoad callback when it has finished loading\", function() {\n var Person = DS.Model.extend({\n name: DS.attr(),\n didLoad: function() {\n ok(\"The didLoad callback was called\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Foo\" });\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n store.find(Person, 1).then(async(function(person) {\n equal(person.get('id'), \"1\", \"The person's ID is available\");\n equal(person.get('name'), \"Foo\", \"The person's properties are available\");\n }));\n});\n\ntest(\"a record receives a didUpdate callback when it has finished updating\", function() {\n var callCount = 0;\n\n var Person = DS.Model.extend({\n bar: DS.attr('string'),\n\n didUpdate: function() {\n callCount++;\n equal(get(this, 'isSaving'), false, \"record should be saving\");\n equal(get(this, 'isDirty'), false, \"record should not be dirty\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Foo\" });\n },\n\n updateRecord: function(store, type, record) {\n equal(callCount, 0, \"didUpdate callback was not called until didSaveRecord is called\");\n\n return Ember.RSVP.resolve();\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n var asyncPerson = store.find(Person, 1);\n equal(callCount, 0, \"precond - didUpdate callback was not called yet\");\n\n asyncPerson.then(async(function(person) {\n person.set('bar', \"Bar\");\n return person.save();\n })).then(async(function() {\n equal(callCount, 1, \"didUpdate called after update\");\n }));\n});\n\ntest(\"a record receives a didCreate callback when it has finished updating\", function() {\n var callCount = 0;\n\n var Person = DS.Model.extend({\n didCreate: function() {\n callCount++;\n equal(get(this, 'isSaving'), false, \"record should not be saving\");\n equal(get(this, 'isDirty'), false, \"record should not be dirty\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n createRecord: function(store, type, record) {\n equal(callCount, 0, \"didCreate callback was not called until didSaveRecord is called\");\n\n return Ember.RSVP.resolve();\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n equal(callCount, 0, \"precond - didCreate callback was not called yet\");\n\n var person = store.createRecord(Person, { id: 69, name: \"Newt Gingrich\" });\n\n person.save().then(async(function() {\n equal(callCount, 1, \"didCreate called after commit\");\n }));\n});\n\ntest(\"a record receives a didDelete callback when it has finished deleting\", function() {\n var callCount = 0;\n\n var Person = DS.Model.extend({\n bar: DS.attr('string'),\n\n didDelete: function() {\n callCount++;\n\n equal(get(this, 'isSaving'), false, \"record should not be saving\");\n equal(get(this, 'isDirty'), false, \"record should not be dirty\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Foo\" });\n },\n\n deleteRecord: function(store, type, record) {\n equal(callCount, 0, \"didDelete callback was not called until didSaveRecord is called\");\n\n return Ember.RSVP.resolve();\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n var asyncPerson = store.find(Person, 1);\n equal(callCount, 0, \"precond - didDelete callback was not called yet\");\n\n asyncPerson.then(async(function(person) {\n person.deleteRecord();\n return person.save();\n })).then(async(function() {\n equal(callCount, 1, \"didDelete called after delete\");\n }));\n});\n\ntest(\"a record receives a becameInvalid callback when it became invalid\", function() {\n var callCount = 0;\n\n var Person = DS.Model.extend({\n bar: DS.attr('string'),\n\n becameInvalid: function() {\n callCount++;\n\n equal(get(this, 'isSaving'), false, \"record should not be saving\");\n equal(get(this, 'isDirty'), true, \"record should be dirty\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Foo\" });\n },\n\n updateRecord: function(store, type, record) {\n equal(callCount, 0, \"becameInvalid callback was not called untill recordWasInvalid is called\");\n\n return Ember.RSVP.reject(new DS.InvalidError({ bar: 'error' }));\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n var asyncPerson = store.find(Person, 1);\n equal(callCount, 0, \"precond - becameInvalid callback was not called yet\");\n\n // Make sure that the error handler has a chance to attach before\n // save fails.\n Ember.run(function() {\n asyncPerson.then(async(function(person) {\n person.set('bar', \"Bar\");\n return person.save();\n })).then(null, async(function() {\n equal(callCount, 1, \"becameInvalid called after invalidating\");\n }));\n });\n});\n\ntest(\"an ID of 0 is allowed\", function() {\n var store = createStore();\n\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n store.push(Person, { id: 0, name: \"Tom Dale\" });\n equal(store.all(Person).objectAt(0).get('name'), \"Tom Dale\", \"found record with id 0\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/lifecycle_callbacks_test");minispade.register('ember-data/~tests/unit/model/merge_test', "(function() {var Person;\n\nmodule(\"unit/model/merge - Merging\", {\n setup: function() {\n Person = DS.Model.extend({\n name: DS.attr(),\n city: DS.attr()\n });\n },\n\n teardown: function() {\n\n }\n});\n\ntest(\"When a record is in flight, changes can be made\", function() {\n var adapter = DS.Adapter.extend({\n createRecord: function(store, type, record) {\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\" });\n }\n });\n\n var store = createStore({ adapter: adapter });\n\n var person = store.createRecord(Person, { name: \"Tom Dale\" });\n\n // Make sure saving isn't resolved synchronously\n Ember.run(function() {\n var promise = person.save();\n\n equal(person.get('name'), \"Tom Dale\");\n\n person.set('name', \"Thomas Dale\");\n\n promise.then(function(person) {\n equal(person.get('isDirty'), true, \"The person is still dirty\");\n equal(person.get('name'), \"Thomas Dale\", \"The changes made still apply\");\n });\n });\n});\n\ntest(\"When a record is in flight, pushes are applied underneath the in flight changes\", function() {\n var adapter = DS.Adapter.extend({\n updateRecord: function(store, type, record) {\n return Ember.RSVP.resolve({ id: 1, name: \"Senor Thomas Dale, Esq.\", city: \"Portland\" });\n }\n });\n\n var store = createStore({ adapter: adapter });\n\n var person = store.push(Person, { id: 1, name: \"Tom\" });\n person.set('name', \"Thomas Dale\");\n\n // Make sure saving isn't resolved synchronously\n Ember.run(function() {\n var promise = person.save();\n\n equal(person.get('name'), \"Thomas Dale\");\n\n person.set('name', \"Tomasz Dale\");\n\n store.push(Person, { id: 1, name: \"Tommy Dale\", city: \"PDX\" });\n\n equal(person.get('name'), \"Tomasz Dale\", \"the local changes applied on top\");\n equal(person.get('city'), \"PDX\", \"the pushed change is available\");\n\n promise.then(function(person) {\n equal(person.get('isDirty'), true, \"The person is still dirty\");\n equal(person.get('name'), \"Tomasz Dale\", \"The local changes apply\");\n equal(person.get('city'), \"Portland\", \"The updates from the server apply on top of the previous pushes\");\n });\n });\n});\n\ntest(\"When a record is dirty, pushes are overridden by local changes\", function() {\n var store = createStore({ adapter: DS.Adapter });\n\n var person = store.push(Person, { id: 1, name: \"Tom Dale\", city: \"San Francisco\" });\n\n person.set('name', \"Tomasz Dale\");\n\n equal(person.get('isDirty'), true, \"the person is currently dirty\");\n equal(person.get('name'), \"Tomasz Dale\", \"the update was effective\");\n equal(person.get('city'), \"San Francisco\", \"the original data applies\");\n\n store.push(Person, { id: 1, name: \"Thomas Dale\", city: \"Portland\" });\n\n equal(person.get('isDirty'), true, \"the local changes are reapplied\");\n equal(person.get('name'), \"Tomasz Dale\", \"the local changes are reapplied\");\n equal(person.get('city'), \"Portland\", \"if there are no local changes, the new data applied\");\n});\n\ntest(\"A record with no changes can still be saved\", function() {\n var adapter = DS.Adapter.extend({\n updateRecord: function(store, type, record) {\n return Ember.RSVP.resolve({ id: 1, name: \"Thomas Dale\" });\n }\n });\n\n var store = createStore({ adapter: adapter });\n\n var person = store.push(Person, { id: 1, name: \"Tom Dale\" });\n\n person.save().then(async(function() {\n equal(person.get('name'), \"Thomas Dale\", \"the updates occurred\");\n }));\n});\n\ntest(\"A dirty record can be reloaded\", function() {\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Thomas Dale\", city: \"Portland\" });\n }\n });\n\n var store = createStore({ adapter: adapter });\n\n var person = store.push(Person, { id: 1, name: \"Tom Dale\" });\n\n person.set('name', \"Tomasz Dale\");\n\n person.reload().then(async(function() {\n equal(person.get('isDirty'), true, \"the person is dirty\");\n equal(person.get('name'), \"Tomasz Dale\", \"the local changes remain\");\n equal(person.get('city'), \"Portland\", \"the new changes apply\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/merge_test");minispade.register('ember-data/~tests/unit/model/relationships_test', "(function() {/*global Tag App*/\n\nvar get = Ember.get, set = Ember.set;\n\nmodule(\"unit/model/relationships - DS.Model\");\n\ntest(\"exposes a hash of the relationships on a model\", function() {\n var Occupation = DS.Model.extend();\n\n var Person = DS.Model.extend({\n occupations: DS.hasMany(Occupation)\n });\n\n Person.reopen({\n people: DS.hasMany(Person),\n parent: DS.belongsTo(Person)\n });\n\n var relationships = get(Person, 'relationships');\n deepEqual(relationships.get(Person), [\n { name: \"people\", kind: \"hasMany\" },\n { name: \"parent\", kind: \"belongsTo\" }\n ]);\n\n deepEqual(relationships.get(Occupation), [\n { name: \"occupations\", kind: \"hasMany\" }\n ]);\n});\n\nvar env;\nmodule(\"unit/model/relationships - DS.hasMany\", {\n setup: function() {\n env = setupStore();\n }\n});\n\ntest(\"hasMany handles pre-loaded relationships\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Pet = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag'),\n pets: DS.hasMany('pet')\n });\n\n env.container.register('model:tag', Tag);\n env.container.register('model:pet', Pet);\n env.container.register('model:person', Person);\n\n env.adapter.find = function(store, type, id) {\n if (type === Tag && id === '12') {\n return Ember.RSVP.resolve({ id: 12, name: \"oohlala\" });\n } else {\n ok(false, \"find() should not be called with these values\");\n }\n };\n\n var store = env.store;\n\n store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }]);\n store.pushMany('pet', [{ id: 4, name: \"fluffy\" }, { id: 7, name: \"snowy\" }, { id: 12, name: \"cerberus\" }]);\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [5] });\n store.push('person', { id: 2, name: \"Yehuda Katz\", tags: [12] });\n\n var wycats;\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n\n var tags = get(person, 'tags');\n equal(get(tags, 'length'), 1, \"the list of tags should have the correct length\");\n equal(get(tags.objectAt(0), 'name'), \"friendly\", \"the first tag should be a Tag\");\n\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [5, 2] });\n equal(tags, get(person, 'tags'), \"a relationship returns the same object every time\");\n equal(get(get(person, 'tags'), 'length'), 2, \"the length is updated after new data is loaded\");\n\n strictEqual(get(person, 'tags').objectAt(0), get(person, 'tags').objectAt(0), \"the returned object is always the same\");\n asyncEqual(get(person, 'tags').objectAt(0), store.find(Tag, 5), \"relationship objects are the same as objects retrieved directly\");\n\n store.push('person', { id: 3, name: \"KSelden\" });\n\n return store.find('person', 3);\n })).then(async(function(kselden) {\n equal(get(get(kselden, 'tags'), 'length'), 0, \"a relationship that has not been supplied returns an empty array\");\n\n store.push('person', { id: 4, name: \"Cyvid Hamluck\", pets: [4] });\n return store.find('person', 4);\n })).then(async(function(cyvid) {\n equal(get(cyvid, 'name'), \"Cyvid Hamluck\", \"precond - retrieves person record from store\");\n\n var pets = get(cyvid, 'pets');\n equal(get(pets, 'length'), 1, \"the list of pets should have the correct length\");\n equal(get(pets.objectAt(0), 'name'), \"fluffy\", \"the first pet should be correct\");\n\n store.push(Person, { id: 4, name: \"Cyvid Hamluck\", pets: [4, 12] });\n equal(pets, get(cyvid, 'pets'), \"a relationship returns the same object every time\");\n equal(get(get(cyvid, 'pets'), 'length'), 2, \"the length is updated after new data is loaded\");\n }));\n});\n\ntest(\"hasMany lazily loads async relationships\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Pet = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag', { async: true }),\n pets: DS.hasMany('pet')\n });\n\n env.container.register('model:tag', Tag);\n env.container.register('model:pet', Pet);\n env.container.register('model:person', Person);\n\n env.adapter.find = function(store, type, id) {\n if (type === Tag && id === '12') {\n return Ember.RSVP.resolve({ id: 12, name: \"oohlala\" });\n } else {\n ok(false, \"find() should not be called with these values\");\n }\n };\n\n var store = env.store;\n\n store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }]);\n store.pushMany('pet', [{ id: 4, name: \"fluffy\" }, { id: 7, name: \"snowy\" }, { id: 12, name: \"cerberus\" }]);\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [5] });\n store.push('person', { id: 2, name: \"Yehuda Katz\", tags: [12] });\n\n var wycats;\n\n store.find('person', 2).then(async(function(person) {\n wycats = person;\n\n equal(get(wycats, 'name'), \"Yehuda Katz\", \"precond - retrieves person record from store\");\n\n return Ember.RSVP.hash({\n wycats: wycats,\n tags: wycats.get('tags')\n });\n })).then(async(function(records) {\n equal(get(records.tags, 'length'), 1, \"the list of tags should have the correct length\");\n equal(get(records.tags.objectAt(0), 'name'), \"oohlala\", \"the first tag should be a Tag\");\n\n strictEqual(records.tags.objectAt(0), records.tags.objectAt(0), \"the returned object is always the same\");\n asyncEqual(records.tags.objectAt(0), store.find(Tag, 12), \"relationship objects are the same as objects retrieved directly\");\n\n return get(wycats, 'tags');\n })).then(async(function(tags) {\n var newTag = store.createRecord(Tag);\n tags.pushObject(newTag);\n }));\n});\n\ntest(\"should be able to retrieve the type for a hasMany relationship from its metadata\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany(Tag)\n });\n\n equal(Person.typeForRelationship('tags'), Tag, \"returns the relationship type\");\n});\n\ntest(\"should be able to retrieve the type for a hasMany relationship specified using a string from its metadata\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var env = setupStore({\n tag: Tag,\n person: Person\n });\n\n equal(env.store.modelFor('person').typeForRelationship('tags'), Tag, \"returns the relationship type\");\n});\n\ntest(\"should be able to retrieve the type for a belongsTo relationship from its metadata\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.belongsTo('tag')\n });\n\n var env = setupStore({\n tag: Tag,\n person: Person\n });\n\n equal(env.store.modelFor('person').typeForRelationship('tags'), Tag, \"returns the relationship type\");\n});\n\ntest(\"should be able to retrieve the type for a belongsTo relationship specified using a string from its metadata\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.belongsTo('tag')\n });\n\n var env = setupStore({\n tag: Tag,\n person: Person\n });\n\n equal(env.store.modelFor('person').typeForRelationship('tags'), Tag, \"returns the relationship type\");\n});\n\ntest(\"relationships work when declared with a string path\", function() {\n window.App = {};\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var env = setupStore({\n person: Person,\n tag: Tag\n });\n\n env.store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }, { id: 12, name: \"oohlala\" }]);\n env.store.push('person', { id: 1, name: \"Tom Dale\", tags: [5, 2] });\n\n env.store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n equal(get(person, 'tags.length'), 2, \"the list of tags should have the correct length\");\n }));\n});\n\ntest(\"hasMany relationships work when the data hash has not been loaded\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n Tag.toString = function() { return \"Tag\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag', { async: true })\n });\n\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n env.adapter.findMany = function(store, type, ids) {\n equal(type, Tag, \"type should be Tag\");\n deepEqual(ids, ['5', '2'], \"ids should be 5 and 2\");\n\n return Ember.RSVP.resolve([{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }]);\n };\n\n env.adapter.find = function(store, type, id) {\n equal(type, Person, \"type should be Person\");\n equal(id, 1, \"id should be 1\");\n\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", tags: [5, 2] });\n };\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is now populated\");\n\n return person.get('tags');\n })).then(async(function(tags) {\n equal(get(tags, 'length'), 2, \"the tags object still exists\");\n equal(get(tags.objectAt(0), 'name'), \"friendly\", \"Tom Dale is now friendly\");\n equal(get(tags.objectAt(0), 'isLoaded'), true, \"Tom Dale is now loaded\");\n }));\n});\n\ntest(\"it is possible to add a new item to a relationship\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n people: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var env = setupStore({\n tag: Tag,\n person: Person\n });\n\n var store = env.store;\n\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [ 1 ] });\n store.push('tag', { id: 1, name: \"ember\" });\n\n store.find(Person, 1).then(async(function(person) {\n var tag = get(person, 'tags').objectAt(0);\n\n equal(get(tag, 'name'), \"ember\", \"precond - relationships work\");\n\n tag = store.createRecord(Tag, { name: \"js\" });\n get(person, 'tags').pushObject(tag);\n\n equal(get(person, 'tags').objectAt(1), tag, \"newly added relationship works\");\n }));\n});\n\ntest(\"it is possible to remove an item from a relationship\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [ 1 ] });\n store.push('tag', { id: 1, name: \"ember\" });\n\n store.find('person', 1).then(async(function(person) {\n var tag = get(person, 'tags').objectAt(0);\n\n equal(get(tag, 'name'), \"ember\", \"precond - relationships work\");\n\n get(person, 'tags').removeObject(tag);\n\n equal(get(person, 'tags.length'), 0, \"object is removed from the relationship\");\n }));\n});\n\ntest(\"it is possible to add an item to a relationship, remove it, then add it again\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n Tag.toString = function() { return \"Tag\"; };\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n var person = store.createRecord('person');\n var tag1 = store.createRecord('tag');\n var tag2 = store.createRecord('tag');\n var tag3 = store.createRecord('tag');\n\n var tags = get(person, 'tags');\n\n tags.pushObjects([tag1, tag2, tag3]);\n tags.removeObject(tag2);\n equal(tags.objectAt(0), tag1);\n equal(tags.objectAt(1), tag3);\n equal(get(person, 'tags.length'), 2, \"object is removed from the relationship\");\n\n tags.insertAt(0, tag2);\n equal(get(person, 'tags.length'), 3, \"object is added back to the relationship\");\n equal(tags.objectAt(0), tag2);\n equal(tags.objectAt(1), tag1);\n equal(tags.objectAt(2), tag3);\n});\n\nmodule(\"unit/model/relationships - RecordArray\");\n\ntest(\"updating the content of a RecordArray updates its content\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var env = setupStore({ tag: Tag }),\n store = env.store;\n\n var records = store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }, { id: 12, name: \"oohlala\" }]);\n\n var tags = DS.RecordArray.create({ content: Ember.A(records.slice(0, 2)), store: store, type: Tag });\n\n var tag = tags.objectAt(0);\n equal(get(tag, 'name'), \"friendly\", \"precond - we're working with the right tags\");\n\n set(tags, 'content', Ember.A(records.slice(1, 3)));\n tag = tags.objectAt(0);\n equal(get(tag, 'name'), \"smarmy\", \"the lookup was updated\");\n});\n\ntest(\"can create child record from a hasMany relationship\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.push('person', { id: 1, name: \"Tom Dale\"});\n\n store.find('person', 1).then(async(function(person) {\n person.get(\"tags\").createRecord({ name: \"cool\" });\n\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n equal(get(person, 'tags.length'), 1, \"tag is added to the parent record\");\n equal(get(person, 'tags').objectAt(0).get(\"name\"), \"cool\", \"tag values are passed along\");\n }));\n});\n\nmodule(\"unit/model/relationships - DS.belongsTo\");\n\ntest(\"belongsTo lazily loads relationships as needed\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n people: DS.hasMany('person')\n });\n Tag.toString = function() { return \"Tag\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag')\n });\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }, { id: 12, name: \"oohlala\" }]);\n store.push('person', { id: 1, name: \"Tom Dale\", tag: 5 });\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n\n equal(get(person, 'tag') instanceof Tag, true, \"the tag property should return a tag\");\n equal(get(person, 'tag.name'), \"friendly\", \"the tag shuld have name\");\n\n strictEqual(get(person, 'tag'), get(person, 'tag'), \"the returned object is always the same\");\n asyncEqual(get(person, 'tag'), store.find('tag', 5), \"relationship object is the same as object retrieved directly\");\n }));\n});\n\ntest(\"async belongsTo relationships work when the data hash has not been loaded\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag', { async: true })\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n env.adapter.find = function(store, type, id) {\n if (type === Person) {\n equal(id, 1, \"id should be 1\");\n\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", tag: 2 });\n } else if (type === Tag) {\n equal(id, 2, \"id should be 2\");\n\n return Ember.RSVP.resolve({ id: 2, name: \"friendly\" });\n }\n };\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is now populated\");\n\n return get(person, 'tag');\n })).then(async(function(tag) {\n equal(get(tag, 'name'), \"friendly\", \"Tom Dale is now friendly\");\n equal(get(tag, 'isLoaded'), true, \"Tom Dale is now loaded\");\n }));\n});\n\ntest(\"async belongsTo relationships work when the data hash has already been loaded\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag', { async: true })\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.push('tag', { id: 2, name: \"friendly\"});\n store.push('person', { id: 1, name: \"Tom Dale\", tag: 2});\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is now populated\");\n return get(person, 'tag');\n })).then(async(function(tag) {\n equal(get(tag, 'name'), \"friendly\", \"Tom Dale is now friendly\");\n equal(get(tag, 'isLoaded'), true, \"Tom Dale is now loaded\");\n }));\n});\n\ntest(\"calling createRecord and passing in an undefined value for a relationship should be treated as if null\", function () {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag')\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.createRecord('person', {id: 1, tag: undefined});\n\n store.find(Person, 1).then(async(function(person) {\n strictEqual(person.get('tag'), null, \"undefined values should return null relationships\");\n }));\n});\n\ntest(\"findMany is passed the owner record for adapters when some of the object graph is already loaded\", function() {\n var Occupation = DS.Model.extend({\n description: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n Occupation.toString = function() { return \"Occupation\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n occupations: DS.hasMany('occupation', { async: true })\n });\n\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ occupation: Occupation, person: Person }),\n store = env.store;\n\n env.adapter.findMany = function(store, type, ids, owner) {\n equal(type, Occupation, \"type should be Occupation\");\n deepEqual(ids, ['5', '2'], \"ids should be 5 and 2\");\n equal(get(owner, 'id'), 1, \"the owner record id should be 1\");\n\n return Ember.RSVP.resolve([{ id: 5, description: \"fifth\" }, { id: 2, description: \"second\" }]);\n };\n\n store.push('person', { id: 1, name: \"Tom Dale\", occupations: [5, 2] });\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'isLoaded'), true, \"isLoaded should be true\");\n equal(get(person, 'name'), \"Tom Dale\", \"the person is still Tom Dale\");\n\n return get(person, 'occupations');\n })).then(async(function(occupations) {\n equal(get(occupations, 'length'), 2, \"the list of occupations should have the correct length\");\n\n equal(get(occupations.objectAt(0), 'description'), \"fifth\", \"the occupation is the fifth\");\n equal(get(occupations.objectAt(0), 'isLoaded'), true, \"the occupation is now loaded\");\n }));\n});\n\ntest(\"findMany is passed the owner record for adapters when none of the object graph is loaded\", function() {\n var Occupation = DS.Model.extend({\n description: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n Occupation.toString = function() { return \"Occupation\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n occupations: DS.hasMany('occupation', { async: true })\n });\n\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ occupation: Occupation, person: Person }),\n store = env.store;\n\n env.adapter.findMany = function(store, type, ids, owner) {\n equal(type, Occupation, \"type should be Occupation\");\n deepEqual(ids, ['5', '2'], \"ids should be 5 and 2\");\n equal(get(owner, 'id'), 1, \"the owner record id should be 1\");\n\n return Ember.RSVP.resolve([{ id: 5, description: \"fifth\" }, { id: 2, description: \"second\" }]);\n };\n\n env.adapter.find = function(store, type, id) {\n equal(type, Person, \"type should be Person\");\n equal(id, 1, \"id should be 1\");\n\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", occupations: [5, 2] });\n };\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is now populated\");\n\n return get(person, 'occupations');\n })).then(async(function(occupations) {\n equal(get(occupations, 'length'), 2, \"the occupation objects still exist\");\n equal(get(occupations.objectAt(0), 'description'), \"fifth\", \"the occupation is the fifth\");\n equal(get(occupations.objectAt(0), 'isLoaded'), true, \"the occupation is now loaded\");\n }));\n});\n\ntest(\"belongsTo supports relationships to models with id 0\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n people: DS.hasMany('person')\n });\n Tag.toString = function() { return \"Tag\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag')\n });\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.pushMany('tag', [{ id: 0, name: \"friendly\" }, { id: 2, name: \"smarmy\" }, { id: 12, name: \"oohlala\" }]);\n store.push('person', { id: 1, name: \"Tom Dale\", tag: 0 });\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n\n equal(get(person, 'tag') instanceof Tag, true, \"the tag property should return a tag\");\n equal(get(person, 'tag.name'), \"friendly\", \"the tag shuld have name\");\n\n strictEqual(get(person, 'tag'), get(person, 'tag'), \"the returned object is always the same\");\n asyncEqual(get(person, 'tag'), store.find(Tag, 0), \"relationship object is the same as object retrieved directly\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/relationships_test");minispade.register('ember-data/~tests/unit/model/rollback_test', "(function() {var env, store, Person, Dog;\n\nmodule(\"unit/model/rollback - model.rollback()\", {\n setup: function() {\n Person = DS.Model.extend({\n firstName: DS.attr(),\n lastName: DS.attr()\n });\n\n env = setupStore({ person: Person });\n store = env.store;\n }\n});\n\ntest(\"changes to attributes can be rolled back\", function() {\n var person = store.push('person', { id: 1, firstName: \"Tom\", lastName: \"Dale\" });\n\n person.set('firstName', \"Thomas\");\n\n equal(person.get('firstName'), \"Thomas\");\n\n person.rollback();\n\n equal(person.get('firstName'), \"Tom\");\n equal(person.get('isDirty'), false);\n});\n\ntest(\"changes to attributes made after a record is in-flight only rolls back the local changes\", function() {\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n var person = store.push('person', { id: 1, firstName: \"Tom\", lastName: \"Dale\" });\n\n person.set('firstName', \"Thomas\");\n\n // Make sure the save is async\n Ember.run(function() {\n var saving = person.save();\n\n equal(person.get('firstName'), \"Thomas\");\n\n person.set('lastName', \"Dolly\");\n\n equal(person.get('lastName'), \"Dolly\");\n\n person.rollback();\n\n equal(person.get('firstName'), \"Thomas\");\n equal(person.get('lastName'), \"Dale\");\n equal(person.get('isSaving'), true);\n\n saving.then(async(function() {\n equal(person.get('isDirty'), false, \"The person is now clean\");\n }));\n });\n});\n\ntest(\"a record's changes can be made if it fails to save\", function() {\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n var person = store.push('person', { id: 1, firstName: \"Tom\", lastName: \"Dale\" });\n\n person.set('firstName', \"Thomas\");\n\n person.save().then(null, async(function() {\n equal(person.get('isError'), true);\n\n person.rollback();\n\n equal(person.get('firstName'), \"Tom\");\n equal(person.get('isError'), false);\n }));\n});\n\ntest(\"new record can be rollbacked\", function() {\n var person = store.createRecord('person', { id: 1 });\n\n equal(person.get('isNew'), true, \"must be new\");\n equal(person.get('isDirty'), true, \"must be dirty\");\n\n Ember.run(person, 'rollback');\n\n equal(person.get('isNew'), false, \"must not be new\");\n equal(person.get('isDirty'), false, \"must not be dirty\");\n equal(person.get('isDeleted'), true, \"must be deleted\");\n});\n\ntest(\"deleted record can be rollbacked\", function() {\n var person = store.push('person', { id: 1 });\n\n person.deleteRecord();\n\n equal(person.get('isDeleted'), true, \"must be deleted\");\n\n person.rollback();\n\n equal(person.get('isDeleted'), false, \"must not be deleted\");\n equal(person.get('isDirty'), false, \"must not be dirty\");\n});\n\ntest(\"invalid record can be rollbacked\", function() {\n Dog = DS.Model.extend({\n name: DS.attr()\n });\n\n var adapter = DS.RESTAdapter.extend({\n ajax: function(url, type, hash) {\n var adapter = this;\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n Ember.run.next(function(){\n reject(adapter.ajaxError({name: 'is invalid'}));\n });\n });\n },\n\n ajaxError: function(jqXHR) {\n return new DS.InvalidError(jqXHR);\n }\n });\n\n env = setupStore({ dog: Dog, adapter: adapter});\n var dog = env.store.push('dog', { id: 1, name: \"Pluto\" });\n\n dog.set('name', \"is a dwarf planet\");\n\n dog.save().then(null, async(function() {\n dog.rollback();\n\n equal(dog.get('name'), \"Pluto\");\n ok(dog.get('isValid'));\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/rollback_test");minispade.register('ember-data/~tests/unit/model_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar Person, store, array;\n\nmodule(\"unit/model - DS.Model\", {\n setup: function() {\n store = createStore();\n\n Person = DS.Model.extend({\n name: DS.attr('string'),\n isDrugAddict: DS.attr('boolean')\n });\n },\n\n teardown: function() {\n Person = null;\n store = null;\n }\n});\n\ntest(\"can have a property set on it\", function() {\n var record = store.createRecord(Person);\n set(record, 'name', 'bar');\n\n equal(get(record, 'name'), 'bar', \"property was set on the record\");\n});\n\ntest(\"setting a property on a record that has not changed does not cause it to become dirty\", function() {\n store.push(Person, { id: 1, name: \"Peter\", isDrugAddict: true });\n store.find(Person, 1).then(async(function(person) {\n equal(person.get('isDirty'), false, \"precond - person record should not be dirty\");\n person.set('name', \"Peter\");\n person.set('isDrugAddict', true);\n equal(person.get('isDirty'), false, \"record does not become dirty after setting property to old value\");\n }));\n});\n\ntest(\"resetting a property on a record cause it to become clean again\", function() {\n store.push(Person, { id: 1, name: \"Peter\", isDrugAddict: true });\n store.find(Person, 1).then(async(function(person) {\n equal(person.get('isDirty'), false, \"precond - person record should not be dirty\");\n person.set('isDrugAddict', false);\n equal(person.get('isDirty'), true, \"record becomes dirty after setting property to a new value\");\n person.set('isDrugAddict', true);\n equal(person.get('isDirty'), false, \"record becomes clean after resetting property to the old value\");\n }));\n});\n\ntest(\"a record reports its unique id via the `id` property\", function() {\n store.push(Person, { id: 1 });\n\n store.find(Person, 1).then(async(function(record) {\n equal(get(record, 'id'), 1, \"reports id as id by default\");\n }));\n});\n\ntest(\"a record's id is included in its toString representation\", function() {\n store.push(Person, { id: 1 });\n\n store.find(Person, 1).then(async(function(record) {\n equal(record.toString(), '<(subclass of DS.Model):'+Ember.guidFor(record)+':1>', \"reports id in toString\");\n }));\n});\n\ntest(\"trying to set an `id` attribute should raise\", function() {\n Person = DS.Model.extend({\n id: DS.attr('number'),\n name: \"Scumdale\"\n });\n\n expectAssertion(function() {\n store.push(Person, { id: 1, name: \"Scumdale\" });\n var person = store.find(Person, 1);\n }, /You may not set `id`/);\n});\n\ntest(\"it should use `_reference` and not `reference` to store its reference\", function() {\n store.push(Person, { id: 1 });\n\n store.find(Person, 1).then(async(function(record) {\n equal(record.get('reference'), undefined, \"doesn't shadow reference key\");\n }));\n});\n\ntest(\"it should cache attributes\", function() {\n var store = createStore();\n\n var Post = DS.Model.extend({\n updatedAt: DS.attr('string')\n });\n\n var dateString = \"Sat, 31 Dec 2011 00:08:16 GMT\";\n var date = new Date(dateString);\n\n store.push(Post, { id: 1 });\n\n store.find(Post, 1).then(async(function(record) {\n record.set('updatedAt', date);\n deepEqual(date, get(record, 'updatedAt'), \"setting a date returns the same date\");\n strictEqual(get(record, 'updatedAt'), get(record, 'updatedAt'), \"second get still returns the same object\");\n }));\n});\n\nmodule(\"unit/model - DS.Model updating\", {\n setup: function() {\n array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n Person = DS.Model.extend({ name: DS.attr('string') });\n store = createStore();\n store.pushMany(Person, array);\n },\n teardown: function() {\n Person = null;\n store = null;\n array = null;\n }\n});\n\ntest(\"a DS.Model can update its attributes\", function() {\n store.find(Person, 2).then(async(function(person) {\n set(person, 'name', \"Brohuda Katz\");\n equal(get(person, 'name'), \"Brohuda Katz\", \"setting took hold\");\n }));\n});\n\ntest(\"a DS.Model can have a defaultValue\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string', { defaultValue: \"unknown\" })\n });\n\n var tag = store.createRecord(Tag);\n\n equal(get(tag, 'name'), \"unknown\", \"the default value is found\");\n\n set(tag, 'name', null);\n\n equal(get(tag, 'name'), null, \"null doesn't shadow defaultValue\");\n});\n\ntest(\"a defaultValue for an attribite can be a function\", function() {\n var Tag = DS.Model.extend({\n createdAt: DS.attr('string', {\n defaultValue: function() {\n return \"le default value\";\n }\n })\n });\n\n var tag = store.createRecord(Tag);\n equal(get(tag, 'createdAt'), \"le default value\", \"the defaultValue function is evaluated\");\n});\n\nmodule(\"unit/model - with a simple Person model\", {\n setup: function() {\n array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n Person = DS.Model.extend({\n name: DS.attr('string')\n });\n store = createStore({\n person: Person\n });\n store.pushMany(Person, array);\n },\n teardown: function() {\n Person = null;\n store = null;\n array = null;\n }\n});\n\ntest(\"can ask if record with a given id is loaded\", function() {\n equal(store.recordIsLoaded(Person, 1), true, 'should have person with id 1');\n equal(store.recordIsLoaded('person', 1), true, 'should have person with id 1');\n equal(store.recordIsLoaded(Person, 4), false, 'should not have person with id 4');\n equal(store.recordIsLoaded('person', 4), false, 'should not have person with id 4');\n});\n\ntest(\"a listener can be added to a record\", function() {\n var count = 0;\n var F = function() { count++; };\n var record = store.createRecord(Person);\n\n record.on('event!', F);\n record.trigger('event!');\n\n equal(count, 1, \"the event was triggered\");\n\n record.trigger('event!');\n\n equal(count, 2, \"the event was triggered\");\n});\n\ntest(\"when an event is triggered on a record the method with the same name is invoked with arguments\", function(){\n var count = 0;\n var F = function() { count++; };\n var record = store.createRecord(Person);\n\n record.eventNamedMethod = F;\n\n record.trigger('eventNamedMethod');\n\n equal(count, 1, \"the corresponding method was called\");\n});\n\ntest(\"when a method is invoked from an event with the same name the arguments are passed through\", function(){\n var eventMethodArgs = null;\n var F = function() { eventMethodArgs = arguments; };\n var record = store.createRecord(Person);\n\n record.eventThatTriggersMethod = F;\n\n record.trigger('eventThatTriggersMethod', 1, 2);\n\n equal( eventMethodArgs[0], 1);\n equal( eventMethodArgs[1], 2);\n});\n\nvar converts = function(type, provided, expected) {\n var Model = DS.Model.extend({\n name: DS.attr(type)\n });\n\n var container = new Ember.Container();\n\n var testStore = createStore({model: Model}),\n serializer = DS.JSONSerializer.create({ store: testStore, container: container });\n\n testStore.push(Model, serializer.normalize(Model, { id: 1, name: provided }));\n testStore.push(Model, serializer.normalize(Model, { id: 2 }));\n\n testStore.find('model', 1).then(async(function(record) {\n deepEqual(get(record, 'name'), expected, type + \" coerces \" + provided + \" to \" + expected);\n }));\n\n // See: Github issue #421\n // record = testStore.find(Model, 2);\n // set(record, 'name', provided);\n // deepEqual(get(record, 'name'), expected, type + \" coerces \" + provided + \" to \" + expected);\n};\n\nvar convertsFromServer = function(type, provided, expected) {\n var Model = DS.Model.extend({\n name: DS.attr(type)\n });\n\n var container = new Ember.Container();\n\n var testStore = createStore({model: Model}),\n serializer = DS.JSONSerializer.create({ store: testStore, container: container });\n\n testStore.push(Model, serializer.normalize(Model, { id: \"1\", name: provided }));\n testStore.find('model', 1).then(async(function(record) {\n deepEqual(get(record, 'name'), expected, type + \" coerces \" + provided + \" to \" + expected);\n }));\n};\n\nvar convertsWhenSet = function(type, provided, expected) {\n var Model = DS.Model.extend({\n name: DS.attr(type)\n });\n\n var testStore = createStore({model: Model});\n\n testStore.push(Model, { id: 2 });\n var record = testStore.find('model', 2).then(async(function(record) {\n set(record, 'name', provided);\n deepEqual(record.serialize().name, expected, type + \" saves \" + provided + \" as \" + expected);\n }));\n};\n\ntest(\"a DS.Model can describe String attributes\", function() {\n converts('string', \"Scumbag Tom\", \"Scumbag Tom\");\n converts('string', 1, \"1\");\n converts('string', \"\", \"\");\n converts('string', null, null);\n converts('string', undefined, null);\n convertsFromServer('string', undefined, null);\n});\n\ntest(\"a DS.Model can describe Number attributes\", function() {\n converts('number', \"1\", 1);\n converts('number', \"0\", 0);\n converts('number', 1, 1);\n converts('number', 0, 0);\n converts('number', \"\", null);\n converts('number', null, null);\n converts('number', undefined, null);\n converts('number', true, 1);\n converts('number', false, 0);\n});\n\ntest(\"a DS.Model can describe Boolean attributes\", function() {\n converts('boolean', \"1\", true);\n converts('boolean', \"\", false);\n converts('boolean', 1, true);\n converts('boolean', 0, false);\n converts('boolean', null, false);\n converts('boolean', true, true);\n converts('boolean', false, false);\n});\n\ntest(\"a DS.Model can describe Date attributes\", function() {\n converts('date', null, null);\n converts('date', undefined, undefined);\n\n var dateString = \"Sat, 31 Dec 2011 00:08:16 GMT\";\n var date = new Date(dateString);\n\n var store = createStore();\n\n var Person = DS.Model.extend({\n updatedAt: DS.attr('date')\n });\n\n store.push(Person, { id: 1 });\n store.find(Person, 1).then(async(function(record) {\n record.set('updatedAt', date);\n deepEqual(date, get(record, 'updatedAt'), \"setting a date returns the same date\");\n }));\n\n convertsFromServer('date', dateString, date);\n convertsWhenSet('date', date, dateString);\n});\n\ntest(\"don't allow setting\", function(){\n var store = createStore();\n\n var Person = DS.Model.extend();\n var record = store.createRecord(Person);\n\n raises(function(){\n record.set('isLoaded', true);\n }, \"raised error when trying to set an unsettable record\");\n});\n\ntest(\"ensure model exits loading state, materializes data and fulfills promise only after data is available\", function () {\n var store = createStore({\n adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"John\", isDrugAddict: false });\n }\n })\n });\n\n store.find(Person, 1).then(async(function(person) {\n equal(get(person, 'currentState.stateName'), 'root.loaded.saved', 'model is in loaded state');\n equal(get(person, 'isLoaded'), true, 'model is loaded');\n }));\n});\n\ntest(\"A DS.Model can be JSONified\", function() {\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var store = createStore({ person: Person });\n var record = store.createRecord('person', { name: \"TomHuda\" });\n deepEqual(record.toJSON(), { name: \"TomHuda\" });\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model_test");minispade.register('ember-data/~tests/unit/record_array_test', "(function() {var get = Ember.get, set = Ember.set;\nvar indexOf = Ember.EnumerableUtils.indexOf;\n\nvar Person, array;\n\nmodule(\"unit/record_array - DS.RecordArray\", {\n setup: function() {\n array = [{ id: '1', name: \"Scumbag Dale\" }, { id: '2', name: \"Scumbag Katz\" }, { id: '3', name: \"Scumbag Bryn\" }];\n\n Person = DS.Model.extend({\n name: DS.attr('string')\n });\n }\n});\n\ntest(\"a record array is backed by records\", function() {\n var store = createStore();\n store.pushMany(Person, array);\n\n store.findByIds(Person, [1,2,3]).then(async(function(records) {\n for (var i=0, l=get(array, 'length'); i<l; i++) {\n deepEqual(records[i].getProperties('id', 'name'), array[i], \"a record array materializes objects on demand\");\n }\n }));\n});\n\ntest(\"acts as a live query\", function() {\n var store = createStore();\n\n var recordArray = store.all(Person);\n store.push(Person, { id: 1, name: 'wycats' });\n equal(get(recordArray, 'lastObject.name'), 'wycats');\n\n store.push(Person, { id: 2, name: 'brohuda' });\n equal(get(recordArray, 'lastObject.name'), 'brohuda');\n});\n\ntest(\"a loaded record is removed from a record array when it is deleted\", function() {\n var Tag = DS.Model.extend({\n people: DS.hasMany('person')\n });\n\n Person.reopen({\n tag: DS.belongsTo('tag')\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.pushMany('person', array);\n store.push('tag', { id: 1 });\n\n var asyncRecords = Ember.RSVP.hash({\n scumbag: store.find('person', 1),\n tag: store.find('tag', 1)\n });\n\n asyncRecords.then(async(function(records) {\n var scumbag = records.scumbag, tag = records.tag;\n\n tag.get('people').addObject(scumbag);\n equal(get(scumbag, 'tag'), tag, \"precond - the scumbag's tag has been set\");\n\n var recordArray = tag.get('people');\n\n equal(get(recordArray, 'length'), 1, \"precond - record array has one item\");\n equal(get(recordArray.objectAt(0), 'name'), \"Scumbag Dale\", \"item at index 0 is record with id 1\");\n\n scumbag.deleteRecord();\n\n equal(get(recordArray, 'length'), 0, \"record is removed from the record array\");\n }));\n});\n\n// GitHub Issue #168\ntest(\"a newly created record is removed from a record array when it is deleted\", function() {\n var store = createStore(),\n recordArray;\n\n recordArray = store.all(Person);\n\n var scumbag = store.createRecord(Person, {\n name: \"Scumbag Dale\"\n });\n\n equal(get(recordArray, 'length'), 1, \"precond - record array already has the first created item\");\n\n // guarantee coalescence\n Ember.run(function() {\n store.createRecord(Person, { name: 'p1'});\n store.createRecord(Person, { name: 'p2'});\n store.createRecord(Person, { name: 'p3'});\n });\n\n equal(get(recordArray, 'length'), 4, \"precond - record array has the created item\");\n equal(get(recordArray.objectAt(0), 'name'), \"Scumbag Dale\", \"item at index 0 is record with id 1\");\n\n scumbag.deleteRecord();\n\n equal(get(recordArray, 'length'), 3, \"record is removed from the record array\");\n\n recordArray.objectAt(0).set('name', 'toto');\n\n equal(get(recordArray, 'length'), 3, \"record is still removed from the record array\");\n});\n\ntest(\"a record array returns undefined when asking for a member outside of its content Array's range\", function() {\n var store = createStore();\n\n store.pushMany(Person, array);\n\n var recordArray = store.all(Person);\n\n strictEqual(recordArray.objectAt(20), undefined, \"objects outside of the range just return undefined\");\n});\n\n// This tests for a bug in the recordCache, where the records were being cached in the incorrect order.\ntest(\"a record array should be able to be enumerated in any order\", function() {\n var store = createStore();\n store.pushMany(Person, array);\n\n var recordArray = store.all(Person);\n\n equal(get(recordArray.objectAt(2), 'id'), 3, \"should retrieve correct record at index 2\");\n equal(get(recordArray.objectAt(1), 'id'), 2, \"should retrieve correct record at index 1\");\n equal(get(recordArray.objectAt(0), 'id'), 1, \"should retrieve correct record at index 0\");\n});\n\nvar shouldContain = function(array, item) {\n ok(indexOf(array, item) !== -1, \"array should contain \"+item.get('name'));\n};\n\nvar shouldNotContain = function(array, item) {\n ok(indexOf(array, item) === -1, \"array should not contain \"+item.get('name'));\n};\n\ntest(\"an AdapterPopulatedRecordArray knows if it's loaded or not\", function() {\n var env = setupStore({ person: Person }),\n store = env.store;\n\n env.adapter.findQuery = function(store, type, query, recordArray) {\n return Ember.RSVP.resolve(array);\n };\n\n store.find('person', { page: 1 }).then(async(function(people) {\n equal(get(people, 'isLoaded'), true, \"The array is now loaded\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/record_array_test");minispade.register('ember-data/~tests/unit/states_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar rootState, stateName;\n\nmodule(\"unit/states - Flags for record states\", {\n setup: function() {\n rootState = DS.RootState;\n }\n});\n\nvar isTrue = function(flag) {\n equal(get(rootState, stateName + \".\" + flag), true, stateName + \".\" + flag + \" should be true\");\n};\n\nvar isFalse = function(flag) {\n equal(get(rootState, stateName + \".\" + flag), false, stateName + \".\" + flag + \" should be false\");\n};\n\ntest(\"the empty state\", function() {\n stateName = \"empty\";\n isFalse(\"isLoading\");\n isFalse(\"isLoaded\");\n isFalse(\"isDirty\");\n isFalse(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the loading state\", function() {\n stateName = \"loading\";\n isTrue(\"isLoading\");\n isFalse(\"isLoaded\");\n isFalse(\"isDirty\");\n isFalse(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the loaded state\", function() {\n stateName = \"loaded\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isFalse(\"isDirty\");\n isFalse(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the updated state\", function() {\n stateName = \"loaded.updated\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isTrue(\"isDirty\");\n isFalse(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the saving state\", function() {\n stateName = \"loaded.updated.inFlight\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isTrue(\"isDirty\");\n isTrue(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the deleted state\", function() {\n stateName = \"deleted\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isTrue(\"isDirty\");\n isFalse(\"isSaving\");\n isTrue(\"isDeleted\");\n});\n\ntest(\"the deleted.saving state\", function() {\n stateName = \"deleted.inFlight\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isTrue(\"isDirty\");\n isTrue(\"isSaving\");\n isTrue(\"isDeleted\");\n});\n\ntest(\"the deleted.saved state\", function() {\n stateName = \"deleted.saved\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isFalse(\"isDirty\");\n isFalse(\"isSaving\");\n isTrue(\"isDeleted\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/states_test");minispade.register('ember-data/~tests/unit/store/adapter_interop_test', "(function() {var get = Ember.get, set = Ember.set;\nvar resolve = Ember.RSVP.resolve;\nvar TestAdapter, store;\n\nmodule(\"unit/store/adapter_interop - DS.Store working with a DS.Adapter\", {\n setup: function() {\n TestAdapter = DS.Adapter.extend();\n },\n teardown: function() {\n if (store) { store.destroy(); }\n }\n});\n\ntest(\"Adapter can be set as a factory\", function() {\n store = createStore({adapter: TestAdapter});\n\n ok(store.get('defaultAdapter') instanceof TestAdapter);\n});\n\ntest('Adapter can be set as a name', function() {\n store = createStore({adapter: '_rest'});\n\n ok(store.get('defaultAdapter') instanceof DS.RESTAdapter);\n});\n\ntest('Adapter can not be set as an instance', function() {\n store = DS.Store.create({\n adapter: DS.Adapter.create()\n });\n var assert = Ember.assert;\n Ember.assert = function() { ok(true, \"raises an error when passing in an instance\"); };\n store.get('defaultAdapter');\n Ember.assert = assert;\n});\n\ntest(\"Calling Store#find invokes its adapter#find\", function() {\n expect(4);\n\n var adapter = TestAdapter.extend({\n find: function(store, type, id) {\n ok(true, \"Adapter#find was called\");\n equal(store, currentStore, \"Adapter#find was called with the right store\");\n equal(type, currentType, \"Adapter#find was called with the type passed into Store#find\");\n equal(id, 1, \"Adapter#find was called with the id passed into Store#find\");\n\n return Ember.RSVP.resolve({ id: 1 });\n }\n });\n\n var currentStore = createStore({ adapter: adapter });\n var currentType = DS.Model.extend();\n\n currentStore.find(currentType, 1);\n});\n\ntest(\"Returning a promise from `find` asynchronously loads data\", function() {\n var adapter = TestAdapter.extend({\n find: function(store, type, id) {\n return resolve({ id: 1, name: \"Scumbag Dale\" });\n }\n });\n\n var currentStore = createStore({ adapter: adapter });\n var currentType = DS.Model.extend({\n name: DS.attr('string')\n });\n\n currentStore.find(currentType, 1).then(async(function(object) {\n strictEqual(get(object, 'name'), \"Scumbag Dale\", \"the data was pushed\");\n }));\n});\n\ntest(\"IDs provided as numbers are coerced to strings\", function() {\n var adapter = TestAdapter.extend({\n find: function(store, type, id) {\n equal(typeof id, 'string', \"id has been normalized to a string\");\n return resolve({ id: 1, name: \"Scumbag Sylvain\" });\n }\n });\n\n var currentStore = createStore({ adapter: adapter });\n var currentType = DS.Model.extend({\n name: DS.attr('string')\n });\n\n currentStore.find(currentType, 1).then(async(function(object) {\n equal(typeof object.get('id'), 'string', \"id was coerced to a string\");\n currentStore.push(currentType, { id: 2, name: \"Scumbag Sam Saffron\" });\n return currentStore.find(currentType, 2);\n })).then(async(function(object) {\n ok(object, \"object was found\");\n equal(typeof object.get('id'), 'string', \"id is a string despite being supplied and searched for as a number\");\n }));\n});\n\n\nvar array = [{ id: \"1\", name: \"Scumbag Dale\" }, { id: \"2\", name: \"Scumbag Katz\" }, { id: \"3\", name: \"Scumbag Bryn\" }];\n\ntest(\"can load data for the same record if it is not dirty\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n store.push(Person, { id: 1, name: \"Tom Dale\" });\n\n var tom = store.find(Person, 1).then(async(function(tom) {\n equal(get(tom, 'isDirty'), false, \"precond - record is not dirty\");\n equal(get(tom, 'name'), \"Tom Dale\", \"returns the correct name\");\n\n store.push(Person, { id: 1, name: \"Captain Underpants\" });\n equal(get(tom, 'name'), \"Captain Underpants\", \"updated record with new date\");\n }));\n\n});\n\n/*\ntest(\"DS.Store loads individual records without explicit IDs with a custom primaryKey\", function() {\n var store = DS.Store.create();\n var Person = DS.Model.extend({ name: DS.attr('string'), primaryKey: 'key' });\n\n store.load(Person, { key: 1, name: \"Tom Dale\" });\n\n var tom = store.find(Person, 1);\n equal(get(tom, 'name'), \"Tom Dale\", \"the person was successfully loaded for the given ID\");\n});\n*/\n\ntest(\"pushMany extracts ids from an Array of hashes if no ids are specified\", function() {\n var store = createStore();\n\n var Person = DS.Model.extend({ name: DS.attr('string') });\n\n store.pushMany(Person, array);\n store.find(Person, 1).then(async(function(person) {\n equal(get(person, 'name'), \"Scumbag Dale\", \"correctly extracted id for loaded data\");\n }));\n});\n\ntest(\"loadMany takes an optional Object and passes it on to the Adapter\", function() {\n var passedQuery = { page: 1 };\n\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var adapter = TestAdapter.extend({\n findQuery: function(store, type, query) {\n equal(type, Person, \"The type was Person\");\n equal(query, passedQuery, \"The query was passed in\");\n return Ember.RSVP.resolve([]);\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n store.find(Person, passedQuery);\n});\n\ntest(\"Find with query calls the correct extract\", function() {\n var passedQuery = { page: 1 };\n\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var adapter = TestAdapter.extend({\n findQuery: function(store, type, query) {\n return Ember.RSVP.resolve([]);\n }\n });\n\n var callCount = 0;\n\n var ApplicationSerializer = DS.JSONSerializer.extend({\n extractFindQuery: function(store, type, payload) {\n callCount++;\n return [];\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n store.container.register('serializer:application', ApplicationSerializer);\n\n store.find(Person, passedQuery);\n equal(callCount, 1, 'extractFindQuery was called');\n});\n\ntest(\"all(type) returns a record array of all records of a specific type\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n store.push(Person, { id: 1, name: \"Tom Dale\" });\n\n var results = store.all(Person);\n equal(get(results, 'length'), 1, \"record array should have the original object\");\n equal(get(results.objectAt(0), 'name'), \"Tom Dale\", \"record has the correct information\");\n\n store.push(Person, { id: 2, name: \"Yehuda Katz\" });\n equal(get(results, 'length'), 2, \"record array should have the new object\");\n equal(get(results.objectAt(1), 'name'), \"Yehuda Katz\", \"record has the correct information\");\n\n strictEqual(results, store.all(Person), \"subsequent calls to all return the same recordArray)\");\n});\n\ntest(\"a new record of a particular type is created via store.createRecord(type)\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var person = store.createRecord(Person);\n\n equal(get(person, 'isLoaded'), true, \"A newly created record is loaded\");\n equal(get(person, 'isNew'), true, \"A newly created record is new\");\n equal(get(person, 'isDirty'), true, \"A newly created record is dirty\");\n\n set(person, 'name', \"Braaahm Dale\");\n\n equal(get(person, 'name'), \"Braaahm Dale\", \"Even if no hash is supplied, `set` still worked\");\n});\n\ntest(\"a new record with a specific id can't be created if this id is already used in the store\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n Person.reopenClass({\n toString: function() {\n return 'Person';\n }\n });\n\n store.createRecord(Person, {id: 5});\n\n expectAssertion(function() {\n store.createRecord(Person, {id: 5});\n }, /The id 5 has already been used with another record of type Person/);\n});\n\ntest(\"an initial data hash can be provided via store.createRecord(type, hash)\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var person = store.createRecord(Person, { name: \"Brohuda Katz\" });\n\n equal(get(person, 'isLoaded'), true, \"A newly created record is loaded\");\n equal(get(person, 'isNew'), true, \"A newly created record is new\");\n equal(get(person, 'isDirty'), true, \"A newly created record is dirty\");\n\n equal(get(person, 'name'), \"Brohuda Katz\", \"The initial data hash is provided\");\n});\n\ntest(\"if an id is supplied in the initial data hash, it can be looked up using `store.find`\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var person = store.createRecord(Person, { id: 1, name: \"Brohuda Katz\" });\n\n store.find(Person, 1).then(async(function(again) {\n strictEqual(person, again, \"the store returns the loaded object\");\n }));\n});\n\ntest(\"records inside a collection view should have their ids updated\", function() {\n var Person = DS.Model.extend();\n\n var idCounter = 1;\n var adapter = TestAdapter.extend({\n createRecord: function(store, type, record) {\n return Ember.RSVP.resolve({name: record.get('name'), id: idCounter++});\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n var container = Ember.CollectionView.create({\n content: store.all(Person)\n });\n\n container.appendTo('#qunit-fixture');\n\n var tom = store.createRecord(Person, {name: 'Tom Dale'});\n var yehuda = store.createRecord(Person, {name: 'Yehuda Katz'});\n\n Ember.RSVP.all([ tom.save(), yehuda.save() ]).then(async(function() {\n container.content.forEach(function(person, index) {\n equal(person.get('id'), index + 1, \"The record's id should be correct.\");\n });\n\n container.destroy();\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/adapter_interop_test");minispade.register('ember-data/~tests/unit/store/create_record_test', "(function() {var get = Ember.get, set = Ember.set;\nvar store, Record;\n\nmodule(\"unit/store/createRecord - Store creating records\", {\n setup: function() {\n store = createStore({ adapter: DS.Adapter.extend()});\n\n Record = DS.Model.extend({\n title: DS.attr('string')\n });\n }\n});\n\ntest(\"doesn't modify passed in properties hash\", function(){\n var attributes = { foo: 'bar' },\n record1 = store.createRecord(Record, attributes),\n record2 = store.createRecord(Record, attributes);\n\n deepEqual(attributes, { foo: 'bar' }, \"The properties hash is not modified\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/create_record_test");minispade.register('ember-data/~tests/unit/store/model_for_test', "(function() {var container, store;\n\nmodule(\"unit/store/model_for - DS.Store#modelFor\", {\n setup: function() {\n store = createStore({blogPost: DS.Model.extend()});\n container = store.container;\n },\n\n teardown: function() {\n container.destroy();\n store.destroy();\n }\n});\n\ntest(\"sets a normalized key as typeKey\", function() {\n container.normalize = function(fullName){\n return Ember.String.camelize(fullName);\n };\n\n ok(store.modelFor(\"blog.post\").typeKey, \"blogPost\", \"typeKey is normalized\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/model_for_test");minispade.register('ember-data/~tests/unit/store/push_test', "(function() {var env, store, Person, PhoneNumber, Post;\nvar attr = DS.attr, hasMany = DS.hasMany, belongsTo = DS.belongsTo;\n\nmodule(\"unit/store/push - DS.Store#push\", {\n setup: function() {\n Person = DS.Model.extend({\n firstName: attr('string'),\n lastName: attr('string'),\n phoneNumbers: hasMany('phone-number')\n });\n\n PhoneNumber = DS.Model.extend({\n number: attr('string'),\n person: belongsTo('person')\n });\n\n Post = DS.Model.extend({\n postTitle: attr('string')\n });\n\n env = setupStore({\"post\": Post,\n \"person\": Person,\n \"phone-number\": PhoneNumber});\n\n store = env.store;\n\n env.container.register('serializer:post', DS.ActiveModelSerializer);\n },\n\n teardown: function() {\n Ember.run(function() {\n store.destroy();\n });\n }\n});\n\ntest(\"Calling push with a normalized hash returns a record\", function() {\n var person = store.push('person', {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n\n store.find('person', 'wat').then(async(function(foundPerson) {\n equal(foundPerson, person, \"record returned via load() is the same as the record returned from find()\");\n deepEqual(foundPerson.getProperties('id', 'firstName', 'lastName'), {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n }));\n});\n\ntest(\"Supplying a model class for `push` is the same as supplying a string\", function () {\n var Programmer = Person.extend();\n env.container.register('model:programmer', Programmer);\n\n var programmer = store.push(Programmer, {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n\n store.find('programmer', 'wat').then(async(function(foundProgrammer) {\n deepEqual(foundProgrammer.getProperties('id', 'firstName', 'lastName'), {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n }));\n});\n\ntest(\"Calling push triggers `didLoad` even if the record hasn't been requested from the adapter\", function() {\n Person.reopen({\n didLoad: async(function() {\n ok(true, \"The didLoad callback was called\");\n })\n });\n\n store.push('person', {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n});\n\ntest(\"Calling update with partial records updates just those attributes\", function() {\n var person = store.push('person', {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n\n store.update('person', {\n id: 'wat',\n lastName: \"Katz!\"\n });\n\n store.find('person', 'wat').then(async(function(foundPerson) {\n equal(foundPerson, person, \"record returned via load() is the same as the record returned from find()\");\n deepEqual(foundPerson.getProperties('id', 'firstName', 'lastName'), {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz!\"\n });\n }));\n});\n\ntest(\"Calling push with a normalized hash containing related records returns a record\", function() {\n var number1 = store.push('phone-number', {\n id: 1,\n number: '5551212',\n person: 'wat'\n });\n\n var number2 = store.push('phone-number', {\n id: 2,\n number: '5552121',\n person: 'wat'\n });\n\n var person = store.push('person', {\n id: 'wat',\n firstName: 'John',\n lastName: 'Smith',\n phoneNumbers: [number1, number2]\n });\n\n deepEqual(person.get('phoneNumbers').toArray(), [ number1, number2 ], \"phoneNumbers array is correct\");\n});\n\ntest(\"Calling push with a normalized hash containing IDs of related records returns a record\", function() {\n Person.reopen({\n phoneNumbers: hasMany('phone-number', { async: true })\n });\n\n env.adapter.find = function(store, type, id) {\n if (id === \"1\") {\n return Ember.RSVP.resolve({\n id: 1,\n number: '5551212',\n person: 'wat'\n });\n }\n\n if (id === \"2\") {\n return Ember.RSVP.resolve({\n id: 2,\n number: '5552121',\n person: 'wat'\n });\n }\n };\n\n var person = store.push('person', {\n id: 'wat',\n firstName: 'John',\n lastName: 'Smith',\n phoneNumbers: [\"1\", \"2\"]\n });\n\n person.get('phoneNumbers').then(async(function(phoneNumbers) {\n deepEqual(phoneNumbers.map(function(item) {\n return item.getProperties('id', 'number', 'person');\n }), [{\n id: \"1\",\n number: '5551212',\n person: person\n }, {\n id: \"2\",\n number: '5552121',\n person: person\n }]);\n }));\n});\n\ntest(\"Calling pushPayload allows pushing raw JSON\", function () {\n store.pushPayload('post', {posts: [{\n id: '1',\n post_title: \"Ember rocks\"\n }]});\n\n var post = store.getById('post', 1);\n\n equal(post.get('postTitle'), \"Ember rocks\", \"you can push raw JSON into the store\");\n\n store.pushPayload('post', {posts: [{\n id: '1',\n post_title: \"Ember rocks (updated)\"\n }]});\n\n equal(post.get('postTitle'), \"Ember rocks (updated)\", \"You can update data in the store\");\n});\n\ntest(\"Calling pushPayload allows pushing singular payload properties\", function () {\n store.pushPayload('post', {post: {\n id: '1',\n post_title: \"Ember rocks\"\n }});\n\n var post = store.getById('post', 1);\n\n equal(post.get('postTitle'), \"Ember rocks\", \"you can push raw JSON into the store\");\n\n store.pushPayload('post', {post: {\n id: '1',\n post_title: \"Ember rocks (updated)\"\n }});\n\n equal(post.get('postTitle'), \"Ember rocks (updated)\", \"You can update data in the store\");\n});\n\ntest(\"Calling pushPayload without a type uses application serializer\", function () {\n expect(2);\n\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n pushPayload: function(store, payload) {\n ok(true, \"pushPayload is called on Application serializer\");\n return this._super(store, payload);\n }\n }));\n\n store.pushPayload({posts: [{\n id: '1',\n postTitle: \"Ember rocks\"\n }]});\n\n var post = store.getById('post', 1);\n\n equal(post.get('postTitle'), \"Ember rocks\", \"you can push raw JSON into the store\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/push_test");minispade.register('ember-data/~tests/unit/store/serializer_for_test', "(function() {var container, store, app;\n\nmodule(\"unit/store/serializer_for - DS.Store#serializerFor\", {\n setup: function() {\n store = createStore({person: DS.Model.extend()});\n container = store.container;\n },\n\n teardown: function() {\n container.destroy();\n store.destroy();\n }\n});\n\ntest(\"Calling serializerFor looks up 'serializer:<type>' from the container\", function() {\n var PersonSerializer = DS.JSONSerializer.extend();\n\n container.register('serializer:person', PersonSerializer);\n\n ok(store.serializerFor('person') instanceof PersonSerializer, \"serializer returned from serializerFor is an instance of the registered Serializer class\");\n});\n\ntest(\"Calling serializerFor with a type that has not been registered looks up the default ApplicationSerializer\", function() {\n var ApplicationSerializer = DS.JSONSerializer.extend();\n\n container.register('serializer:application', ApplicationSerializer);\n\n ok(store.serializerFor('person') instanceof ApplicationSerializer, \"serializer returned from serializerFor is an instance of ApplicationSerializer\");\n});\n\ntest(\"Calling serializerFor with a type that has not been registered and in an application that does not have an ApplicationSerializer looks up the default Ember Data serializer\", function() {\n ok(store.serializerFor('person') instanceof DS.JSONSerializer, \"serializer returned from serializerFor is an instance of DS.JSONSerializer\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/serializer_for_test");minispade.register('ember-data/~tests/unit/store/unload_test', "(function() {var get = Ember.get, set = Ember.set;\nvar store, tryToFind, Record;\n\nmodule(\"unit/store/unload - Store unloading records\", {\n setup: function() {\n store = createStore({ adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n tryToFind = true;\n return Ember.RSVP.resolve({ id: id, wasFetched: true });\n }\n })\n });\n\n Record = DS.Model.extend({\n title: DS.attr('string')\n });\n },\n\n teardown: function() {\n Ember.run(store, 'destroy');\n }\n});\n\ntest(\"unload a dirty record\", function() {\n store.push(Record, {id: 1, title: 'toto'});\n\n store.find(Record, 1).then(async(function(record) {\n record.set('title', 'toto2');\n\n equal(get(record, 'isDirty'), true, \"record is dirty\");\n expectAssertion(function() {\n record.unloadRecord();\n }, \"You can only unload a loaded, non-dirty record.\", \"can not unload dirty record\");\n }));\n});\n\ntest(\"unload a record\", function() {\n store.push(Record, {id: 1, title: 'toto'});\n\n store.find(Record, 1).then(async(function(record) {\n equal(get(record, 'id'), 1, \"found record with id 1\");\n equal(get(record, 'isDirty'), false, \"record is not dirty\");\n\n store.unloadRecord(record);\n\n equal(get(record, 'isDirty'), false, \"record is not dirty\");\n equal(get(record, 'isDeleted'), true, \"record is deleted\");\n\n tryToFind = false;\n store.find(Record, 1);\n equal(tryToFind, true, \"not found record with id 1\");\n }));\n});\n\nmodule(\"DS.Store - unload record with relationships\");\n\ntest(\"can commit store after unload record with relationships\", function() {\n store = createStore({ adapter: DS.Adapter.extend({\n find: function() {\n return Ember.RSVP.resolve({ id: 1, description: 'cuisinart', brand: 1 });\n },\n createRecord: function(store, type, record) {\n return Ember.RSVP.resolve();\n }\n })\n });\n\n var like, product, brand;\n\n var Brand = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Product = DS.Model.extend({\n description: DS.attr('string'),\n brand: DS.belongsTo(Brand)\n });\n\n var Like = DS.Model.extend({\n product: DS.belongsTo(Product)\n });\n\n store.push(Brand, { id: 1, name: 'EmberJS' });\n store.push(Product, { id: 1, description: 'toto', brand: 1 });\n\n var asyncRecords = Ember.RSVP.hash({\n brand: store.find(Brand, 1),\n product: store.find(Product, 1)\n });\n\n asyncRecords.then(async(function(records) {\n like = store.createRecord(Like, { id: 1, product: product });\n records.like = like.save();\n return Ember.RSVP.hash(records);\n })).then(async(function(records) {\n store.unloadRecord(records.product);\n\n return store.find(Product, 1);\n })).then(async(function(product) {\n equal(product.get('description'), 'cuisinart', \"The record was unloaded and the adapter's `find` was called\");\n store.destroy();\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/unload_test");minispade.register('ember-inflector/~tests/system/inflector_test', "(function() {var inflector;\nmodule('ember-inflector.dsl', {\n setup: function() {\n inflector = new Ember.Inflector(/* no rulest == no rules */);\n },\n teardown: function() {\n inflector = undefined;\n }\n});\n\ntest('ability to add additonal pluralization rules', function(){\n equal(inflector.pluralize('cow'), 'cow', 'no pluralization rule');\n\n inflector.plural(/$/, 's');\n\n equal(inflector.pluralize('cow'), 'cows', 'pluralization rule was applied');\n});\n\ntest('ability to add additonal singularization rules', function(){\n equal(inflector.singularize('cows'), 'cows', 'no singularization rule was applied');\n\n inflector.singular(/s$/, '');\n\n equal(inflector.singularize('cows'), 'cow', 'singularization rule was applied');\n});\n\ntest('ability to add additonal uncountable rules', function(){\n inflector.plural(/$/, 's');\n equal(inflector.pluralize('cow'), 'cows', 'pluralization rule was applied');\n\n inflector.uncountable('cow');\n equal(inflector.pluralize('cow'), 'cow', 'pluralization rule NOT was applied');\n});\n\ntest('ability to add additonal irregular rules', function(){\n inflector.singular(/s$/, '');\n inflector.plural(/$/, 's');\n\n equal(inflector.singularize('cows'), 'cow', 'regular singularization rule was applied');\n equal(inflector.pluralize('cow'), 'cows', 'regular pluralization rule was applied');\n\n inflector.irregular('cow', 'kine');\n\n equal(inflector.singularize('kine'), 'cow', 'irregular singularization rule was applied');\n equal(inflector.pluralize('cow'), 'kine', 'irregular pluralization rule was applied');\n});\n\ntest('ability to add identical singular and pluralizations',function(){\n\n inflector.singular(/s$/, '');\n inflector.plural(/$/, 's');\n\n equal(inflector.singularize('settings'),'setting','regular singularization rule was applied');\n equal(inflector.pluralize('setting'),'settings','regular pluralization rule was applied');\n\n inflector.irregular('settings','settings');\n inflector.irregular('userPreferences','userPreferences');\n\n equal(inflector.singularize('settings'),'settings','irregular singularization rule was applied on lowercase word');\n equal(inflector.pluralize('settings'),'settings','irregular pluralization rule was applied on lowercase word');\n\n equal(inflector.singularize('userPreferences'),'userPreferences','irregular singularization rule was applied on camelcase word');\n equal(inflector.pluralize('userPreferences'),'userPreferences','irregular pluralization rule was applied on camelcase word');\n});\n\nmodule('ember-inflector.unit');\n\ntest('plurals', function() {\n expect(1);\n\n var inflector = new Ember.Inflector({\n plurals: [\n [/$/, 's'],\n [/s$/i, 's']\n ]\n });\n\n equal(inflector.pluralize('apple'), 'apples');\n});\n\ntest('singularization',function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n singular: [\n [/s$/i, ''],\n [/(ss)$/i, '$1']\n ]\n });\n\n equal(inflector.singularize('apple'), 'apple');\n});\n\ntest('singularization of irregulars', function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n irregularPairs: [\n ['person', 'people']\n ]\n });\n\n equal(inflector.singularize('person'), 'person');\n});\n\ntest('plural',function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n plurals: [\n ['1', '1'],\n ['2', '2'],\n ['3', '3']\n ]\n });\n\n equal(inflector.rules.plurals.length, 3);\n});\n\ntest('singular',function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n singular: [\n ['1', '1'],\n ['2', '2'],\n ['3', '3']\n ]\n });\n\n equal(inflector.rules.singular.length, 3);\n});\n\ntest('irregular',function(){\n expect(6);\n\n var inflector = new Ember.Inflector({\n irregularPairs: [\n ['1', '12'],\n ['2', '22'],\n ['3', '32']\n ]\n });\n\n equal(inflector.rules.irregular['1'], '12');\n equal(inflector.rules.irregular['2'], '22');\n equal(inflector.rules.irregular['3'], '32');\n\n equal(inflector.rules.irregularInverse['12'], '1');\n equal(inflector.rules.irregularInverse['22'], '2');\n equal(inflector.rules.irregularInverse['32'], '3');\n});\n\ntest('uncountable',function(){\n expect(3);\n\n var inflector = new Ember.Inflector({\n uncountable: [\n '1',\n '2',\n '3'\n ]\n });\n\n equal(inflector.rules.uncountable['1'], true);\n equal(inflector.rules.uncountable['2'], true);\n equal(inflector.rules.uncountable['3'], true);\n});\n\ntest('inflect.nothing', function(){\n expect(2);\n\n var inflector = new Ember.Inflector();\n\n equal(inflector.inflect('', []), '');\n equal(inflector.inflect(' ', []), ' ');\n});\n\ntest('inflect.noRules',function(){\n expect(1);\n\n var inflector = new Ember.Inflector();\n\n equal(inflector.inflect('word', []),'word');\n});\n\ntest('inflect.uncountable', function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n plural: [\n [/$/,'s']\n ],\n uncountable: [\n 'word'\n ]\n });\n\n var rules = [];\n\n equal(inflector.inflect('word', rules), 'word');\n});\n\ntest('inflect.irregular', function(){\n expect(2);\n\n var inflector = new Ember.Inflector({\n irregularPairs: [\n ['word', 'wordy']\n ]\n });\n\n var rules = [];\n\n equal(inflector.inflect('word', rules, inflector.rules.irregular), 'wordy');\n equal(inflector.inflect('wordy', rules, inflector.rules.irregularInverse), 'word');\n});\n\ntest('inflect.basicRules', function(){\n expect(1);\n\n var inflector = new Ember.Inflector();\n var rules = [[/$/, 's']];\n\n equal(inflector.inflect('word', rules ), 'words');\n});\n\ntest('inflect.advancedRules', function(){\n expect(1);\n\n var inflector = new Ember.Inflector();\n var rules = [[/^(ox)$/i, '$1en']];\n\n equal(inflector.inflect('ox', rules), 'oxen');\n});\n\n})();\n//@ sourceURL=ember-inflector/~tests/system/inflector_test");minispade.register('ember-inflector/~tests/system/integration_test', "(function() {module(\"ember-inflector.integration\");\n\ntest(\"pluralize\", function(){\n expect(3);\n\n equal(Ember.String.pluralize('word'), 'words');\n equal(Ember.String.pluralize('ox'), 'oxen');\n equal(Ember.String.pluralize('octopus'), 'octopi');\n});\n\ntest(\"singularize\", function(){\n expect(3);\n\n equal(Ember.String.singularize('words'), 'word');\n equal(Ember.String.singularize('oxen'), 'ox');\n equal(Ember.String.singularize('octopi'), 'octopus');\n});\n\n})();\n//@ sourceURL=ember-inflector/~tests/system/integration_test");
76
+ minispade.register('activemodel-adapter/~tests/integration/active_model_adapter_test', "(function() {var env, store, adapter, SuperUser;\nvar originalAjax, passedUrl, passedVerb, passedHash;\nmodule(\"integration/active_model_adapter - AMS Adapter\", {\n setup: function() {\n SuperUser = DS.Model.extend();\n\n env = setupStore({\n superUser: SuperUser,\n adapter: DS.ActiveModelAdapter\n });\n\n store = env.store;\n adapter = env.adapter;\n\n passedUrl = passedVerb = passedHash = null;\n }\n});\n\ntest('buildURL - decamelizes names', function() {\n equal(adapter.buildURL('superUser', 1), \"/super_users/1\");\n});\n\ntest('ajaxError - returns invalid error if 422 response', function() {\n var error = new DS.InvalidError({ name: \"can't be blank\" });\n\n var jqXHR = {\n status: 422,\n responseText: JSON.stringify({ errors: { name: \"can't be blank\" } })\n };\n\n equal(adapter.ajaxError(jqXHR), error.toString());\n});\n\ntest('ajaxError - invalid error has camelized keys', function() {\n var error = new DS.InvalidError({ firstName: \"can't be blank\" });\n\n var jqXHR = {\n status: 422,\n responseText: JSON.stringify({ errors: { first_name: \"can't be blank\" } })\n };\n\n equal(adapter.ajaxError(jqXHR), error.toString());\n});\n\ntest('ajaxError - returns ajax response if not 422 response', function() {\n var jqXHR = {\n status: 500,\n responseText: \"Something went wrong\"\n };\n\n equal(adapter.ajaxError(jqXHR), jqXHR);\n});\n\n})();\n//@ sourceURL=activemodel-adapter/~tests/integration/active_model_adapter_test");minispade.register('activemodel-adapter/~tests/integration/active_model_serializer_test', "(function() {var get = Ember.get, set = Ember.set;\nvar HomePlanet, league, SuperVillain, superVillain, EvilMinion, YellowMinion, DoomsdayDevice, MediocreVillain, env;\n\nmodule(\"integration/active_model - ActiveModelSerializer\", {\n setup: function() {\n SuperVillain = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n homePlanet: DS.belongsTo(\"homePlanet\"),\n evilMinions: DS.hasMany(\"evilMinion\")\n });\n HomePlanet = DS.Model.extend({\n name: DS.attr('string'),\n superVillains: DS.hasMany('superVillain', {async: true})\n });\n EvilMinion = DS.Model.extend({\n superVillain: DS.belongsTo('superVillain'),\n name: DS.attr('string')\n });\n YellowMinion = EvilMinion.extend();\n DoomsdayDevice = DS.Model.extend({\n name: DS.attr('string'),\n evilMinion: DS.belongsTo('evilMinion', {polymorphic: true})\n });\n MediocreVillain = DS.Model.extend({\n name: DS.attr('string'),\n evilMinions: DS.hasMany('evilMinion', {polymorphic: true})\n });\n env = setupStore({\n superVillain: SuperVillain,\n homePlanet: HomePlanet,\n evilMinion: EvilMinion,\n yellowMinion: YellowMinion,\n doomsdayDevice: DoomsdayDevice,\n mediocreVillain: MediocreVillain\n });\n env.store.modelFor('superVillain');\n env.store.modelFor('homePlanet');\n env.store.modelFor('evilMinion');\n env.store.modelFor('yellowMinion');\n env.store.modelFor('doomsdayDevice');\n env.store.modelFor('mediocreVillain');\n env.container.register('serializer:application', DS.ActiveModelSerializer);\n env.container.register('serializer:ams', DS.ActiveModelSerializer);\n env.container.register('adapter:ams', DS.ActiveModelAdapter);\n env.amsSerializer = env.container.lookup(\"serializer:ams\");\n env.amsAdapter = env.container.lookup(\"adapter:ams\");\n },\n\n teardown: function() {\n env.store.destroy();\n }\n});\n\ntest(\"serialize\", function() {\n league = env.store.createRecord(HomePlanet, { name: \"Villain League\", id: \"123\" });\n var tom = env.store.createRecord(SuperVillain, { firstName: \"Tom\", lastName: \"Dale\", homePlanet: league });\n\n var json = env.amsSerializer.serialize(tom);\n\n deepEqual(json, {\n first_name: \"Tom\",\n last_name: \"Dale\",\n home_planet_id: get(league, \"id\")\n });\n});\n\ntest(\"serializeIntoHash\", function() {\n league = env.store.createRecord(HomePlanet, { name: \"Umber\", id: \"123\" });\n var json = {};\n\n env.amsSerializer.serializeIntoHash(json, HomePlanet, league);\n\n deepEqual(json, {\n home_planet: {\n name: \"Umber\"\n }\n });\n});\n\ntest(\"serializeIntoHash with decamelized types\", function() {\n HomePlanet.typeKey = 'home-planet';\n league = env.store.createRecord(HomePlanet, { name: \"Umber\", id: \"123\" });\n var json = {};\n\n env.amsSerializer.serializeIntoHash(json, HomePlanet, league);\n\n deepEqual(json, {\n home_planet: {\n name: \"Umber\"\n }\n });\n});\n\n\ntest(\"normalize\", function() {\n var superVillain_hash = {first_name: \"Tom\", last_name: \"Dale\", home_planet_id: \"123\", evil_minion_ids: [1,2]};\n\n var json = env.amsSerializer.normalize(SuperVillain, superVillain_hash, \"superVillain\");\n\n deepEqual(json, {\n firstName: \"Tom\",\n lastName: \"Dale\",\n homePlanet: \"123\",\n evilMinions: [1,2]\n });\n});\n\ntest(\"normalize links\", function() {\n var home_planet = {\n id: \"1\",\n name: \"Umber\",\n links: { super_villains: \"/api/super_villians/1\" }\n };\n\n\n var json = env.amsSerializer.normalize(HomePlanet, home_planet, \"homePlanet\");\n\n equal(json.links.superVillains, \"/api/super_villians/1\", \"normalize links\");\n});\n\ntest(\"extractSingle\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n\n var json_hash = {\n home_planet: {id: \"1\", name: \"Umber\", super_villain_ids: [1]},\n super_villains: [{\n id: \"1\",\n first_name: \"Tom\",\n last_name: \"Dale\",\n home_planet_id: \"1\"\n }]\n };\n\n var json = env.amsSerializer.extractSingle(env.store, HomePlanet, json_hash);\n\n deepEqual(json, {\n \"id\": \"1\",\n \"name\": \"Umber\",\n \"superVillains\": [1]\n });\n\n env.store.find(\"superVillain\", 1).then(async(function(minion){\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"extractArray\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n\n var json_hash = {\n home_planets: [{id: \"1\", name: \"Umber\", super_villain_ids: [1]}],\n super_villains: [{id: \"1\", first_name: \"Tom\", last_name: \"Dale\", home_planet_id: \"1\"}]\n };\n\n var array = env.amsSerializer.extractArray(env.store, HomePlanet, json_hash);\n\n deepEqual(array, [{\n \"id\": \"1\",\n \"name\": \"Umber\",\n \"superVillains\": [1]\n }]);\n\n env.store.find(\"superVillain\", 1).then(async(function(minion){\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"serialize polymorphic\", function() {\n var tom = env.store.createRecord(YellowMinion, {name: \"Alex\", id: \"124\"});\n var ray = env.store.createRecord(DoomsdayDevice, {evilMinion: tom, name: \"DeathRay\"});\n\n var json = env.amsSerializer.serialize(ray);\n\n deepEqual(json, {\n name: \"DeathRay\",\n evil_minion_type: \"YellowMinion\",\n evil_minion_id: \"124\"\n });\n});\n\ntest(\"serialize polymorphic when type key is not camelized\", function() {\n YellowMinion.typeKey = 'yellow-minion';\n var tom = env.store.createRecord(YellowMinion, {name: \"Alex\", id: \"124\"});\n var ray = env.store.createRecord(DoomsdayDevice, {evilMinion: tom, name: \"DeathRay\"});\n\n var json = env.amsSerializer.serialize(ray);\n\n deepEqual(json[\"evil_minion_type\"], \"YellowMinion\");\n});\n\ntest(\"extractPolymorphic hasMany\", function() {\n env.container.register('adapter:yellowMinion', DS.ActiveModelAdapter);\n MediocreVillain.toString = function() { return \"MediocreVillain\"; };\n YellowMinion.toString = function() { return \"YellowMinion\"; };\n\n var json_hash = {\n mediocre_villain: {id: 1, name: \"Dr Horrible\", evil_minions: [{ type: \"yellow_minion\", id: 12}] },\n evil_minions: [{id: 12, name: \"Alex\", doomsday_device_ids: [1] }]\n };\n\n var json = env.amsSerializer.extractSingle(env.store, MediocreVillain, json_hash);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"Dr Horrible\",\n \"evilMinions\": [{\n type: \"yellowMinion\",\n id: 12\n }]\n });\n});\n\ntest(\"extractPolymorphic\", function() {\n env.container.register('adapter:yellowMinion', DS.ActiveModelAdapter);\n EvilMinion.toString = function() { return \"EvilMinion\"; };\n YellowMinion.toString = function() { return \"YellowMinion\"; };\n\n var json_hash = {\n doomsday_device: {id: 1, name: \"DeathRay\", evil_minion: { type: \"yellow_minion\", id: 12}},\n evil_minions: [{id: 12, name: \"Alex\", doomsday_device_ids: [1] }]\n };\n\n var json = env.amsSerializer.extractSingle(env.store, DoomsdayDevice, json_hash);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"DeathRay\",\n \"evilMinion\": {\n type: \"yellowMinion\",\n id: 12\n }\n });\n});\n\ntest(\"extractPolymorphic when the related data is not specified\", function() {\n var json = {\n doomsday_device: {id: 1, name: \"DeathRay\"},\n evil_minions: [{id: 12, name: \"Alex\", doomsday_device_ids: [1] }]\n };\n\n json = env.amsSerializer.extractSingle(env.store, DoomsdayDevice, json);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"DeathRay\",\n \"evilMinion\": undefined\n });\n});\n\ntest(\"extractPolymorphic hasMany when the related data is not specified\", function() {\n var json = {\n mediocre_villain: {id: 1, name: \"Dr Horrible\"}\n };\n\n json = env.amsSerializer.extractSingle(env.store, MediocreVillain, json);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"Dr Horrible\",\n \"evilMinions\": undefined\n });\n});\n\ntest(\"extractPolymorphic does not break hasMany relationships\", function() {\n var json = {\n mediocre_villain: {id: 1, name: \"Dr. Evil\", evil_minions: []}\n };\n\n json = env.amsSerializer.extractSingle(env.store, MediocreVillain, json);\n\n deepEqual(json, {\n \"id\": 1,\n \"name\": \"Dr. Evil\",\n \"evilMinions\": []\n });\n});\n\n})();\n//@ sourceURL=activemodel-adapter/~tests/integration/active_model_serializer_test");minispade.register('activemodel-adapter/~tests/integration/embedded_records_mixin_test', "(function() {var get = Ember.get, set = Ember.set;\nvar HomePlanet, league, SuperVillain, superVillain, EvilMinion, Comment, env;\n\nmodule(\"integration/embedded_records_mixin - EmbeddedRecordsMixin\", {\n setup: function() {\n SuperVillain = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n homePlanet: DS.belongsTo(\"homePlanet\"),\n evilMinions: DS.hasMany(\"evilMinion\")\n });\n HomePlanet = DS.Model.extend({\n name: DS.attr('string'),\n villains: DS.hasMany('superVillain')\n });\n EvilMinion = DS.Model.extend({\n superVillain: DS.belongsTo('superVillain'),\n name: DS.attr('string')\n });\n Comment = DS.Model.extend({\n body: DS.attr('string'),\n root: DS.attr('boolean'),\n children: DS.hasMany('comment')\n });\n env = setupStore({\n superVillain: SuperVillain,\n homePlanet: HomePlanet,\n evilMinion: EvilMinion,\n comment: Comment\n });\n env.store.modelFor('superVillain');\n env.store.modelFor('homePlanet');\n env.store.modelFor('evilMinion');\n env.store.modelFor('comment');\n env.container.register('serializer:application', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin));\n env.container.register('serializer:ams', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin));\n env.container.register('adapter:ams', DS.ActiveModelAdapter);\n env.amsSerializer = env.container.lookup(\"serializer:ams\");\n env.amsAdapter = env.container.lookup(\"adapter:ams\");\n },\n\n teardown: function() {\n env.store.destroy();\n }\n});\n\ntest(\"extractSingle with embedded objects\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n var json_hash = {\n home_planet: {\n id: \"1\",\n name: \"Umber\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\",\n last_name: \"Dale\"\n }]\n }\n };\n\n var json = serializer.extractSingle(env.store, HomePlanet, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n name: \"Umber\",\n villains: [\"1\"]\n });\n env.store.find(\"superVillain\", 1).then(async(function(minion) {\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"extractSingle with embedded objects inside embedded objects\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'}\n }\n }));\n env.container.register('serializer:superVillain', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n evilMinions: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n var json_hash = {\n home_planet: {\n id: \"1\",\n name: \"Umber\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\",\n last_name: \"Dale\",\n evil_minions: [{\n id: \"1\",\n name: \"Alex\"\n }]\n }]\n }\n };\n\n var json = serializer.extractSingle(env.store, HomePlanet, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n name: \"Umber\",\n villains: [\"1\"]\n });\n env.store.find(\"superVillain\", 1).then(async(function(villain) {\n equal(villain.get('firstName'), \"Tom\");\n equal(villain.get('evilMinions.length'), 1, \"Should load the embedded child\");\n equal(villain.get('evilMinions.firstObject.name'), \"Alex\", \"Should load the embedded child\");\n }));\n env.store.find(\"evilMinion\", 1).then(async(function(minion) {\n equal(minion.get('name'), \"Alex\");\n }));\n});\n\ntest(\"extractSingle with embedded objects of same type\", function() {\n env.container.register('adapter:comment', DS.ActiveModelAdapter);\n env.container.register('serializer:comment', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n children: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:comment\");\n var json_hash = {\n comment: {\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [{\n id: \"2\",\n body: \"World\",\n root: false\n },\n {\n id: \"3\",\n body: \"Foo\",\n root: false\n }]\n }\n };\n var json = serializer.extractSingle(env.store, Comment, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [\"2\", \"3\"]\n }, \"Primary record was correct\");\n equal(env.store.recordForId(\"comment\", \"2\").get(\"body\"), \"World\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"comment\", \"3\").get(\"body\"), \"Foo\", \"Secondary records found in the store\");\n});\n\ntest(\"extractSingle with embedded objects inside embedded objects of same type\", function() {\n env.container.register('adapter:comment', DS.ActiveModelAdapter);\n env.container.register('serializer:comment', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n children: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:comment\");\n var json_hash = {\n comment: {\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [{\n id: \"2\",\n body: \"World\",\n root: false,\n children: [{\n id: \"4\",\n body: \"Another\",\n root: false\n }]\n },\n {\n id: \"3\",\n body: \"Foo\",\n root: false\n }]\n }\n };\n var json = serializer.extractSingle(env.store, Comment, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [\"2\", \"3\"]\n }, \"Primary record was correct\");\n equal(env.store.recordForId(\"comment\", \"2\").get(\"body\"), \"World\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"comment\", \"3\").get(\"body\"), \"Foo\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"comment\", \"4\").get(\"body\"), \"Another\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"comment\", \"2\").get(\"children.length\"), 1, \"Should have one embedded record\");\n equal(env.store.recordForId(\"comment\", \"2\").get(\"children.firstObject.body\"), \"Another\", \"Should have one embedded record\");\n});\n\ntest(\"extractSingle with embedded objects of same type, but from separate attributes\", function() {\n HomePlanet.reopen({\n reformedVillains: DS.hasMany('superVillain')\n });\n\n env.container.register('adapter:home_planet', DS.ActiveModelAdapter);\n env.container.register('serializer:home_planet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'},\n reformedVillains: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:home_planet\");\n var json_hash = {\n home_planet: {\n id: \"1\",\n name: \"Earth\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\"\n }, {\n id: \"3\",\n first_name: \"Yehuda\"\n }],\n reformed_villains: [{\n id: \"2\",\n first_name: \"Alex\"\n },{\n id: \"4\",\n first_name: \"Erik\"\n }]\n }\n };\n var json = serializer.extractSingle(env.store, HomePlanet, json_hash);\n\n deepEqual(json, {\n id: \"1\",\n name: \"Earth\",\n villains: [\"1\", \"3\"],\n reformedVillains: [\"2\", \"4\"]\n }, \"Primary array was correct\");\n\n equal(env.store.recordForId(\"superVillain\", \"1\").get(\"firstName\"), \"Tom\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"2\").get(\"firstName\"), \"Alex\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"3\").get(\"firstName\"), \"Yehuda\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"4\").get(\"firstName\"), \"Erik\", \"Secondary records found in the store\");\n});\n\ntest(\"extractArray with embedded objects\", function() {\n env.container.register('adapter:superVillain', DS.ActiveModelAdapter);\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n\n var json_hash = {\n home_planets: [{\n id: \"1\",\n name: \"Umber\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\",\n last_name: \"Dale\"\n }]\n }]\n };\n\n var array = serializer.extractArray(env.store, HomePlanet, json_hash);\n\n deepEqual(array, [{\n id: \"1\",\n name: \"Umber\",\n villains: [\"1\"]\n }]);\n\n env.store.find(\"superVillain\", 1).then(async(function(minion){\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"extractArray with embedded objects of same type as primary type\", function() {\n env.container.register('adapter:comment', DS.ActiveModelAdapter);\n env.container.register('serializer:comment', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n children: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:comment\");\n\n var json_hash = {\n comments: [{\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [{\n id: \"2\",\n body: \"World\",\n root: false\n },\n {\n id: \"3\",\n body: \"Foo\",\n root: false\n }]\n }]\n };\n\n var array = serializer.extractArray(env.store, Comment, json_hash);\n\n deepEqual(array, [{\n id: \"1\",\n body: \"Hello\",\n root: true,\n children: [\"2\", \"3\"]\n }], \"Primary array is correct\");\n\n equal(env.store.recordForId(\"comment\", \"2\").get(\"body\"), \"World\", \"Secondary record found in the store\");\n equal(env.store.recordForId(\"comment\", \"3\").get(\"body\"), \"Foo\", \"Secondary record found in the store\");\n});\n\ntest(\"extractArray with embedded objects of same type, but from separate attributes\", function() {\n HomePlanet.reopen({\n reformedVillains: DS.hasMany('superVillain')\n });\n\n env.container.register('adapter:homePlanet', DS.ActiveModelAdapter);\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'},\n reformedVillains: {embedded: 'always'}\n }\n }));\n\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n var json_hash = {\n home_planets: [{\n id: \"1\",\n name: \"Earth\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\"\n },{\n id: \"3\",\n first_name: \"Yehuda\"\n }],\n reformed_villains: [{\n id: \"2\",\n first_name: \"Alex\"\n },{\n id: \"4\",\n first_name: \"Erik\"\n }]\n },{\n id: \"2\",\n name: \"Mars\",\n villains: [{\n id: \"1\",\n first_name: \"Tom\"\n },{\n id: \"3\",\n first_name: \"Yehuda\"\n }],\n reformed_villains: [{\n id: \"5\",\n first_name: \"Peter\"\n },{\n id: \"6\",\n first_name: \"Trek\"\n }]\n }]\n };\n var json = serializer.extractArray(env.store, HomePlanet, json_hash);\n\n deepEqual(json, [{\n id: \"1\",\n name: \"Earth\",\n villains: [\"1\", \"3\"],\n reformedVillains: [\"2\", \"4\"]\n },{\n id: \"2\",\n name: \"Mars\",\n villains: [\"1\", \"3\"],\n reformedVillains: [\"5\", \"6\"]\n }], \"Primary array was correct\");\n\n equal(env.store.recordForId(\"superVillain\", \"1\").get(\"firstName\"), \"Tom\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"2\").get(\"firstName\"), \"Alex\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"3\").get(\"firstName\"), \"Yehuda\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"4\").get(\"firstName\"), \"Erik\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"5\").get(\"firstName\"), \"Peter\", \"Secondary records found in the store\");\n equal(env.store.recordForId(\"superVillain\", \"6\").get(\"firstName\"), \"Trek\", \"Secondary records found in the store\");\n});\n\ntest(\"serialize with embedded objects\", function() {\n league = env.store.createRecord(HomePlanet, { name: \"Villain League\", id: \"123\" });\n var tom = env.store.createRecord(SuperVillain, { firstName: \"Tom\", lastName: \"Dale\", homePlanet: league });\n\n env.container.register('serializer:homePlanet', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {\n attrs: {\n villains: {embedded: 'always'}\n }\n }));\n var serializer = env.container.lookup(\"serializer:homePlanet\");\n\n var json = serializer.serialize(league);\n\n deepEqual(json, {\n name: \"Villain League\",\n villains: [{\n id: get(tom, \"id\"),\n first_name: \"Tom\",\n last_name: \"Dale\",\n home_planet_id: get(league, \"id\")\n }]\n });\n});\n})();\n//@ sourceURL=activemodel-adapter/~tests/integration/embedded_records_mixin_test");minispade.register('activemodel-adapter/~tests/unit/adapter/path_for_type_test', "(function() {var env, store, adapter;\nmodule(\"unit/adapter/path_for_type - DS.ActiveModelAdapter#pathForType\", {\n setup: function() {\n env = setupStore({\n adapter: DS.ActiveModelAdapter\n });\n\n adapter = env.adapter;\n }\n});\n\ntest('pathForType - works with camelized types', function() {\n equal(adapter.pathForType('superUser'), \"super_users\");\n});\n\ntest('pathForType - works with dasherized types', function() {\n equal(adapter.pathForType('super-user'), \"super_users\");\n});\n\ntest('pathForType - works with underscored types', function() {\n equal(adapter.pathForType('super_user'), \"super_users\");\n});\n\n})();\n//@ sourceURL=activemodel-adapter/~tests/unit/adapter/path_for_type_test");minispade.register('ember-data/~tests/integration/adapter/find_all_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar Person, adapter, store, allRecords;\n\nmodule(\"integration/adapter/find_all - Finding All Records of a Type\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: DS.attr('string'),\n name: DS.attr('string'),\n firstName: DS.attr('string'),\n lastName: DS.attr('string')\n });\n\n allRecords = null;\n },\n\n teardown: function() {\n if (allRecords) { allRecords.destroy(); }\n store.destroy();\n }\n});\n\ntest(\"When all records for a type are requested, the store should call the adapter's `findAll` method.\", function() {\n expect(5);\n\n store = createStore({ adapter: DS.Adapter.extend({\n findAll: function(store, type, since) {\n // this will get called twice\n ok(true, \"the adapter's findAll method should be invoked\");\n\n return Ember.RSVP.resolve([{ id: 1, name: \"Braaaahm Dale\" }]);\n }\n })\n });\n\n var allRecords;\n\n store.find(Person).then(async(function(all) {\n allRecords = all;\n equal(get(all, 'length'), 1, \"the record array's length is 1 after a record is loaded into it\");\n equal(all.objectAt(0).get('name'), \"Braaaahm Dale\", \"the first item in the record array is Braaaahm Dale\");\n }));\n\n store.find(Person).then(async(function(all) {\n // Only one record array per type should ever be created (identity map)\n strictEqual(allRecords, all, \"the same record array is returned every time all records of a type are requested\");\n }));\n});\n\ntest(\"When all records for a type are requested, a rejection should reject the promise\", function() {\n expect(5);\n\n var count = 0;\n store = createStore({ adapter: DS.Adapter.extend({\n findAll: function(store, type, since) {\n // this will get called twice\n ok(true, \"the adapter's findAll method should be invoked\");\n\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve([{ id: 1, name: \"Braaaahm Dale\" }]);\n }\n }\n })\n });\n\n var allRecords;\n\n store.find(Person).then(null, async(function() {\n ok(true, \"The rejection should get here\");\n return store.find(Person);\n })).then(async(function(all) {\n allRecords = all;\n equal(get(all, 'length'), 1, \"the record array's length is 1 after a record is loaded into it\");\n equal(all.objectAt(0).get('name'), \"Braaaahm Dale\", \"the first item in the record array is Braaaahm Dale\");\n }));\n});\n\ntest(\"When all records for a type are requested, records that are already loaded should be returned immediately.\", function() {\n expect(3);\n\n // Load a record from the server\n store.push(Person, { id: 1, name: \"Jeremy Ashkenas\" });\n\n // Create a new, unsaved record in the store\n store.createRecord(Person, { name: \"Alex MacCaw\" });\n\n allRecords = store.all(Person);\n\n equal(get(allRecords, 'length'), 2, \"the record array's length is 2\");\n equal(allRecords.objectAt(0).get('name'), \"Jeremy Ashkenas\", \"the first item in the record array is Jeremy Ashkenas\");\n equal(allRecords.objectAt(1).get('name'), \"Alex MacCaw\", \"the second item in the record array is Alex MacCaw\");\n});\n\ntest(\"When all records for a type are requested, records that are created on the client should be added to the record array.\", function() {\n expect(3);\n\n allRecords = store.all(Person);\n\n equal(get(allRecords, 'length'), 0, \"precond - the record array's length is zero before any records are loaded\");\n\n store.createRecord(Person, { name: \"Carsten Nielsen\" });\n\n equal(get(allRecords, 'length'), 1, \"the record array's length is 1\");\n equal(allRecords.objectAt(0).get('name'), \"Carsten Nielsen\", \"the first item in the record array is Carsten Nielsen\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/find_all_test");minispade.register('ember-data/~tests/integration/adapter/find_test', "(function() {var get = Ember.get, set = Ember.set;\nvar Person, store, adapter;\n\nmodule(\"integration/adapter/find - Finding Records\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: DS.attr('string'),\n name: DS.attr('string'),\n firstName: DS.attr('string'),\n lastName: DS.attr('string')\n });\n },\n\n teardown: function() {\n store.destroy();\n }\n});\n\ntest(\"When a single record is requested, the adapter's find method should be called unless it's loaded.\", function() {\n expect(2);\n\n var count = 0;\n\n store = createStore({ adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n equal(type, Person, \"the find method is called with the correct type\");\n equal(count, 0, \"the find method is only called once\");\n\n count++;\n return { id: 1, name: \"Braaaahm Dale\" };\n }\n })\n });\n\n store.find(Person, 1);\n store.find(Person, 1);\n});\n\ntest(\"When a single record is requested multiple times, all .find() calls are resolved after the promise is resolved\", function() {\n var deferred = Ember.RSVP.defer();\n\n store = createStore({ adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n return deferred.promise;\n }\n })\n });\n\n store.find(Person, 1).then(async(function(person) {\n equal(person.get('id'), \"1\");\n equal(person.get('name'), \"Braaaahm Dale\");\n\n stop();\n deferred.promise.then(function(value){\n start();\n ok(true, 'expected deferred.promise to fulfill');\n },function(reason){\n start();\n ok(false, 'expected deferred.promise to fulfill, but rejected');\n });\n }));\n\n store.find(Person, 1).then(async(function(post) {\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Braaaahm Dale\");\n\n stop();\n deferred.promise.then(function(value){\n start();\n ok(true, 'expected deferred.promise to fulfill');\n }, function(reason){\n start();\n ok(false, 'expected deferred.promise to fulfill, but rejected');\n });\n\n }));\n\n Ember.run(function() {\n deferred.resolve({ id: 1, name: \"Braaaahm Dale\" });\n });\n});\n\ntest(\"When a single record is requested, and the promise is rejected, .find() is rejected.\", function() {\n var count = 0;\n\n store = createStore({ adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.reject();\n }\n })\n });\n\n store.find(Person, 1).then(null, async(function(reason) {\n ok(true, \"The rejection handler was called\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/find_test");minispade.register('ember-data/~tests/integration/adapter/fixture_adapter_test', "(function() {var get = Ember.get, set = Ember.set;\nvar env, Person, Phone, App;\n\nmodule(\"integration/adapter/fixture_adapter - DS.FixtureAdapter\", {\n setup: function() {\n Person = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n\n height: DS.attr('number'),\n\n phones: DS.hasMany('phone', { async: true })\n });\n\n Phone = DS.Model.extend({\n person: DS.belongsTo('person')\n });\n\n env = setupStore({ person: Person, phone: Phone, adapter: DS.FixtureAdapter });\n env.adapter.simulateRemoteResponse = true;\n\n // Enable setTimeout.\n Ember.testing = false;\n\n Person.FIXTURES = [];\n Phone.FIXTURES = [];\n },\n teardown: function() {\n Ember.testing = true;\n\n env.container.destroy();\n }\n});\n\ntest(\"should load data for a type asynchronously when it is requested\", function() {\n Person.FIXTURES = [{\n id: 'wycats',\n firstName: \"Yehuda\",\n lastName: \"Katz\",\n\n height: 65\n },\n\n {\n id: 'ebryn',\n firstName: \"Erik\",\n lastName: \"Brynjolffsosysdfon\",\n\n height: 70,\n phones: [1, 2]\n }];\n\n Phone.FIXTURES = [{\n id: 1,\n person: 'ebryn'\n }, {\n id: 2,\n person: 'ebryn'\n }];\n\n env.store.find('person', 'ebryn').then(async(function(ebryn) {\n equal(get(ebryn, 'isLoaded'), true, \"data loads asynchronously\");\n equal(get(ebryn, 'height'), 70, \"data from fixtures is loaded correctly\");\n\n return Ember.RSVP.hash({ ebryn: ebryn, wycats: env.store.find('person', 'wycats') });\n }, 1000)).then(async(function(records) {\n equal(get(records.wycats, 'isLoaded'), true, \"subsequent requests for records are returned asynchronously\");\n equal(get(records.wycats, 'height'), 65, \"subsequent requested records contain correct information\");\n\n return get(records.ebryn, 'phones');\n }, 1000)).then(async(function(phones) {\n equal(get(phones, 'length'), 2, \"relationships from fixtures is loaded correctly\");\n }, 1000));\n});\n\ntest(\"should load data asynchronously at the end of the runloop when simulateRemoteResponse is false\", function() {\n Person.FIXTURES = [{\n id: 'wycats',\n firstName: \"Yehuda\"\n }];\n\n env.adapter.simulateRemoteResponse = false;\n\n var wycats;\n\n Ember.run(function() {\n env.store.find('person', 'wycats').then(function(person) {\n wycats = person;\n });\n });\n\n ok(get(wycats, 'isLoaded'), 'isLoaded is true after runloop finishes');\n equal(get(wycats, 'firstName'), 'Yehuda', 'record properties are defined after runloop finishes');\n});\n\ntest(\"should create record asynchronously when it is committed\", function() {\n equal(Person.FIXTURES.length, 0, \"Fixtures is empty\");\n\n var paul = env.store.createRecord('person', {firstName: 'Paul', lastName: 'Chavard', height: 70});\n\n paul.on('didCreate', async(function() {\n equal(get(paul, 'isNew'), false, \"data loads asynchronously\");\n equal(get(paul, 'isDirty'), false, \"data loads asynchronously\");\n equal(get(paul, 'height'), 70, \"data from fixtures is saved correctly\");\n\n equal(Person.FIXTURES.length, 1, \"Record added to FIXTURES\");\n\n var fixture = Person.FIXTURES[0];\n\n ok(typeof fixture.id === 'string', \"The fixture has an ID generated for it\");\n equal(fixture.firstName, 'Paul');\n equal(fixture.lastName, 'Chavard');\n equal(fixture.height, 70);\n }));\n\n paul.save();\n});\n\ntest(\"should update record asynchronously when it is committed\", function() {\n equal(Person.FIXTURES.length, 0, \"Fixtures is empty\");\n\n var paul = env.store.push('person', { id: 1, firstName: 'Paul', lastName: 'Chavard', height: 70});\n\n paul.set('height', 80);\n\n paul.on('didUpdate', async(function() {\n equal(get(paul, 'isDirty'), false, \"data loads asynchronously\");\n equal(get(paul, 'height'), 80, \"data from fixtures is saved correctly\");\n\n equal(Person.FIXTURES.length, 1, \"Record FIXTURES updated\");\n\n var fixture = Person.FIXTURES[0];\n\n equal(fixture.firstName, 'Paul');\n equal(fixture.lastName, 'Chavard');\n equal(fixture.height, 80);\n }, 1000));\n\n paul.save();\n});\n\ntest(\"should delete record asynchronously when it is committed\", function() {\n stop();\n\n var timer = setTimeout(function() {\n start();\n ok(false, \"timeout exceeded waiting for fixture data\");\n }, 1000);\n\n equal(Person.FIXTURES.length, 0, \"Fixtures empty\");\n\n var paul = env.store.push('person', { id: 'paul', firstName: 'Paul', lastName: 'Chavard', height: 70 });\n\n paul.deleteRecord();\n\n paul.on('didDelete', function() {\n clearTimeout(timer);\n start();\n\n equal(get(paul, 'isDeleted'), true, \"data deleted asynchronously\");\n equal(get(paul, 'isDirty'), false, \"data deleted asynchronously\");\n\n equal(Person.FIXTURES.length, 0, \"Record removed from FIXTURES\");\n });\n\n paul.save();\n});\n\ntest(\"should follow isUpdating semantics\", function() {\n var timer = setTimeout(function() {\n start();\n ok(false, \"timeout exceeded waiting for fixture data\");\n }, 1000);\n\n stop();\n\n Person.FIXTURES = [{\n id: \"twinturbo\",\n firstName: \"Adam\",\n lastName: \"Hawkins\",\n height: 65\n }];\n\n var result = env.store.findAll('person');\n\n result.then(function(all) {\n clearTimeout(timer);\n start();\n equal(get(all, 'isUpdating'), false, \"isUpdating is set when it shouldn't be\");\n });\n});\n\ntest(\"should coerce integer ids into string\", function() {\n Person.FIXTURES = [{\n id: 1,\n firstName: \"Adam\",\n lastName: \"Hawkins\",\n height: 65\n }];\n\n env.store.find('person', 1).then(async(function(result) {\n strictEqual(get(result, 'id'), \"1\", \"should load integer model id as string\");\n }));\n});\n\ntest(\"should coerce belongsTo ids into string\", function() {\n Person.FIXTURES = [{\n id: 1,\n firstName: \"Adam\",\n lastName: \"Hawkins\",\n\n phones: [1]\n }];\n\n Phone.FIXTURES = [{\n id: 1,\n person: 1\n }];\n\n env.store.find('phone', 1).then(async(function(result) {\n var person = get(result, 'person');\n person.one('didLoad', async(function() {\n strictEqual(get(result, 'person.id'), \"1\", \"should load integer belongsTo id as string\");\n strictEqual(get(result, 'person.firstName'), \"Adam\", \"resolved relationship with an integer belongsTo id\");\n }));\n }));\n});\n\ntest(\"only coerce belongsTo ids to string if id is defined and not null\", function() {\n Person.FIXTURES = [];\n\n Phone.FIXTURES = [{\n id: 1\n }];\n\n env.store.find('phone', 1).then(async(function(phone) {\n equal(phone.get('person'), null);\n }));\n});\n\ntest(\"should throw if ids are not defined in the FIXTURES\", function() {\n Person.FIXTURES = [{\n firstName: \"Adam\",\n lastName: \"Hawkins\",\n height: 65\n }];\n\n raises(function(){\n env.store.find('person', 1);\n }, /the id property must be defined as a number or string for fixture/);\n\n Person.FIXTURES = [{\n id: 0\n }];\n\n env.store.find('person', 0).then(async(function() {\n ok(true, \"0 is an acceptable ID, so no exception was thrown\");\n }), function() {\n ok(false, \"should not get here\");\n });\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/fixture_adapter_test");minispade.register('ember-data/~tests/integration/adapter/queries_test', "(function() {var get = Ember.get, set = Ember.set;\nvar Person, env, store, adapter;\n\nmodule(\"integration/adapter/queries - Queries\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: DS.attr('string'),\n name: DS.attr('string'),\n firstName: DS.attr('string'),\n lastName: DS.attr('string')\n });\n\n env = setupStore({ person: Person });\n store = env.store;\n adapter = env.adapter;\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"When a query is made, the adapter should receive a record array it can populate with the results of the query.\", function() {\n adapter.findQuery = function(store, type, query, recordArray) {\n equal(type, Person, \"the find method is called with the correct type\");\n\n return Ember.RSVP.resolve([{ id: 1, name: \"Peter Wagenet\" }, { id: 2, name: \"Brohuda Katz\" }]);\n };\n\n store.find('person', { page: 1 }).then(async(function(queryResults) {\n equal(get(queryResults, 'length'), 2, \"the record array has a length of 2 after the results are loaded\");\n equal(get(queryResults, 'isLoaded'), true, \"the record array's `isLoaded` property should be true\");\n\n equal(queryResults.objectAt(0).get('name'), \"Peter Wagenet\", \"the first record is 'Peter Wagenet'\");\n equal(queryResults.objectAt(1).get('name'), \"Brohuda Katz\", \"the second record is 'Brohuda Katz'\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/queries_test");minispade.register('ember-data/~tests/integration/adapter/record_persistence_test', "(function() {var get = Ember.get, set = Ember.set, attr = DS.attr;\nvar Person, env, store;\n\nvar all = Ember.RSVP.all, hash = Ember.RSVP.hash, resolve = Ember.RSVP.resolve;\n\nfunction assertClean(promise) {\n return promise.then(async(function(record) {\n equal(record.get('isDirty'), false, \"The record is now clean\");\n return record;\n }));\n}\n\n\nmodule(\"integration/adapter/record_persistence - Persisting Records\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: attr('string'),\n name: attr('string'),\n firstName: attr('string'),\n lastName: attr('string')\n });\n Person.toString = function() { return \"Person\"; };\n\n env = setupStore({ person: Person });\n store = env.store;\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"When a store is committed, the adapter's `commit` method should be called with records that have been changed.\", function() {\n expect(2);\n\n env.adapter.updateRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n equal(record, tom, \"the record is correct\");\n\n return Ember.RSVP.resolve();\n };\n\n env.store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n\n var tom;\n\n env.store.find('person', 1).then(async(function(person) {\n tom = person;\n set(tom, \"name\", \"Tom Dale\");\n tom.save();\n }));\n});\n\ntest(\"When a store is committed, the adapter's `commit` method should be called with records that have been created.\", function() {\n expect(2);\n\n env.adapter.createRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n equal(record, tom, \"the record is correct\");\n\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\" });\n };\n\n var tom = env.store.createRecord('person', { name: \"Tom Dale\" });\n tom.save();\n});\n\ntest(\"After a created record has been assigned an ID, finding a record by that ID returns the original record.\", function() {\n expect(1);\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\" });\n };\n\n var tom = env.store.createRecord('person', { name: \"Tom Dale\" });\n tom.save();\n\n asyncEqual(tom, env.store.find('person', 1), \"the retrieved record is the same as the created record\");\n});\n\ntest(\"when a store is committed, the adapter's `commit` method should be called with records that have been deleted.\", function() {\n env.adapter.deleteRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n equal(record, tom, \"the record is correct\");\n\n return Ember.RSVP.resolve();\n };\n\n var tom;\n\n env.store.push('person', { id: 1, name: \"Tom Dale\" });\n env.store.find('person', 1).then(async(function(person) {\n tom = person;\n tom.deleteRecord();\n return tom.save();\n })).then(async(function(tom) {\n equal(get(tom, 'isDeleted'), true, \"record is marked as deleted\");\n }));\n});\n\ntest(\"An adapter can notify the store that records were updated by calling `didSaveRecords`.\", function() {\n expect(6);\n\n var tom, yehuda;\n\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n env.store.push('person', { id: 1 });\n env.store.push('person', { id: 2 });\n\n all([ env.store.find('person', 1), env.store.find('person', 2) ])\n .then(async(function(array) {\n tom = array[0];\n yehuda = array[1];\n\n tom.set('name', \"Michael Phelps\");\n yehuda.set('name', \"Usain Bolt\");\n\n ok(tom.get('isDirty'), \"tom is dirty\");\n ok(yehuda.get('isDirty'), \"yehuda is dirty\");\n\n assertClean(tom.save()).then(async(function(record) {\n equal(record, tom, \"The record is correct\");\n }));\n\n assertClean(yehuda.save()).then(async(function(record) {\n equal(record, yehuda, \"The record is correct\");\n }));\n }));\n});\n\ntest(\"An adapter can notify the store that records were updated and provide new data by calling `didSaveRecords`.\", function() {\n var tom, yehuda;\n\n env.adapter.updateRecord = function(store, type, record) {\n if (record.get('id') === \"1\") {\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", updatedAt: \"now\" });\n } else if (record.get('id') === \"2\") {\n return Ember.RSVP.resolve({ id: 2, name: \"Yehuda Katz\", updatedAt: \"now!\" });\n }\n };\n\n env.store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n env.store.push('person', { id: 2, name: \"Gentile Katz\" });\n\n hash({ tom: env.store.find('person', 1), yehuda: env.store.find('person', 2) }).then(async(function(people) {\n people.tom.set('name', \"Draaaaaahm Dale\");\n people.yehuda.set('name', \"Goy Katz\");\n\n return hash({ tom: people.tom.save(), yehuda: people.yehuda.save() });\n })).then(async(function(people) {\n equal(people.tom.get('name'), \"Tom Dale\", \"name attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.tom.get('updatedAt'), \"now\", \"updatedAt attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.yehuda.get('name'), \"Yehuda Katz\", \"name attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.yehuda.get('updatedAt'), \"now!\", \"updatedAt attribute should reflect value of hash passed to didSaveRecords\");\n }));\n});\n\ntest(\"An adapter can notify the store that a record was updated by calling `didSaveRecord`.\", function() {\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n store.push('person', { id: 1 });\n store.push('person', { id: 2 });\n\n hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(people) {\n people.tom.set('name', \"Tom Dale\");\n people.yehuda.set('name', \"Yehuda Katz\");\n\n ok(people.tom.get('isDirty'), \"tom is dirty\");\n ok(people.yehuda.get('isDirty'), \"yehuda is dirty\");\n\n assertClean(people.tom.save());\n assertClean(people.yehuda.save());\n }));\n\n});\n\ntest(\"An adapter can notify the store that a record was updated and provide new data by calling `didSaveRecord`.\", function() {\n env.adapter.updateRecord = function(store, type, record) {\n switch (record.get('id')) {\n case \"1\":\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", updatedAt: \"now\" });\n case \"2\":\n return Ember.RSVP.resolve({ id: 2, name: \"Yehuda Katz\", updatedAt: \"now!\" });\n }\n };\n\n env.store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n env.store.push('person', { id: 2, name: \"Gentile Katz\" });\n\n\n hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(people) {\n people.tom.set('name', \"Draaaaaahm Dale\");\n people.yehuda.set('name', \"Goy Katz\");\n\n return hash({ tom: people.tom.save(), yehuda: people.yehuda.save() });\n })).then(async(function(people) {\n equal(people.tom.get('name'), \"Tom Dale\", \"name attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.tom.get('updatedAt'), \"now\", \"updatedAt attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.yehuda.get('name'), \"Yehuda Katz\", \"name attribute should reflect value of hash passed to didSaveRecords\");\n equal(people.yehuda.get('updatedAt'), \"now!\", \"updatedAt attribute should reflect value of hash passed to didSaveRecords\");\n }));\n\n});\n\ntest(\"An adapter can notify the store that records were deleted by calling `didSaveRecords`.\", function() {\n env.adapter.deleteRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n env.store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n env.store.push('person', { id: 2, name: \"Gentile Katz\" });\n\n hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(people) {\n people.tom.deleteRecord();\n people.yehuda.deleteRecord();\n\n assertClean(people.tom.save());\n assertClean(people.yehuda.save());\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/record_persistence_test");minispade.register('ember-data/~tests/integration/adapter/rest_adapter_test', "(function() {var env, store, adapter, Post, Person, Comment, SuperUser;\nvar originalAjax, passedUrl, passedVerb, passedHash;\n\nmodule(\"integration/adapter/rest_adapter - REST Adapter\", {\n setup: function() {\n Post = DS.Model.extend({\n name: DS.attr(\"string\")\n });\n\n Post.toString = function() {\n return \"Post\";\n };\n\n Comment = DS.Model.extend({\n name: DS.attr(\"string\")\n });\n\n SuperUser = DS.Model.extend();\n\n env = setupStore({\n post: Post,\n comment: Comment,\n superUser: SuperUser,\n adapter: DS.RESTAdapter\n });\n\n store = env.store;\n adapter = env.adapter;\n\n passedUrl = passedVerb = passedHash = null;\n }\n});\n\nfunction ajaxResponse(value) {\n adapter.ajax = function(url, verb, hash) {\n passedUrl = url;\n passedVerb = verb;\n passedHash = hash;\n\n return Ember.RSVP.resolve(value);\n };\n}\n\ntest(\"find - basic payload\", function() {\n ajaxResponse({ posts: [{ id: 1, name: \"Rails is omakase\" }] });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n }));\n});\n\ntest(\"find - basic payload (with legacy singular name)\", function() {\n ajaxResponse({ post: { id: 1, name: \"Rails is omakase\" } });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n }));\n});\ntest(\"find - payload with sideloaded records of the same type\", function() {\n var count = 0;\n\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ]\n });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n\n var post2 = store.getById('post', 2);\n equal(post2.get('id'), \"2\");\n equal(post2.get('name'), \"The Parley Letter\");\n }));\n});\n\ntest(\"find - payload with sideloaded records of a different type\", function() {\n ajaxResponse({\n posts: [{ id: 1, name: \"Rails is omakase\" }],\n comments: [{ id: 1, name: \"FIRST\" }]\n });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n\n var comment = store.getById('comment', 1);\n equal(comment.get('id'), \"1\");\n equal(comment.get('name'), \"FIRST\");\n }));\n});\n\ntest(\"find - payload with an serializer-specified primary key\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_'\n }));\n\n ajaxResponse({ posts: [{ \"_ID_\": 1, name: \"Rails is omakase\" }] });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n }));\n});\n\ntest(\"find - payload with a serializer-specified attribute mapping\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n attrs: {\n 'name': '_NAME_',\n 'createdAt': { key: '_CREATED_AT_', someOtherOption: 'option' }\n }\n }));\n\n Post.reopen({\n createdAt: DS.attr(\"number\")\n });\n\n ajaxResponse({ posts: [{ id: 1, _NAME_: \"Rails is omakase\", _CREATED_AT_: 2013 }] });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"GET\");\n equal(passedHash, undefined);\n\n equal(post.get('id'), \"1\");\n equal(post.get('name'), \"Rails is omakase\");\n equal(post.get('createdAt'), 2013);\n }));\n});\n\ntest(\"create - an empty payload is a basic success if an id was specified\", function() {\n ajaxResponse();\n\n var post = store.createRecord('post', { id: \"some-uuid\", name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"POST\");\n deepEqual(passedHash.data, { post: { id: \"some-uuid\", name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"The Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"create - a payload with a new ID and data applies the updates\", function() {\n ajaxResponse({ posts: [{ id: \"1\", name: \"Dat Parley Letter\" }] });\n var post = store.createRecord('post', { name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"POST\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('id'), \"1\", \"the post has the updated ID\");\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"create - a payload with a new ID and data applies the updates (with legacy singular name)\", function() {\n ajaxResponse({ post: { id: \"1\", name: \"Dat Parley Letter\" } });\n var post = store.createRecord('post', { name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"POST\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('id'), \"1\", \"the post has the updated ID\");\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"create - findMany doesn't overwrite owner\", function() {\n ajaxResponse({ comment: { id: \"1\", name: \"Dat Parley Letter\", post: 1 } });\n\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [] });\n var post = store.getById('post', 1);\n\n var comment = store.createRecord('comment', { name: \"The Parley Letter\" });\n post.get('comments').pushObject(comment);\n\n equal(comment.get('post'), post, \"the post has been set correctly\");\n\n comment.save().then(async(function(comment) {\n equal(comment.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(comment.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n equal(comment.get('post'), post, \"the post is still set\");\n }));\n});\n\ntest(\"create - a serializer's primary key and attributes are consulted when building the payload\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_id_',\n\n attrs: {\n name: '_name_'\n }\n }));\n\n ajaxResponse();\n\n var post = store.createRecord('post', { id: \"some-uuid\", name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n deepEqual(passedHash.data, { post: { _id_: 'some-uuid', '_name_': \"The Parley Letter\" } });\n }));\n});\n\ntest(\"create - a serializer's attributes are consulted when building the payload if no id is pre-defined\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primarykey: '_id_',\n\n attrs: {\n name: '_name_'\n }\n }));\n\n ajaxResponse();\n\n var post = store.createRecord('post', { name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n deepEqual(passedHash.data, { post: { '_name_': \"The Parley Letter\" } });\n }));\n});\n\ntest(\"create - a record on the many side of a hasMany relationship should update relationships when data is sideloaded\", function() {\n expect(3);\n\n ajaxResponse({\n posts: [{\n id: \"1\",\n name: \"Rails is omakase\",\n comments: [1,2]\n }],\n comments: [{\n id: \"1\",\n name: \"Dat Parley Letter\",\n post: 1\n },{\n id: \"2\",\n name: \"Another Comment\",\n post: 1\n }]\n // My API is returning a comment:{} as well as a comments:[{...},...]\n //, comment: {\n // id: \"2\",\n // name: \"Another Comment\",\n // post: 1\n // }\n });\n\n Post.reopen({ comments: DS.hasMany('comment') });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [1] });\n store.push('comment', { id: 1, name: \"Dat Parlay Letter\", post: 1 });\n\n var post = store.getById('post', 1);\n var commentCount = post.get('comments.length');\n equal(commentCount, 1, \"the post starts life with a comment\");\n\n var comment = store.createRecord('comment', { name: \"Another Comment\", post: post });\n\n comment.save().then(async(function(comment) {\n equal(comment.get('post'), post, \"the comment is related to the post\");\n }));\n\n post.reload().then(async(function(post) {\n equal(post.get('comments.length'), 2, \"Post comment count has been updated\");\n }));\n});\n\ntest(\"update - an empty payload is a basic success\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse();\n\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"PUT\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"The Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"update - a payload with updates applies the updates\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ posts: [{ id: 1, name: \"Dat Parley Letter\" }] });\n\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"PUT\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"update - a payload with updates applies the updates (with legacy singular name)\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ post: { id: 1, name: \"Dat Parley Letter\" } });\n\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"PUT\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n }));\n});\n\ntest(\"update - a payload with sideloaded updates pushes the updates\", function() {\n ajaxResponse({\n posts: [{ id: 1, name: \"Dat Parley Letter\" }],\n comments: [{ id: 1, name: \"FIRST\" }]\n });\n var post = store.createRecord('post', { name: \"The Parley Letter\" });\n\n post.save().then(async(function(post) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"POST\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('id'), \"1\", \"the post has the updated ID\");\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n\n var comment = store.getById('comment', 1);\n equal(comment.get('name'), \"FIRST\", \"The comment was sideloaded\");\n }));\n});\n\n\ntest(\"update - a payload with sideloaded updates pushes the updates\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n posts: [{ id: 1, name: \"Dat Parley Letter\" }],\n comments: [{ id: 1, name: \"FIRST\" }]\n });\n\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"PUT\");\n deepEqual(passedHash.data, { post: { name: \"The Parley Letter\" } });\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('name'), \"Dat Parley Letter\", \"the post was updated\");\n\n var comment = store.getById('comment', 1);\n equal(comment.get('name'), \"FIRST\", \"The comment was sideloaded\");\n }));\n});\n\ntest(\"update - a serializer's primary key and attributes are consulted when building the payload\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_id_',\n\n attrs: {\n name: '_name_'\n }\n }));\n\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n ajaxResponse();\n\n store.find('post', 1).then(async(function(post) {\n post.set('name', \"The Parley Letter\");\n return post.save();\n })).then(async(function(post) {\n deepEqual(passedHash.data, { post: { '_name_': \"The Parley Letter\" } });\n }));\n});\n\ntest(\"delete - an empty payload is a basic success\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse();\n\n post.deleteRecord();\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"DELETE\");\n equal(passedHash, undefined);\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('isDeleted'), true, \"the post is now deleted\");\n }));\n});\n\ntest(\"delete - a payload with sideloaded updates pushes the updates\", function() {\n store.push('post', { id: 1, name: \"Rails is omakase\" });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ comments: [{ id: 1, name: \"FIRST\" }] });\n\n post.deleteRecord();\n return post.save();\n })).then(async(function(post) {\n equal(passedUrl, \"/posts/1\");\n equal(passedVerb, \"DELETE\");\n equal(passedHash, undefined);\n\n equal(post.get('isDirty'), false, \"the post isn't dirty anymore\");\n equal(post.get('isDeleted'), true, \"the post is now deleted\");\n\n var comment = store.getById('comment', 1);\n equal(comment.get('name'), \"FIRST\", \"The comment was sideloaded\");\n }));\n});\n\ntest(\"findAll - returning an array populates the array\", function() {\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ]\n });\n\n store.findAll('post').then(async(function(posts) {\n equal(passedUrl, \"/posts\");\n equal(passedVerb, \"GET\");\n equal(passedHash.data, undefined);\n\n var post1 = store.getById('post', 1),\n post2 = store.getById('post', 2);\n\n deepEqual(\n post1.getProperties('id', 'name'),\n { id: \"1\", name: \"Rails is omakase\" },\n \"Post 1 is loaded\"\n );\n\n deepEqual(\n post2.getProperties('id', 'name'),\n { id: \"2\", name: \"The Parley Letter\" },\n \"Post 2 is loaded\"\n );\n\n equal(posts.get('length'), 2, \"The posts are in the array\");\n equal(posts.get('isLoaded'), true, \"The RecordArray is loaded\");\n deepEqual(\n posts.toArray(),\n [ post1, post2 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findAll - returning sideloaded data loads the data\", function() {\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ],\n comments: [{ id: 1, name: \"FIRST\" }] });\n\n store.findAll('post').then(async(function(posts) {\n var comment = store.getById('comment', 1);\n\n deepEqual(comment.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n }));\n});\n\ntest(\"findAll - data is normalized through custom serializers\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n ajaxResponse({\n posts: [\n { _ID_: 1, _NAME_: \"Rails is omakase\" },\n { _ID_: 2, _NAME_: \"The Parley Letter\" }\n ]\n });\n\n store.findAll('post').then(async(function(posts) {\n var post1 = store.getById('post', 1),\n post2 = store.getById('post', 2);\n\n deepEqual(\n post1.getProperties('id', 'name'),\n { id: \"1\", name: \"Rails is omakase\" },\n \"Post 1 is loaded\"\n );\n deepEqual(\n post2.getProperties('id', 'name'),\n { id: \"2\", name: \"The Parley Letter\" },\n \"Post 2 is loaded\"\n );\n\n equal(posts.get('length'), 2, \"The posts are in the array\");\n equal(posts.get('isLoaded'), true, \"The RecordArray is loaded\");\n deepEqual(\n posts.toArray(),\n [ post1, post2 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findAll - since token is passed to the adapter\", function() {\n ajaxResponse({\n meta: { since: 'later'},\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ]\n });\n\n store.metaForType('post', { since: 'now' });\n\n store.findAll('post').then(async(function(posts) {\n equal(passedUrl, '/posts');\n equal(passedVerb, 'GET');\n equal(store.typeMapFor(Post).metadata.since, 'later');\n deepEqual(passedHash.data, { since: 'now' });\n }));\n});\n\ntest(\"metadata is accessible\", function() {\n ajaxResponse({\n meta: { offset: 5 },\n posts: [{id: 1, name: \"Rails is very expensive sushi\"}]\n });\n\n store.findAll('post').then(async(function(posts) {\n equal(\n store.metadataFor('post').offset,\n 5,\n \"Metadata can be accessed with metadataFor.\"\n );\n }));\n});\n\ntest(\"findQuery - payload 'meta' is accessible on the record array\", function() {\n ajaxResponse({\n meta: { offset: 5 },\n posts: [{id: 1, name: \"Rails is very expensive sushi\"}]\n });\n\n store.findQuery('post', { page: 2 }).then(async(function(posts) {\n equal(\n posts.get('meta.offset'),\n 5,\n \"Reponse metadata can be accessed with recordArray.meta\"\n );\n }));\n});\n\ntest(\"findQuery - returning an array populates the array\", function() {\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }]\n });\n\n store.findQuery('post', { page: 1 }).then(async(function(posts) {\n equal(passedUrl, '/posts');\n equal(passedVerb, 'GET');\n deepEqual(passedHash.data, { page: 1 });\n\n var post1 = store.getById('post', 1),\n post2 = store.getById('post', 2);\n\n deepEqual(\n post1.getProperties('id', 'name'),\n { id: \"1\", name: \"Rails is omakase\" },\n \"Post 1 is loaded\"\n );\n deepEqual(\n post2.getProperties('id', 'name'),\n { id: \"2\", name: \"The Parley Letter\" },\n \"Post 2 is loaded\"\n );\n\n equal(posts.get('length'), 2, \"The posts are in the array\");\n equal(posts.get('isLoaded'), true, \"The RecordArray is loaded\");\n deepEqual(\n posts.toArray(),\n [ post1, post2 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findQuery - returning sideloaded data loads the data\", function() {\n ajaxResponse({\n posts: [\n { id: 1, name: \"Rails is omakase\" },\n { id: 2, name: \"The Parley Letter\" }\n ],\n comments: [{ id: 1, name: \"FIRST\" }]\n });\n\n store.findQuery('post', { page: 1 }).then(async(function(posts) {\n var comment = store.getById('comment', 1);\n\n deepEqual(comment.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n }));\n});\n\ntest(\"findQuery - data is normalized through custom serializers\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n ajaxResponse({\n posts: [{ _ID_: 1, _NAME_: \"Rails is omakase\" },\n { _ID_: 2, _NAME_: \"The Parley Letter\" }]\n });\n\n store.findQuery('post', { page: 1 }).then(async(function(posts) {\n var post1 = store.getById('post', 1),\n post2 = store.getById('post', 2);\n\n deepEqual(\n post1.getProperties('id', 'name'),\n { id: \"1\", name: \"Rails is omakase\" },\n \"Post 1 is loaded\"\n );\n\n deepEqual(\n post2.getProperties('id', 'name'),\n { id: \"2\", name: \"The Parley Letter\" },\n \"Post 2 is loaded\"\n );\n\n equal(posts.get('length'), 2, \"The posts are in the array\");\n equal(posts.get('isLoaded'), true, \"The RecordArray is loaded\");\n deepEqual(\n posts.toArray(),\n [ post1, post2 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findMany - returning an array populates the array\", function() {\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [ 1, 2, 3 ] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { id: 1, name: \"FIRST\" },\n { id: 2, name: \"Rails is unagi\" },\n { id: 3, name: \"What is omakase?\" }\n ]\n });\n\nreturn post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3);\n\n deepEqual(comment1.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n deepEqual(comment2.getProperties('id', 'name'), { id: \"2\", name: \"Rails is unagi\" });\n deepEqual(comment3.getProperties('id', 'name'), { id: \"3\", name: \"What is omakase?\" });\n\n deepEqual(\n comments.toArray(),\n [ comment1, comment2, comment3 ],\n \"The correct records are in the array\"\n );\n }));\n});\n\ntest(\"findMany - returning sideloaded data loads the data\", function() {\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [ 1, 2, 3 ] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { id: 1, name: \"FIRST\" },\n { id: 2, name: \"Rails is unagi\" },\n { id: 3, name: \"What is omakase?\" },\n { id: 4, name: \"Unrelated comment\" }\n ],\n posts: [{ id: 2, name: \"The Parley Letter\" }]\n });\n\n return post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3),\n comment4 = store.getById('comment', 4),\n post2 = store.getById('post', 2);\n\n deepEqual(\n comments.toArray(),\n [ comment1, comment2, comment3 ],\n \"The correct records are in the array\"\n );\n\n deepEqual(comment4.getProperties('id', 'name'), { id: \"4\", name: \"Unrelated comment\" });\n deepEqual(post2.getProperties('id', 'name'), { id: \"2\", name: \"The Parley Letter\" });\n }));\n});\n\ntest(\"findMany - a custom serializer is used if present\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n env.container.register('serializer:comment', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push('post', { id: 1, name: \"Rails is omakase\", comments: [ 1, 2, 3 ] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { _ID_: 1, _NAME_: \"FIRST\" },\n { _ID_: 2, _NAME_: \"Rails is unagi\" },\n { _ID_: 3, _NAME_: \"What is omakase?\" }]\n });\n\n return post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3);\n\n deepEqual(comment1.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n deepEqual(comment2.getProperties('id', 'name'), { id: \"2\", name: \"Rails is unagi\" });\n deepEqual(comment3.getProperties('id', 'name'), { id: \"3\", name: \"What is omakase?\" });\n\n deepEqual(comments.toArray(), [ comment1, comment2, comment3 ], \"The correct records are in the array\");\n }));\n});\n\ntest(\"findHasMany - returning an array populates the array\", function() {\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push(\n 'post',\n {\n id: 1,\n name: \"Rails is omakase\",\n links: { comments: '/posts/1/comments' }\n }\n );\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { id: 1, name: \"FIRST\" },\n { id: 2, name: \"Rails is unagi\" },\n { id: 3, name: \"What is omakase?\" }\n ]\n });\n\n return post.get('comments');\n })).then(async(function(comments) {\n equal(passedUrl, '/posts/1/comments');\n equal(passedVerb, 'GET');\n equal(passedHash, undefined);\n\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3);\n\n deepEqual(comment1.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n deepEqual(comment2.getProperties('id', 'name'), { id: \"2\", name: \"Rails is unagi\" });\n deepEqual(comment3.getProperties('id', 'name'), { id: \"3\", name: \"What is omakase?\" });\n\n deepEqual(comments.toArray(), [ comment1, comment2, comment3 ], \"The correct records are in the array\");\n }));\n});\n\ntest(\"findMany - returning sideloaded data loads the data\", function() {\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push(\n 'post',\n {\n id: 1,\n name: \"Rails is omakase\",\n links: { comments: '/posts/1/comments' }\n }\n );\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { id: 1, name: \"FIRST\" },\n { id: 2, name: \"Rails is unagi\" },\n { id: 3, name: \"What is omakase?\" }\n ],\n posts: [{ id: 2, name: \"The Parley Letter\" }]\n });\n\n return post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3),\n post2 = store.getById('post', 2);\n\n deepEqual(comments.toArray(), [ comment1, comment2, comment3 ], \"The correct records are in the array\");\n\n deepEqual(post2.getProperties('id', 'name'), { id: \"2\", name: \"The Parley Letter\" });\n }));\n});\n\ntest(\"findMany - a custom serializer is used if present\", function() {\n env.container.register('serializer:post', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n env.container.register('serializer:comment', DS.RESTSerializer.extend({\n primaryKey: '_ID_',\n attrs: { name: '_NAME_' }\n }));\n\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n\n store.push(\n 'post',\n {\n id: 1,\n name: \"Rails is omakase\",\n links: { comments: '/posts/1/comments' }\n }\n );\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({\n comments: [\n { _ID_: 1, _NAME_: \"FIRST\" },\n { _ID_: 2, _NAME_: \"Rails is unagi\" },\n { _ID_: 3, _NAME_: \"What is omakase?\" }\n ]\n });\n return post.get('comments');\n })).then(async(function(comments) {\n var comment1 = store.getById('comment', 1),\n comment2 = store.getById('comment', 2),\n comment3 = store.getById('comment', 3);\n\n deepEqual(comment1.getProperties('id', 'name'), { id: \"1\", name: \"FIRST\" });\n deepEqual(comment2.getProperties('id', 'name'), { id: \"2\", name: \"Rails is unagi\" });\n deepEqual(comment3.getProperties('id', 'name'), { id: \"3\", name: \"What is omakase?\" });\n\n deepEqual(comments.toArray(), [ comment1, comment2, comment3 ], \"The correct records are in the array\");\n }));\n});\n\ntest('buildURL - with host and namespace', function() {\n adapter.setProperties({\n host: 'http://example.com',\n namespace: 'api/v1'\n });\n\n ajaxResponse({ posts: [{ id: 1 }] });\n\n store.find('post', 1).then(async(function(post) {\n equal(passedUrl, \"http://example.com/api/v1/posts/1\");\n }));\n});\n\ntest('buildURL - with relative paths in links', function() {\n adapter.setProperties({\n host: 'http://example.com',\n namespace: 'api/v1'\n });\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n ajaxResponse({ posts: [{ id: 1, links: { comments: 'comments' } }] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ comments: [{ id: 1 }] });\n return post.get('comments');\n })).then(async(function (comments) {\n equal(passedUrl, \"http://example.com/api/v1/posts/1/comments\");\n }));\n});\n\ntest('buildURL - with absolute paths in links', function() {\n adapter.setProperties({\n host: 'http://example.com',\n namespace: 'api/v1'\n });\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n ajaxResponse({ posts: [{ id: 1, links: { comments: '/api/v1/posts/1/comments' } }] });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ comments: [{ id: 1 }] });\n return post.get('comments');\n })).then(async(function (comments) {\n equal(passedUrl, \"http://example.com/api/v1/posts/1/comments\");\n }));\n});\n\ntest('buildURL - with full URLs in links', function() {\n adapter.setProperties({\n host: 'http://example.com',\n namespace: 'api/v1'\n });\n Post.reopen({ comments: DS.hasMany('comment', { async: true }) });\n Comment.reopen({ post: DS.belongsTo('post') });\n\n ajaxResponse({\n posts: [\n { id: 1,\n links: { comments: 'http://example.com/api/v1/posts/1/comments' }\n }\n ]\n });\n\n store.find('post', 1).then(async(function(post) {\n ajaxResponse({ comments: [{ id: 1 }] });\n return post.get('comments');\n })).then(async(function (comments) {\n equal(passedUrl, \"http://example.com/api/v1/posts/1/comments\");\n }));\n});\n\ntest('buildURL - with camelized names', function() {\n adapter.setProperties({\n pathForType: function(type) {\n var decamelized = Ember.String.decamelize(type);\n return Ember.String.pluralize(decamelized);\n }\n });\n\n ajaxResponse({ superUsers: [{ id: 1 }] });\n\n store.find('superUser', 1).then(async(function(post) {\n equal(passedUrl, \"/super_users/1\");\n }));\n});\n\ntest('normalizeKey - to set up _ids and _id', function() {\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n keyForAttribute: function(attr) {\n //if (kind === 'hasMany') {\n //key = key.replace(/_ids$/, '');\n //key = Ember.String.pluralize(key);\n //} else if (kind === 'belongsTo') {\n //key = key.replace(/_id$/, '');\n //}\n\n return Ember.String.underscore(attr);\n },\n\n keyForBelongsTo: function(belongsTo) {\n },\n\n keyForRelationship: function(rel, kind) {\n if (kind === 'belongsTo') {\n var underscored = Ember.String.underscore(rel);\n return underscored + '_id';\n } else {\n var singular = Ember.String.singularize(rel);\n return Ember.String.underscore(singular) + '_ids';\n }\n }\n }));\n\n env.container.register('model:post', DS.Model.extend({\n name: DS.attr(),\n authorName: DS.attr(),\n author: DS.belongsTo('user'),\n comments: DS.hasMany('comment')\n }));\n\n env.container.register('model:user', DS.Model.extend({\n createdAt: DS.attr(),\n name: DS.attr()\n }));\n\n env.container.register('model:comment', DS.Model.extend({\n body: DS.attr()\n }));\n\n ajaxResponse({\n posts: [{\n id: \"1\",\n name: \"Rails is omakase\",\n author_name: \"@d2h\",\n author_id: \"1\",\n comment_ids: [ \"1\", \"2\" ]\n }],\n\n users: [{\n id: \"1\",\n name: \"D2H\"\n }],\n\n comments: [{\n id: \"1\",\n body: \"Rails is unagi\"\n }, {\n id: \"2\",\n body: \"What is omakase?\"\n }]\n });\n\n store.find('post', 1).then(async(function(post) {\n equal(post.get('authorName'), \"@d2h\");\n equal(post.get('author.name'), \"D2H\");\n deepEqual(post.get('comments').mapBy('body'), [\"Rails is unagi\", \"What is omakase?\"]);\n }));\n});\n\n//test(\"creating a record with a 422 error marks the records as invalid\", function(){\n //expect(1);\n\n //var mockXHR = {\n //status: 422,\n //responseText: JSON.stringify({ errors: { name: [\"can't be blank\"]} })\n //};\n\n //jQuery.ajax = function(hash) {\n //hash.error.call(hash.context, mockXHR, \"Unprocessable Entity\");\n //};\n\n //var post = store.createRecord(Post, { name: \"\" });\n\n //post.on(\"becameInvalid\", function() {\n //ok(true, \"becameInvalid is called\");\n //});\n\n //post.on(\"becameError\", function() {\n //ok(false, \"becameError is not called\");\n //});\n\n //post.save();\n//});\n\n//test(\"changing A=>null=>A should clean up the record\", function() {\n //var store = DS.Store.create({\n //adapter: DS.RESTAdapter\n //});\n //var Kidney = DS.Model.extend();\n //var Person = DS.Model.extend();\n\n //Kidney.reopen({\n //person: DS.belongsTo(Person)\n //});\n //Kidney.toString = function() { return \"Kidney\"; };\n\n //Person.reopen({\n //name: DS.attr('string'),\n //kidneys: DS.hasMany(Kidney)\n //});\n //Person.toString = function() { return \"Person\"; };\n\n //store.load(Person, { id: 1, kidneys: [1, 2] });\n //store.load(Kidney, { id: 1, person: 1 });\n //store.load(Kidney, { id: 2, person: 1 });\n\n //var person = store.find(Person, 1);\n //var kidney1 = store.find(Kidney, 1);\n //var kidney2 = store.find(Kidney, 2);\n\n //deepEqual(person.get('kidneys').toArray(), [kidney1, kidney2], \"precond - person should have both kidneys\");\n //equal(kidney1.get('person'), person, \"precond - first kidney should be in the person\");\n\n //person.get('kidneys').removeObject(kidney1);\n\n //ok(person.get('isDirty'), \"precond - person should be dirty after operation\");\n //ok(kidney1.get('isDirty'), \"precond - first kidney should be dirty after operation\");\n\n //deepEqual(person.get('kidneys').toArray(), [kidney2], \"precond - person should have only the second kidney\");\n //equal(kidney1.get('person'), null, \"precond - first kidney should be on the operating table\");\n\n //person.get('kidneys').addObject(kidney1);\n\n //ok(!person.get('isDirty'), \"person should be clean after restoration\");\n //ok(!kidney1.get('isDirty'), \"first kidney should be clean after restoration\");\n\n //deepEqual(person.get('kidneys').toArray(), [kidney2, kidney1], \"person should have both kidneys again\");\n //equal(kidney1.get('person'), person, \"first kidney should be in the person again\");\n//});\n\n//test(\"changing A=>B=>A should clean up the record\", function() {\n //var store = DS.Store.create({\n //adapter: DS.RESTAdapter\n //});\n //var Kidney = DS.Model.extend();\n //var Person = DS.Model.extend();\n\n //Kidney.reopen({\n //person: DS.belongsTo(Person)\n //});\n //Kidney.toString = function() { return \"Kidney\"; };\n\n //Person.reopen({\n //name: DS.attr('string'),\n //kidneys: DS.hasMany(Kidney)\n //});\n //Person.toString = function() { return \"Person\"; };\n\n //store.load(Person, { person: { id: 1, name: \"John Doe\", kidneys: [1, 2] }});\n //store.load(Person, { person: { id: 2, name: \"Jane Doe\", kidneys: [3]} });\n //store.load(Kidney, { kidney: { id: 1, person_id: 1 } });\n //store.load(Kidney, { kidney: { id: 2, person_id: 1 } });\n //store.load(Kidney, { kidney: { id: 3, person_id: 2 } });\n\n //var john = store.find(Person, 1);\n //var jane = store.find(Person, 2);\n //var kidney1 = store.find(Kidney, 1);\n //var kidney2 = store.find(Kidney, 2);\n //var kidney3 = store.find(Kidney, 3);\n\n //deepEqual(john.get('kidneys').toArray(), [kidney1, kidney2], \"precond - john should have the first two kidneys\");\n //deepEqual(jane.get('kidneys').toArray(), [kidney3], \"precond - jane should have the third kidney\");\n //equal(kidney2.get('person'), john, \"precond - second kidney should be in john\");\n\n //kidney2.set('person', jane);\n\n //ok(john.get('isDirty'), \"precond - john should be dirty after operation\");\n //ok(jane.get('isDirty'), \"precond - jane should be dirty after operation\");\n //ok(kidney2.get('isDirty'), \"precond - second kidney should be dirty after operation\");\n\n //deepEqual(john.get('kidneys').toArray(), [kidney1], \"precond - john should have only the first kidney\");\n //deepEqual(jane.get('kidneys').toArray(), [kidney3, kidney2], \"precond - jane should have the other two kidneys\");\n //equal(kidney2.get('person'), jane, \"precond - second kidney should be in jane\");\n\n //kidney2.set('person', john);\n\n //ok(!john.get('isDirty'), \"john should be clean after restoration\");\n //ok(!jane.get('isDirty'), \"jane should be clean after restoration\");\n //ok(!kidney2.get('isDirty'), \"second kidney should be clean after restoration\");\n\n //deepEqual(john.get('kidneys').toArray(), [kidney1, kidney2], \"john should have the first two kidneys again\");\n //deepEqual(jane.get('kidneys').toArray(), [kidney3], \"jane should have the third kidney again\");\n //equal(kidney2.get('person'), john, \"second kidney should be in john again\");\n//});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/rest_adapter_test");minispade.register('ember-data/~tests/integration/adapter/store_adapter_test', "(function() {/**\n This is an integration test that tests the communication between a store\n and its adapter.\n\n Typically, when a method is invoked on the store, it calls a related\n method on its adapter. The adapter notifies the store that it has\n completed the assigned task, either synchronously or asynchronously,\n by calling a method on the store.\n\n These tests ensure that the proper methods get called, and, if applicable,\n the given record or record array changes state appropriately.\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar Person, Dog, env, store, adapter;\n\nmodule(\"integration/adapter/store_adapter - DS.Store and DS.Adapter integration test\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: DS.attr('string'),\n name: DS.attr('string'),\n firstName: DS.attr('string'),\n lastName: DS.attr('string')\n });\n\n Dog = DS.Model.extend({\n name: DS.attr('string')\n });\n\n env = setupStore({ person: Person, dog: Dog });\n store = env.store;\n adapter = env.adapter;\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"Records loaded multiple times and retrieved in recordArray are ready to send state events\", function() {\n adapter.findQuery = function(store, type, query, recordArray) {\n return Ember.RSVP.resolve([{\n id: 1,\n name: \"Mickael Ramírez\"\n }, {\n id: 2,\n name: \"Johny Fontana\"\n }]);\n };\n\n store.findQuery('person', {q: 'bla'}).then(async(function(people) {\n var people2 = store.findQuery('person', { q: 'bla2' });\n\n return Ember.RSVP.hash({ people: people, people2: people2 });\n })).then(async(function(results) {\n equal(results.people2.get('length'), 2, 'return the elements' );\n ok( results.people2.get('isLoaded'), 'array is loaded' );\n\n var person = results.people.objectAt(0);\n ok(person.get('isLoaded'), 'record is loaded');\n\n // delete record will not throw exception\n person.deleteRecord();\n }));\n\n});\n\ntest(\"by default, createRecords calls createRecord once per record\", function() {\n var count = 1;\n\n adapter.createRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (count === 1) {\n equal(get(record, 'name'), \"Tom Dale\");\n } else if (count === 2) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n } else {\n ok(false, \"should not have invoked more than 2 times\");\n }\n\n var hash = get(record, 'data');\n hash.id = count;\n hash.updatedAt = \"now\";\n\n count++;\n return Ember.RSVP.resolve(hash);\n };\n\n var tom = store.createRecord('person', { name: \"Tom Dale\" });\n var yehuda = store.createRecord('person', { name: \"Yehuda Katz\" });\n\n Ember.RSVP.hash({ tom: tom.save(), yehuda: yehuda.save() }).then(async(function(records) {\n tom = records.tom;\n yehuda = records.yehuda;\n\n asyncEqual(tom, store.find('person', 1), \"Once an ID is in, find returns the same object\");\n asyncEqual(yehuda, store.find('person', 2), \"Once an ID is in, find returns the same object\");\n equal(get(tom, 'updatedAt'), \"now\", \"The new information is received\");\n equal(get(yehuda, 'updatedAt'), \"now\", \"The new information is received\");\n }));\n});\n\ntest(\"by default, updateRecords calls updateRecord once per record\", function() {\n var count = 0;\n\n adapter.updateRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (count === 0) {\n equal(get(record, 'name'), \"Tom Dale\");\n } else if (count === 1) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n } else {\n ok(false, \"should not get here\");\n }\n\n count++;\n\n equal(record.get('isSaving'), true, \"record is saving\");\n\n return Ember.RSVP.resolve();\n };\n\n store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n store.push('person', { id: 2, name: \"Brohuda Katz\" });\n\n Ember.RSVP.hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n set(tom, \"name\", \"Tom Dale\");\n set(yehuda, \"name\", \"Yehuda Katz\");\n\n return Ember.RSVP.hash({ tom: tom.save(), yehuda: yehuda.save() });\n })).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n equal(tom.get('isSaving'), false, \"record is no longer saving\");\n equal(tom.get('isLoaded'), true, \"record is loaded\");\n\n equal(yehuda.get('isSaving'), false, \"record is no longer saving\");\n equal(yehuda.get('isLoaded'), true, \"record is loaded\");\n }));\n});\n\ntest(\"calling store.didSaveRecord can provide an optional hash\", function() {\n var count = 0;\n\n adapter.updateRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n count++;\n if (count === 1) {\n equal(get(record, 'name'), \"Tom Dale\");\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", updatedAt: \"now\" });\n } else if (count === 2) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n return Ember.RSVP.resolve({ id: 2, name: \"Yehuda Katz\", updatedAt: \"now!\" });\n } else {\n ok(false, \"should not get here\");\n }\n };\n\n store.push('person', { id: 1, name: \"Braaaahm Dale\" });\n store.push('person', { id: 2, name: \"Brohuda Katz\" });\n\n Ember.RSVP.hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n set(tom, \"name\", \"Tom Dale\");\n set(yehuda, \"name\", \"Yehuda Katz\");\n\n return Ember.RSVP.hash({ tom: tom.save(), yehuda: yehuda.save() });\n })).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n equal(get(tom, 'isDirty'), false, \"the record should not be dirty\");\n equal(get(tom, 'updatedAt'), \"now\", \"the hash was updated\");\n\n equal(get(yehuda, 'isDirty'), false, \"the record should not be dirty\");\n equal(get(yehuda, 'updatedAt'), \"now!\", \"the hash was updated\");\n }));\n});\n\ntest(\"by default, deleteRecord calls deleteRecord once per record\", function() {\n expect(4);\n\n var count = 0;\n\n adapter.deleteRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (count === 0) {\n equal(get(record, 'name'), \"Tom Dale\");\n } else if (count === 1) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n } else {\n ok(false, \"should not get here\");\n }\n\n count++;\n\n return Ember.RSVP.resolve();\n };\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n store.push('person', { id: 2, name: \"Yehuda Katz\" });\n\n Ember.RSVP.hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n tom.deleteRecord();\n yehuda.deleteRecord();\n\n tom.save();\n yehuda.save();\n }));\n});\n\ntest(\"by default, destroyRecord calls deleteRecord once per record without requiring .save\", function() {\n expect(4);\n\n var count = 0;\n\n adapter.deleteRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (count === 0) {\n equal(get(record, 'name'), \"Tom Dale\");\n } else if (count === 1) {\n equal(get(record, 'name'), \"Yehuda Katz\");\n } else {\n ok(false, \"should not get here\");\n }\n\n count++;\n\n return Ember.RSVP.resolve();\n };\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n store.push('person', { id: 2, name: \"Yehuda Katz\" });\n\n Ember.RSVP.hash({ tom: store.find('person', 1), yehuda: store.find('person', 2) }).then(async(function(records) {\n var tom = records.tom, yehuda = records.yehuda;\n\n tom.destroyRecord();\n yehuda.destroyRecord();\n }));\n});\n\ntest(\"if an existing model is edited then deleted, deleteRecord is called on the adapter\", function() {\n expect(5);\n\n var count = 0;\n\n adapter.deleteRecord = function(store, type, record) {\n count++;\n equal(get(record, 'id'), 'deleted-record', \"should pass correct record to deleteRecord\");\n equal(count, 1, \"should only call deleteRecord method of adapter once\");\n\n return Ember.RSVP.resolve();\n };\n\n adapter.updateRecord = function() {\n ok(false, \"should not have called updateRecord method of adapter\");\n };\n\n // Load data for a record into the store.\n store.push('person', { id: 'deleted-record', name: \"Tom Dale\" });\n\n // Retrieve that loaded record and edit it so it becomes dirty\n store.find('person', 'deleted-record').then(async(function(tom) {\n tom.set('name', \"Tom Mothereffin' Dale\");\n\n equal(get(tom, 'isDirty'), true, \"precond - record should be dirty after editing\");\n\n tom.deleteRecord();\n return tom.save();\n })).then(async(function(tom) {\n equal(get(tom, 'isDirty'), false, \"record should not be dirty\");\n equal(get(tom, 'isDeleted'), true, \"record should be considered deleted\");\n }));\n});\n\ntest(\"if a deleted record errors, it enters the error state\", function() {\n var count = 0;\n\n adapter.deleteRecord = function(store, type, record) {\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve();\n }\n };\n\n store.push('person', { id: 'deleted-record', name: \"Tom Dale\" });\n\n var tom;\n\n store.find('person', 'deleted-record').then(async(function(person) {\n tom = person;\n person.deleteRecord();\n return person.save();\n })).then(null, async(function() {\n equal(tom.get('isError'), true, \"Tom is now errored\");\n\n // this time it succeeds\n return tom.save();\n })).then(async(function() {\n equal(tom.get('isError'), false, \"Tom is not errored anymore\");\n }));\n});\n\ntest(\"if a created record is marked as invalid by the server, it enters an error state\", function() {\n adapter.createRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (get(record, 'name').indexOf('Bro') === -1) {\n return Ember.RSVP.reject(new DS.InvalidError({ name: ['common... name requires a \"bro\"'] }));\n } else {\n return Ember.RSVP.resolve();\n }\n };\n\n var yehuda = store.createRecord('person', { id: 1, name: \"Yehuda Katz\" });\n\n // Wrap this in an Ember.run so that all chained async behavior is set up\n // before flushing any scheduled behavior.\n Ember.run(function() {\n yehuda.save().then(null, async(function(error) {\n equal(get(yehuda, 'isValid'), false, \"the record is invalid\");\n ok(get(yehuda, 'errors.name'), \"The errors.name property exists\");\n\n set(yehuda, 'updatedAt', true);\n equal(get(yehuda, 'isValid'), false, \"the record is still invalid\");\n\n // This tests that we handle undefined values without blowing up\n var errors = get(yehuda, 'errors');\n set(errors, 'other_bound_property', undefined);\n set(yehuda, 'errors', errors);\n set(yehuda, 'name', \"Brohuda Brokatz\");\n\n equal(get(yehuda, 'isValid'), true, \"the record is no longer invalid after changing\");\n equal(get(yehuda, 'isDirty'), true, \"the record has outstanding changes\");\n\n equal(get(yehuda, 'isNew'), true, \"precond - record is still new\");\n\n return yehuda.save();\n })).then(async(function(person) {\n strictEqual(person, yehuda, \"The promise resolves with the saved record\");\n\n equal(get(yehuda, 'isValid'), true, \"record remains valid after committing\");\n equal(get(yehuda, 'isNew'), false, \"record is no longer new\");\n }));\n });\n});\n\ntest(\"if a created record is marked as erred by the server, it enters an error state\", function() {\n adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n Ember.run(function() {\n var person = store.createRecord('person', { id: 1, name: \"John Doe\" });\n\n person.save().then(null, async(function() {\n ok(get(person, 'isError'), \"the record is in the error state\");\n }));\n });\n});\n\ntest(\"if an updated record is marked as invalid by the server, it enters an error state\", function() {\n adapter.updateRecord = function(store, type, record) {\n equal(type, Person, \"the type is correct\");\n\n if (get(record, 'name').indexOf('Bro') === -1) {\n return Ember.RSVP.reject(new DS.InvalidError({ name: ['common... name requires a \"bro\"'] }));\n } else {\n return Ember.RSVP.resolve();\n }\n };\n\n var yehuda = store.push('person', { id: 1, name: \"Brohuda Brokatz\" });\n\n Ember.run(function() {\n store.find('person', 1).then(async(function(person) {\n equal(person, yehuda, \"The same object is passed through\");\n\n equal(get(yehuda, 'isValid'), true, \"precond - the record is valid\");\n set(yehuda, 'name', \"Yehuda Katz\");\n equal(get(yehuda, 'isValid'), true, \"precond - the record is still valid as far as we know\");\n\n equal(get(yehuda, 'isDirty'), true, \"the record is dirty\");\n\n return yehuda.save();\n })).then(null, async(function(reason) {\n equal(get(yehuda, 'isDirty'), true, \"the record is still dirty\");\n equal(get(yehuda, 'isValid'), false, \"the record is invalid\");\n\n set(yehuda, 'updatedAt', true);\n equal(get(yehuda, 'isValid'), false, \"the record is still invalid\");\n\n set(yehuda, 'name', \"Brohuda Brokatz\");\n equal(get(yehuda, 'isValid'), true, \"the record is no longer invalid after changing\");\n equal(get(yehuda, 'isDirty'), true, \"the record has outstanding changes\");\n\n return yehuda.save();\n })).then(async(function(yehuda) {\n equal(get(yehuda, 'isValid'), true, \"record remains valid after committing\");\n equal(get(yehuda, 'isDirty'), false, \"record is no longer new\");\n }));\n });\n});\n\ntest(\"if a updated record is marked as erred by the server, it enters an error state\", function() {\n adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n var person = store.push(Person, { id: 1, name: \"John Doe\" });\n\n store.find('person', 1).then(async(function(record) {\n equal(record, person, \"The person was resolved\");\n person.set('name', \"Jonathan Doe\");\n return person.save();\n })).then(null, async(function(reason) {\n ok(get(person, 'isError'), \"the record is in the error state\");\n }));\n});\n\ntest(\"can be created after the DS.Store\", function() {\n expect(1);\n\n adapter.find = function(store, type) {\n equal(type, Person, \"the type is correct\");\n return Ember.RSVP.resolve({ id: 1 });\n };\n\n store.find('person', 1);\n});\n\ntest(\"the filter method can optionally take a server query as well\", function() {\n adapter.findQuery = function(store, type, query, array) {\n return Ember.RSVP.resolve([\n { id: 1, name: \"Yehuda Katz\" },\n { id: 2, name: \"Tom Dale\" }\n ]);\n };\n\n var asyncFilter = store.filter('person', { page: 1 }, function(data) {\n return data.get('name') === \"Tom Dale\";\n });\n\n var loadedFilter;\n\n asyncFilter.then(async(function(filter) {\n loadedFilter = filter;\n return store.find('person', 2);\n })).then(async(function(tom) {\n equal(get(loadedFilter, 'length'), 1, \"The filter has an item in it\");\n deepEqual(loadedFilter.toArray(), [ tom ], \"The filter has a single entry in it\");\n }));\n});\n\ntest(\"relationships returned via `commit` do not trigger additional findManys\", function() {\n Person.reopen({\n dogs: DS.hasMany()\n });\n\n store.push('dog', { id: 1, name: \"Scruffy\" });\n\n adapter.find = function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", dogs: [1] });\n };\n\n adapter.updateRecord = function(store, type, record) {\n return new Ember.RSVP.Promise(function(resolve, reject) {\n store.push('person', { id: 1, name: \"Tom Dale\", dogs: [1, 2] });\n store.push('dog', { id: 2, name: \"Scruffles\" });\n resolve({ id: 1, name: \"Scruffy\" });\n });\n };\n\n adapter.findMany = function(store, type, ids) {\n ok(false, \"Should not get here\");\n };\n\n store.find('person', 1).then(async(function(person) {\n return Ember.RSVP.hash({ tom: person, dog: store.find('dog', 1) });\n })).then(async(function(records) {\n records.tom.get('dogs');\n return records.dog.save();\n })).then(async(function(tom) {\n ok(true, \"Tom was saved\");\n }));\n});\n\ntest(\"relationships don't get reset if the links is the same\", function() {\n Person.reopen({\n dogs: DS.hasMany({ async: true })\n });\n\n var count = 0;\n\n adapter.findHasMany = function() {\n ok(count++ === 0, \"findHasMany is only called once\");\n\n return Ember.RSVP.resolve([{ id: 1, name: \"Scruffy\" }]);\n };\n\n store.push('person', { id: 1, name: \"Tom Dale\", links: { dogs: \"/dogs\" } });\n\n var tom, dogs;\n\n store.find('person', 1).then(async(function(person) {\n tom = person;\n dogs = tom.get('dogs');\n return dogs;\n })).then(async(function(dogs) {\n equal(dogs.get('length'), 1, \"The dogs are loaded\");\n store.push('person', { id: 1, name: \"Tom Dale\", links: { dogs: \"/dogs\" } });\n ok(tom.get('dogs') instanceof DS.PromiseArray, 'dogs is a promise');\n return tom.get('dogs');\n })).then(async(function(dogs) {\n equal(dogs.get('length'), 1, \"The same dogs are loaded\");\n }));\n});\n\n\ntest(\"async hasMany always returns a promise\", function() {\n Person.reopen({\n dogs: DS.hasMany({ async: true })\n });\n\n adapter.createRecord = function(store, type, record) {\n var hash = { name: \"Tom Dale\" };\n hash.dogs = Ember.A();\n hash.id = 1;\n return Ember.RSVP.resolve(hash);\n };\n\n var tom = store.createRecord('person', { name: \"Tom Dale\" });\n ok(tom.get('dogs') instanceof DS.PromiseArray, \"dogs is a promise before save\");\n\n tom.save().then(async(function() {\n ok(tom.get('dogs') instanceof DS.PromiseArray, \"dogs is a promise after save\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/adapter/store_adapter_test");minispade.register('ember-data/~tests/integration/all_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar Person, store, array, moreArray;\n\nmodule(\"integration/all - DS.Store#all()\", {\n setup: function() {\n array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }];\n moreArray = [{ id: 3, name: \"Scumbag Bryn\" }];\n Person = DS.Model.extend({ name: DS.attr('string') });\n\n store = createStore({ person: Person });\n },\n teardown: function() {\n store.destroy();\n Person = null;\n array = null;\n }\n});\n\ntest(\"store.all('person') should return all records and should update with new ones\", function() {\n store.pushMany('person', array);\n\n var all = store.all('person');\n equal(get(all, 'length'), 2);\n\n store.pushMany('person', moreArray);\n\n equal(get(all, 'length'), 3);\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/all_test");minispade.register('ember-data/~tests/integration/application_test', "(function() {var app, container;\n\n/**\n These tests ensure that Ember Data works with Ember.js' application\n initialization and dependency injection APIs.\n*/\n\nmodule(\"integration/application - Injecting a Custom Store\", {\n setup: function() {\n Ember.run(function() {\n app = Ember.Application.create({\n Store: DS.Store.extend({ isCustom: true }),\n FooController: Ember.Controller.extend(),\n ApplicationView: Ember.View.extend(),\n BazController: {},\n ApplicationController: Ember.View.extend()\n });\n });\n\n container = app.__container__;\n },\n\n teardown: function() {\n app.destroy();\n Ember.BOOTED = false;\n }\n});\n\ntest(\"If a Store property exists on an Ember.Application, it should be instantiated.\", function() {\n ok(container.lookup('store:main').get('isCustom'), \"the custom store was instantiated\");\n});\n\ntest(\"If a store is instantiated, it should be made available to each controller.\", function() {\n var fooController = container.lookup('controller:foo');\n ok(fooController.get('store.isCustom'), \"the custom store was injected\");\n});\n\nmodule(\"integration/application - Injecting the Default Store\", {\n setup: function() {\n Ember.run(function() {\n app = Ember.Application.create({\n FooController: Ember.Controller.extend(),\n ApplicationView: Ember.View.extend(),\n BazController: {},\n ApplicationController: Ember.View.extend()\n });\n });\n\n container = app.__container__;\n },\n\n teardown: function() {\n app.destroy();\n Ember.BOOTED = false;\n }\n});\n\ntest(\"If a Store property exists on an Ember.Application, it should be instantiated.\", function() {\n ok(container.lookup('store:main') instanceof DS.Store, \"the store was instantiated\");\n});\n\ntest(\"If a store is instantiated, it should be made available to each controller.\", function() {\n var fooController = container.lookup('controller:foo');\n ok(fooController.get('store') instanceof DS.Store, \"the store was injected\");\n});\n\ntest(\"the DS namespace should be accessible\", function() {\n ok(Ember.Namespace.byName('DS') instanceof Ember.Namespace, \"the DS namespace is accessible\");\n});\n\ntest(\"the deprecated serializer:_default is resolved as serializer:default\", function(){\n var deprecated = container.lookup('serializer:_default'),\n valid = container.lookup('serializer:-default');\n\n ok(deprecated === valid, \"they should resolve to the same thing\");\n});\n\ntest(\"the deprecated serializer:_rest is resolved as serializer:rest\", function(){\n var deprecated = container.lookup('serializer:_rest'),\n valid = container.lookup('serializer:-rest');\n\n ok(deprecated === valid, \"they should resolve to the same thing\");\n});\n\ntest(\"the deprecated adapter:_rest is resolved as adapter:rest\", function(){\n var deprecated = container.lookup('adapter:_rest'),\n valid = container.lookup('adapter:-rest');\n\n ok(deprecated === valid, \"they should resolve to the same thing\");\n});\n\ntest(\"a deprecation is made when looking up adapter:_rest\", function(){\n expectDeprecation(function(){\n container.lookup('serializer:_default');\n },\"You tried to look up 'serializer:_default', but this has been deprecated in favor of 'serializer:-default'.\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/application_test");minispade.register('ember-data/~tests/integration/client_id_generation_test', "(function() {var get = Ember.get, set = Ember.set;\nvar serializer, adapter, store;\nvar Post, Comment, env;\n\nmodule(\"integration/client_id_generation - Client-side ID Generation\", {\n setup: function() {\n Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n\n Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n env = setupStore({\n post: Post,\n comment: Comment\n });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"If an adapter implements the `generateIdForRecord` method, the store should be able to assign IDs without saving to the persistence layer.\", function() {\n expect(6);\n\n var idCount = 1;\n\n env.adapter.generateIdForRecord = function(passedStore, record) {\n equal(env.store, passedStore, \"store is the first parameter\");\n\n return \"id-\" + idCount++;\n };\n\n env.adapter.createRecord = function(store, type, record) {\n if (type === Comment) {\n equal(get(record, 'id'), 'id-1', \"Comment passed to `createRecord` has 'id-1' assigned\");\n return Ember.RSVP.resolve();\n } else {\n equal(get(record, 'id'), 'id-2', \"Post passed to `createRecord` has 'id-2' assigned\");\n return Ember.RSVP.resolve();\n }\n };\n\n var comment = env.store.createRecord('comment');\n var post = env.store.createRecord('post');\n\n equal(get(comment, 'id'), 'id-1', \"comment is assigned id 'id-1'\");\n equal(get(post, 'id'), 'id-2', \"post is assigned id 'id-2'\");\n\n // Despite client-generated IDs, calling commit() on the store should still\n // invoke the adapter's `createRecord` method.\n comment.save();\n post.save();\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/client_id_generation_test");minispade.register('ember-data/~tests/integration/debug_adapter_test', "(function() {var App, store, debugAdapter, get = Ember.get;\n\nmodule(\"DS.DebugAdapter\", {\n setup: function() {\n Ember.run(function() {\n App = Ember.Application.create({\n toString: function() { return 'App'; }\n });\n\n App.Store = DS.Store.extend({\n adapter: DS.Adapter.extend()\n });\n\n App.Post = DS.Model.extend({\n title: DS.attr('string')\n });\n\n App.advanceReadiness();\n });\n\n store = App.__container__.lookup('store:main');\n debugAdapter = App.__container__.lookup('data-adapter:main');\n\n debugAdapter.reopen({\n getModelTypes: function() {\n return Ember.A([App.Post]);\n }\n });\n },\n teardown: function() {\n App.destroy();\n }\n});\n\ntest(\"Watching Model Types\", function() {\n expect(5);\n\n var added = function(types) {\n equal(types.length, 1);\n equal(types[0].name, 'App.Post');\n equal(types[0].count, 0);\n strictEqual(types[0].object, App.Post);\n };\n\n var updated = function(types) {\n equal(types[0].count, 1);\n };\n\n debugAdapter.watchModelTypes(added, updated);\n\n store.push('post', {id: 1, title: 'Post Title'});\n});\n\ntest(\"Watching Records\", function() {\n var post, args, record;\n\n Ember.run(function() {\n store.push('post', { id: '1', title: 'Clean Post'});\n });\n\n var callback = function() {\n args = arguments;\n };\n\n debugAdapter.watchRecords(App.Post, callback, callback, callback);\n\n equal(get(args[0], 'length'), 1);\n record = args[0][0];\n deepEqual(record.columnValues, { id: '1', title: 'Clean Post'} );\n deepEqual(record.filterValues, { isNew: false, isModified: false, isClean: true } );\n deepEqual(record.searchKeywords, ['1', 'Clean Post'] );\n deepEqual(record.color, 'black' );\n\n Ember.run(function() {\n post = store.find('post', 1);\n });\n\n Ember.run(function() {\n post.set('title', 'Modified Post');\n });\n\n record = args[0][0];\n deepEqual(record.columnValues, { id: '1', title: 'Modified Post'});\n deepEqual(record.filterValues, { isNew: false, isModified: true, isClean: false });\n deepEqual(record.searchKeywords, ['1', 'Modified Post'] );\n deepEqual(record.color, 'blue' );\n\n post = store.createRecord('post', { id: '2', title: 'New Post' });\n record = args[0][0];\n deepEqual(record.columnValues, { id: '2', title: 'New Post'});\n deepEqual(record.filterValues, { isNew: true, isModified: false, isClean: false });\n deepEqual(record.searchKeywords, ['2', 'New Post'] );\n deepEqual(record.color, 'green' );\n\n Ember.run(post, 'deleteRecord');\n\n var index = args[0];\n var count = args[1];\n equal(index, 1);\n equal(count, 1);\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/debug_adapter_test");minispade.register('ember-data/~tests/integration/filter_test', "(function() {var get = Ember.get, set = Ember.set;\nvar forEach = Ember.EnumerableUtils.forEach;\nvar indexOf = Ember.EnumerableUtils.indexOf;\n\nvar Person, store, env, array, recordArray;\n\nvar shouldContain = function(array, item) {\n ok(indexOf(array, item) !== -1, \"array should contain \"+item.get('name'));\n};\n\nvar shouldNotContain = function(array, item) {\n ok(indexOf(array, item) === -1, \"array should not contain \"+item.get('name'));\n};\n\nmodule(\"integration/filter - DS.Model updating\", {\n setup: function() {\n array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n Person = DS.Model.extend({ name: DS.attr('string') });\n\n env = setupStore({ person: Person });\n store = env.store;\n },\n teardown: function() {\n store.destroy();\n Person = null;\n array = null;\n }\n});\n\ntest(\"when a DS.Model updates its attributes, its changes affect its filtered Array membership\", function() {\n store.pushMany('person', array);\n\n var people = store.filter('person', function(hash) {\n if (hash.get('name').match(/Katz$/)) { return true; }\n });\n\n equal(get(people, 'length'), 1, \"precond - one item is in the RecordArray\");\n\n var person = people.objectAt(0);\n\n equal(get(person, 'name'), \"Scumbag Katz\", \"precond - the item is correct\");\n\n set(person, 'name', \"Yehuda Katz\");\n\n equal(get(people, 'length'), 1, \"there is still one item\");\n equal(get(person, 'name'), \"Yehuda Katz\", \"it has the updated item\");\n\n set(person, 'name', \"Yehuda Katz-Foo\");\n\n equal(get(people, 'length'), 0, \"there are now no items\");\n});\n\ntest(\"a record array can have a filter on it\", function() {\n store.pushMany('person', array);\n\n var recordArray = store.filter('person', function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n });\n\n equal(get(recordArray, 'length'), 2, \"The Record Array should have the filtered objects on it\");\n\n store.push('person', { id: 4, name: \"Scumbag Koz\" });\n\n equal(get(recordArray, 'length'), 3, \"The Record Array should be updated as new items are added to the store\");\n\n store.push('person', { id: 1, name: \"Scumbag Tom\" });\n\n equal(get(recordArray, 'length'), 2, \"The Record Array should be updated as existing members are updated\");\n});\n\ntest(\"a filtered record array includes created elements\", function() {\n store.pushMany('person', array);\n\n var recordArray = store.filter('person', function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n });\n\n equal(get(recordArray, 'length'), 2, \"precond - The Record Array should have the filtered objects on it\");\n\n store.createRecord('person', { name: \"Scumbag Koz\" });\n\n equal(get(recordArray, 'length'), 3, \"The record array has the new object on it\");\n});\n\ntest(\"a Record Array can update its filter\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n deleteRecord: function(store, type, record) {\n return Ember.RSVP.resolve();\n }\n }));\n\n store.pushMany('person', array);\n\n var dickens = store.createRecord('person', { id: 4, name: \"Scumbag Dickens\" });\n dickens.deleteRecord();\n\n var asyncDale = store.find('person', 1);\n var asyncKatz = store.find('person', 2);\n var asyncBryn = store.find('person', 3);\n\n store.filter(Person, function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n }).then(async(function(recordArray) {\n\n Ember.RSVP.hash({ dale: asyncDale, katz: asyncKatz, bryn: asyncBryn }).then(async(function(records) {\n shouldContain(recordArray, records.dale);\n shouldContain(recordArray, records.katz);\n shouldNotContain(recordArray, records.bryn);\n shouldNotContain(recordArray, dickens);\n\n recordArray.set('filterFunction', function(hash) {\n if (hash.get('name').match(/Katz/)) { return true; }\n });\n\n equal(get(recordArray, 'length'), 1, \"The Record Array should have one object on it\");\n\n Ember.run(function() {\n store.push('person', { id: 5, name: \"Other Katz\" });\n });\n\n equal(get(recordArray, 'length'), 2, \"The Record Array now has the new object matching the filter\");\n\n Ember.run(function() {\n store.push('person', { id: 6, name: \"Scumbag Demon\" });\n });\n\n equal(get(recordArray, 'length'), 2, \"The Record Array doesn't have objects matching the old filter\");\n }));\n }));\n});\n\ntest(\"a Record Array can update its filter and notify array observers\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n deleteRecord: function(store, type, record) {\n return Ember.RSVP.resolve();\n }\n }));\n\n store.pushMany('person', array);\n\n var dickens = store.createRecord('person', { id: 4, name: \"Scumbag Dickens\" });\n dickens.deleteRecord();\n\n var asyncDale = store.find('person', 1);\n var asyncKatz = store.find('person', 2);\n var asyncBryn = store.find('person', 3);\n\n store.filter(Person, function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n }).then(async(function(recordArray) {\n\n var didChangeIdx, didChangeRemoved = 0, didChangeAdded = 0;\n\n var arrayObserver = {\n arrayWillChange: Ember.K,\n\n arrayDidChange: function(array, idx, removed, added) {\n didChangeIdx = idx;\n didChangeRemoved += removed;\n didChangeAdded += added;\n }\n };\n\n recordArray.addArrayObserver(arrayObserver);\n\n recordArray.set('filterFunction', function(hash) {\n if (hash.get('name').match(/Katz/)) { return true; }\n });\n\n Ember.RSVP.all([ asyncDale, asyncKatz, asyncBryn ]).then(async(function() {\n equal(didChangeRemoved, 1, \"removed one item from array\");\n didChangeRemoved = 0;\n\n Ember.run(function() {\n store.push('person', { id: 5, name: \"Other Katz\" });\n });\n\n equal(didChangeAdded, 1, \"one item was added\");\n didChangeAdded = 0;\n\n equal(recordArray.objectAt(didChangeIdx).get('name'), \"Other Katz\");\n\n Ember.run(function() {\n store.push('person', { id: 6, name: \"Scumbag Demon\" });\n });\n\n equal(didChangeAdded, 0, \"did not get called when an object that doesn't match is added\");\n\n Ember.run(function() {\n recordArray.set('filterFunction', function(hash) {\n if (hash.get('name').match(/Scumbag [KD]/)) { return true; }\n });\n });\n\n equal(didChangeAdded, 2, \"one item is added when going back\");\n equal(recordArray.objectAt(didChangeIdx).get('name'), \"Scumbag Demon\");\n equal(recordArray.objectAt(didChangeIdx-1).get('name'), \"Scumbag Dale\");\n }));\n }));\n});\n\ntest(\"it is possible to filter by computed properties\", function() {\n Person.reopen({\n name: DS.attr('string'),\n upperName: Ember.computed(function() {\n return this.get('name').toUpperCase();\n }).property('name')\n });\n\n var filter = store.filter('person', function(person) {\n return person.get('upperName') === \"TOM DALE\";\n });\n\n equal(filter.get('length'), 0, \"precond - the filter starts empty\");\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n\n equal(filter.get('length'), 1, \"the filter now has a record in it\");\n\n store.find('person', 1).then(async(function(person) {\n Ember.run(function() {\n person.set('name', \"Yehuda Katz\");\n });\n\n equal(filter.get('length'), 0, \"the filter is empty again\");\n }));\n});\n\ntest(\"a filter created after a record is already loaded works\", function() {\n Person.reopen({\n name: DS.attr('string'),\n upperName: Ember.computed(function() {\n return this.get('name').toUpperCase();\n }).property('name')\n });\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n\n var filter = store.filter('person', function(person) {\n return person.get('upperName') === \"TOM DALE\";\n });\n\n equal(filter.get('length'), 1, \"the filter now has a record in it\");\n asyncEqual(filter.objectAt(0), store.find('person', 1));\n});\n\ntest(\"it is possible to filter by state flags\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: id, name: \"Tom Dale\" });\n }\n }));\n\n var filter = store.filter(Person, function(person) {\n return person.get('isLoaded');\n });\n\n equal(filter.get('length'), 0, \"precond - there are no records yet\");\n\n Ember.run(function() {\n var asyncPerson = store.find('person', 1);\n\n // Ember.run will block `find` from being synchronously\n // resolved in test mode\n\n equal(filter.get('length'), 0, \"the unloaded record isn't in the filter\");\n\n asyncPerson.then(async(function(person) {\n equal(filter.get('length'), 1, \"the now-loaded record is in the filter\");\n asyncEqual(filter.objectAt(0), store.find('person', 1));\n }));\n });\n});\n\ntest(\"it is possible to filter loaded records by dirtiness\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n updateRecord: function() {\n return Ember.RSVP.resolve();\n }\n }));\n\n var filter = store.filter('person', function(person) {\n return !person.get('isDirty');\n });\n\n store.push('person', { id: 1, name: \"Tom Dale\" });\n\n store.find('person', 1).then(async(function(person) {\n equal(filter.get('length'), 1, \"the clean record is in the filter\");\n\n // Force synchronous update of the filter, even though\n // we're already inside a run loop\n Ember.run(function() {\n person.set('name', \"Yehuda Katz\");\n });\n\n equal(filter.get('length'), 0, \"the now-dirty record is not in the filter\");\n\n return person.save();\n })).then(async(function(person) {\n equal(filter.get('length'), 1, \"the clean record is back in the filter\");\n }));\n});\n\ntest(\"it is possible to filter created records by dirtiness\", function() {\n set(store, 'adapter', DS.Adapter.extend({\n createRecord: function() {\n return Ember.RSVP.resolve();\n }\n }));\n\n var filter = store.filter('person', function(person) {\n return !person.get('isDirty');\n });\n\n var person = store.createRecord('person', {\n id: 1,\n name: \"Tom Dale\"\n });\n\n equal(filter.get('length'), 0, \"the dirty record is not in the filter\");\n\n person.save().then(async(function(person) {\n equal(filter.get('length'), 1, \"the clean record is in the filter\");\n }));\n});\n\n\n// SERVER SIDE TESTS\nvar edited;\n\nvar clientEdits = function(ids) {\n edited = [];\n\n forEach(ids, function(id) {\n // wrap in an Ember.run to guarantee coalescence of the\n // iterated `set` calls and promise resolution.\n Ember.run(function() {\n store.find('person', id).then(function(person) {\n edited.push(person);\n person.set('name', 'Client-side ' + id );\n });\n });\n });\n};\n\nvar clientCreates = function(names) {\n edited = [];\n\n // wrap in an Ember.run to guarantee coalescence of the\n // iterated `set` calls.\n Ember.run( function() {\n forEach(names, function( name ) {\n edited.push(store.createRecord('person', { name: 'Client-side ' + name }));\n });\n });\n};\n\nvar serverResponds = function(){\n forEach(edited, function(person) { person.save(); });\n};\n\nvar setup = function(serverCallbacks) {\n set(store, 'adapter', DS.Adapter.extend(serverCallbacks));\n\n store.pushMany('person', array);\n\n recordArray = store.filter('person', function(hash) {\n if (hash.get('name').match(/Scumbag/)) { return true; }\n });\n\n equal(get(recordArray, 'length'), 3, \"The filter function should work\");\n};\n\ntest(\"a Record Array can update its filter after server-side updates one record\", function() {\n setup({\n updateRecord: function(store, type, record) {\n return Ember.RSVP.resolve({id: 1, name: \"Scumbag Server-side Dale\"});\n }\n });\n\n clientEdits([1]);\n equal(get(recordArray, 'length'), 2, \"The record array updates when the client changes records\");\n\n serverResponds();\n equal(get(recordArray, 'length'), 3, \"The record array updates when the server changes one record\");\n});\n\ntest(\"a Record Array can update its filter after server-side updates multiple records\", function() {\n setup({\n updateRecord: function(store, type, record) {\n switch (record.get('id')) {\n case \"1\":\n return Ember.RSVP.resolve({ id: 1, name: \"Scumbag Server-side Dale\" });\n case \"2\":\n return Ember.RSVP.resolve({ id: 2, name: \"Scumbag Server-side Katz\" });\n }\n }\n });\n\n clientEdits([1,2]);\n equal(get(recordArray, 'length'), 1, \"The record array updates when the client changes records\");\n\n serverResponds();\n equal(get(recordArray, 'length'), 3, \"The record array updates when the server changes multiple records\");\n});\n\ntest(\"a Record Array can update its filter after server-side creates one record\", function() {\n setup({\n createRecord: function(store, type, record) {\n return Ember.RSVP.resolve({id: 4, name: \"Scumbag Server-side Tim\"});\n }\n });\n\n clientCreates([\"Tim\"]);\n equal(get(recordArray, 'length'), 3, \"The record array does not include non-matching records\");\n\n serverResponds();\n equal(get(recordArray, 'length'), 4, \"The record array updates when the server creates a record\");\n});\n\ntest(\"a Record Array can update its filter after server-side creates multiple records\", function() {\n setup({\n createRecord: function(store, type, record) {\n switch (record.get('name')) {\n case \"Client-side Mike\":\n return Ember.RSVP.resolve({id: 4, name: \"Scumbag Server-side Mike\"});\n case \"Client-side David\":\n return Ember.RSVP.resolve({id: 5, name: \"Scumbag Server-side David\"});\n }\n }\n });\n\n clientCreates([\"Mike\", \"David\"]);\n equal(get(recordArray, 'length'), 3, \"The record array does not include non-matching records\");\n\n serverResponds();\n equal(get(recordArray, 'length'), 5, \"The record array updates when the server creates multiple records\");\n});\n\n\n})();\n//@ sourceURL=ember-data/~tests/integration/filter_test");minispade.register('ember-data/~tests/integration/lifecycle_hooks_test', "(function() {var Person, env;\nvar attr = DS.attr;\nvar resolve = Ember.RSVP.resolve;\n\nmodule(\"integration/lifecycle_hooks - Lifecycle Hooks\", {\n setup: function() {\n Person = DS.Model.extend({\n name: attr('string')\n });\n\n env = setupStore({\n person: Person\n });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\nasyncTest(\"When the adapter acknowledges that a record has been created, a `didCreate` event is triggered.\", function() {\n expect(3);\n\n env.adapter.createRecord = function(store, type, record) {\n return resolve({ id: 99, name: \"Yehuda Katz\" });\n };\n\n var person = env.store.createRecord(Person, { name: \"Yehuda Katz\" });\n\n person.on('didCreate', function() {\n equal(this, person, \"this is bound to the record\");\n equal(this.get('id'), \"99\", \"the ID has been assigned\");\n equal(this.get('name'), \"Yehuda Katz\", \"the attribute has been assigned\");\n start();\n });\n\n person.save();\n});\n\ntest(\"When the adapter acknowledges that a record has been created without a new data payload, a `didCreate` event is triggered.\", function() {\n expect(3);\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n var person = env.store.createRecord(Person, { id: 99, name: \"Yehuda Katz\" });\n\n person.on('didCreate', function() {\n equal(this, person, \"this is bound to the record\");\n equal(this.get('id'), \"99\", \"the ID has been assigned\");\n equal(this.get('name'), \"Yehuda Katz\", \"the attribute has been assigned\");\n });\n\n person.save();\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/lifecycle_hooks_test");minispade.register('ember-data/~tests/integration/records/collection_save_test', "(function() {var Comment, Post, env;\n\nmodule(\"integration/records/collection_save - Save Collection of Records\", {\n setup: function() {\n var Post = DS.Model.extend({\n title: DS.attr('string')\n });\n\n Post.toString = function() { return \"Post\"; };\n\n env = setupStore({ post: Post });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"Collection will resolve save on success\", function() {\n expect(1);\n env.store.createRecord('post', {title: 'Hello'});\n env.store.createRecord('post', {title: 'World'});\n\n var posts = env.store.all('post');\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.resolve({ id: 123 });\n };\n\n posts.save().then(async(function() {\n ok(true, 'save operation was resolved');\n }));\n});\n\ntest(\"Collection will reject save on error\", function() {\n env.store.createRecord('post', {title: 'Hello'});\n env.store.createRecord('post', {title: 'World'});\n\n var posts = env.store.all('post');\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n posts.save().then(function() {}, async(function() {\n ok(true, 'save operation was rejected');\n }));\n});\n\ntest(\"Retry is allowed in a failure handler\", function() {\n env.store.createRecord('post', {title: 'Hello'});\n env.store.createRecord('post', {title: 'World'});\n\n var posts = env.store.all('post');\n\n var count = 0;\n\n env.adapter.createRecord = function(store, type, record) {\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve({ id: 123 });\n }\n };\n\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.resolve({ id: 123 });\n };\n\n posts.save().then(function() {}, async(function() {\n return posts.save();\n })).then(async(function(post) {\n equal(posts.get('firstObject.id'), '123', \"The post ID made it through\");\n }));\n});\n\ntest(\"Collection will reject save on invalid\", function() {\n expect(1);\n env.store.createRecord('post', {title: 'Hello'});\n env.store.createRecord('post', {title: 'World'});\n\n var posts = env.store.all('post');\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject({ title: 'invalid' });\n };\n\n posts.save().then(function() {}, async(function() {\n ok(true, 'save operation was rejected');\n }));\n});\n})();\n//@ sourceURL=ember-data/~tests/integration/records/collection_save_test");minispade.register('ember-data/~tests/integration/records/delete_record_test', "(function() {var get = Ember.get, set = Ember.set;\nvar attr = DS.attr;\nvar Person, env;\n\nmodule(\"integration/deletedRecord - Deleting Records\", {\n setup: function() {\n Person = DS.Model.extend({\n name: attr('string')\n });\n\n Person.toString = function() { return \"Person\"; };\n\n env = setupStore({\n person: Person\n });\n },\n\n teardown: function() {\n Ember.run(function(){\n env.container.destroy();\n });\n }\n});\n\ntest(\"records can be deleted during record array enumeration\", function () {\n var adam = env.store.push('person', {id: 1, name: \"Adam Sunderland\"});\n var dave = env.store.push('person', {id: 2, name: \"Dave Sunderland\"});\n var all = env.store.all('person');\n\n // pre-condition\n equal(all.get('length'), 2, 'expected 2 records');\n\n Ember.run(function(){\n all.forEach(function(record) {\n record.deleteRecord();\n });\n });\n\n equal(all.get('length'), 0, 'expected 0 records');\n});\n\ntest(\"when deleted records are rolled back, they are still in their previous record arrays\", function () {\n var jaime = env.store.push('person', {id: 1, name: \"Jaime Lannister\"});\n var cersei = env.store.push('person', {id: 2, name: \"Cersei Lannister\"});\n var all = env.store.all('person');\n var filtered = env.store.filter('person', function () {\n return true;\n });\n\n equal(all.get('length'), 2, 'precond - we start with two people');\n equal(filtered.get('length'), 2, 'precond - we start with two people');\n\n Ember.run(function () {\n jaime.deleteRecord();\n jaime.rollback();\n });\n\n equal(all.get('length'), 2, 'record was not removed');\n equal(filtered.get('length'), 2, 'record was not removed');\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/records/delete_record_test");minispade.register('ember-data/~tests/integration/records/reload_test', "(function() {var get = Ember.get, set = Ember.set;\nvar attr = DS.attr;\nvar Person, env;\n\nmodule(\"integration/reload - Reloading Records\", {\n setup: function() {\n Person = DS.Model.extend({\n updatedAt: attr('string'),\n name: attr('string'),\n firstName: attr('string'),\n lastName: attr('string')\n });\n\n Person.toString = function() { return \"Person\"; };\n\n env = setupStore({ person: Person });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"When a single record is requested, the adapter's find method should be called unless it's loaded.\", function() {\n var count = 0;\n\n env.adapter.find = function(store, type, id) {\n if (count === 0) {\n count++;\n return Ember.RSVP.resolve({ id: id, name: \"Tom Dale\" });\n } else if (count === 1) {\n count++;\n return Ember.RSVP.resolve({ id: id, name: \"Braaaahm Dale\" });\n } else {\n ok(false, \"Should not get here\");\n }\n };\n\n env.store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is loaded with the right name\");\n equal(get(person, 'isLoaded'), true, \"The person is now loaded\");\n var promise = person.reload();\n equal(get(person, 'isReloading'), true, \"The person is now reloading\");\n return promise;\n })).then(async(function(person) {\n equal(get(person, 'isReloading'), false, \"The person is no longer reloading\");\n equal(get(person, 'name'), \"Braaaahm Dale\", \"The person is now updated with the right name\");\n }));\n});\n\ntest(\"When a record is reloaded and fails, it can try again\", function() {\n var tom = env.store.push('person', { id: 1, name: \"Tom Dale\" });\n\n var count = 0;\n env.adapter.find = function(store, type, id) {\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve({ id: 1, name: \"Thomas Dale\" });\n }\n };\n\n tom.reload().then(null, async(function() {\n equal(tom.get('isError'), true, \"Tom is now errored\");\n return tom.reload();\n })).then(async(function(person) {\n equal(person, tom, \"The resolved value is the record\");\n equal(tom.get('isError'), false, \"Tom is no longer errored\");\n equal(tom.get('name'), \"Thomas Dale\", \"the updates apply\");\n }));\n});\n\ntest(\"When a record is loaded a second time, isLoaded stays true\", function() {\n env.store.push('person', { id: 1, name: \"Tom Dale\" });\n\n env.store.find('person', 1).then(async(function(person) {\n equal(get(person, 'isLoaded'), true, \"The person is loaded\");\n person.addObserver('isLoaded', isLoadedDidChange);\n\n // Reload the record\n env.store.push('person', { id: 1, name: \"Tom Dale\" });\n equal(get(person, 'isLoaded'), true, \"The person is still loaded after load\");\n\n person.removeObserver('isLoaded', isLoadedDidChange);\n }));\n\n function isLoadedDidChange() {\n // This shouldn't be hit\n equal(get(this, 'isLoaded'), true, \"The person is still loaded after change\");\n }\n});\n\ntest(\"When a record is reloaded, its async hasMany relationships still work\", function() {\n env.container.register('model:person', DS.Model.extend({\n name: DS.attr(),\n tags: DS.hasMany('tag', { async: true })\n }));\n\n env.container.register('model:tag', DS.Model.extend({\n name: DS.attr()\n }));\n\n var tags = { 1: \"hipster\", 2: \"hair\" };\n\n env.adapter.find = function(store, type, id) {\n switch (type.typeKey) {\n case 'person':\n return Ember.RSVP.resolve({ id: 1, name: \"Tom\", tags: [1, 2] });\n case 'tag':\n return Ember.RSVP.resolve({ id: id, name: tags[id] });\n }\n };\n\n var tom;\n\n env.store.find('person', 1).then(async(function(person) {\n tom = person;\n equal(person.get('name'), \"Tom\", \"precond\");\n\n return person.get('tags');\n })).then(async(function(tags) {\n deepEqual(tags.mapBy('name'), [ 'hipster', 'hair' ]);\n\n return tom.reload();\n })).then(async(function(person) {\n equal(person.get('name'), \"Tom\", \"precond\");\n\n return person.get('tags');\n })).then(async(function(tags) {\n deepEqual(tags.mapBy('name'), [ 'hipster', 'hair' ], \"The tags are still there\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/records/reload_test");minispade.register('ember-data/~tests/integration/records/save_test', "(function() {var Comment, Post, env;\n\nmodule(\"integration/records/save - Save Record\", {\n setup: function() {\n var Post = DS.Model.extend({\n title: DS.attr('string')\n });\n\n Post.toString = function() { return \"Post\"; };\n\n env = setupStore({ post: Post });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"Will resolve save on success\", function() {\n expect(1);\n var post = env.store.createRecord('post', {title: 'toto'});\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.resolve({ id: 123 });\n };\n\n post.save().then(async(function() {\n ok(true, 'save operation was resolved');\n }));\n});\n\ntest(\"Will reject save on error\", function() {\n var post = env.store.createRecord('post', {title: 'toto'});\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n post.save().then(function() {}, async(function() {\n ok(true, 'save operation was rejected');\n }));\n});\n\ntest(\"Retry is allowed in a failure handler\", function() {\n var post = env.store.createRecord('post', {title: 'toto'});\n\n var count = 0;\n\n env.adapter.createRecord = function(store, type, record) {\n if (count++ === 0) {\n return Ember.RSVP.reject();\n } else {\n return Ember.RSVP.resolve({ id: 123 });\n }\n };\n\n post.save().then(function() {}, async(function() {\n return post.save();\n })).then(async(function(post) {\n equal(post.get('id'), '123', \"The post ID made it through\");\n }));\n});\n\ntest(\"Will reject save on invalid\", function() {\n expect(1);\n var post = env.store.createRecord('post', {title: 'toto'});\n\n env.adapter.createRecord = function(store, type, record) {\n return Ember.RSVP.reject({ title: 'invalid' });\n };\n\n post.save().then(function() {}, async(function() {\n ok(true, 'save operation was rejected');\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/records/save_test");minispade.register('ember-data/~tests/integration/records/unload_test', "(function() {var get = Ember.get, set = Ember.set;\nvar attr = DS.attr;\nvar Person, env;\n\nmodule(\"integration/unload - Unloading Records\", {\n setup: function() {\n Person = DS.Model.extend({\n name: attr('string')\n });\n\n Person.toString = function() { return \"Person\"; };\n\n env = setupStore({ person: Person });\n },\n\n teardown: function() {\n Ember.run(function(){\n env.container.destroy();\n });\n }\n});\n\ntest(\"can unload a single record\", function () {\n var adam = env.store.push('person', {id: 1, name: \"Adam Sunderland\"});\n\n Ember.run(function(){\n adam.unloadRecord();\n });\n\n equal(env.store.all('person').get('length'), 0);\n});\n\ntest(\"can unload all records for a given type\", function () {\n var adam = env.store.push('person', {id: 1, name: \"Adam Sunderland\"});\n var bob = env.store.push('person', {id: 2, name: \"Bob Bobson\"});\n\n Ember.run(function(){\n env.store.unloadAll('person');\n });\n\n equal(env.store.all('person').get('length'), 0);\n});\n\ntest(\"removes findAllCache after unloading all records\", function () {\n var adam = env.store.push('person', {id: 1, name: \"Adam Sunderland\"});\n var bob = env.store.push('person', {id: 2, name: \"Bob Bobson\"});\n\n Ember.run(function(){\n env.store.all('person');\n env.store.unloadAll('person');\n });\n\n equal(env.store.all('person').get('length'), 0);\n});\n\ntest(\"unloading all records also updates record array from all()\", function() {\n var adam = env.store.push('person', {id: 1, name: \"Adam Sunderland\"});\n var bob = env.store.push('person', {id: 2, name: \"Bob Bobson\"});\n var all = env.store.all('person');\n\n equal(all.get('length'), 2);\n\n Ember.run(function(){\n env.store.unloadAll('person');\n });\n\n equal(all.get('length'), 0);\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/records/unload_test");minispade.register('ember-data/~tests/integration/relationships/belongs_to_test', "(function() {var env, store, User, Message, Post, Comment;\nvar get = Ember.get, set = Ember.set;\n\nvar attr = DS.attr, hasMany = DS.hasMany, belongsTo = DS.belongsTo;\nvar resolve = Ember.RSVP.resolve, hash = Ember.RSVP.hash;\n\nfunction stringify(string) {\n return function() { return string; };\n}\n\nmodule(\"integration/relationship/belongs_to Belongs-To Relationships\", {\n setup: function() {\n User = DS.Model.extend({\n name: attr('string'),\n messages: hasMany('message', {polymorphic: true}),\n favouriteMessage: belongsTo('message', {polymorphic: true})\n });\n User.toString = stringify('User');\n\n Message = DS.Model.extend({\n user: belongsTo('user'),\n created_at: attr('date')\n });\n Message.toString = stringify('Message');\n\n Post = Message.extend({\n title: attr('string'),\n comments: hasMany('comment')\n });\n Post.toString = stringify('Post');\n\n Comment = Message.extend({\n body: DS.attr('string'),\n message: DS.belongsTo('message', { polymorphic: true })\n });\n Comment.toString = stringify('Comment');\n\n env = setupStore({\n user: User,\n post: Post,\n comment: Comment,\n message: Message\n });\n\n env.container.register('serializer:user', DS.JSONSerializer.extend({\n attrs: {\n favouriteMessage: { embedded: 'always' }\n }\n }));\n\n store = env.store;\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"The store can materialize a non loaded monomorphic belongsTo association\", function() {\n expect(1);\n\n env.store.modelFor('post').reopen({\n user: DS.belongsTo('user', { async: true })\n });\n\n env.adapter.find = function(store, type, id) {\n ok(true, \"The adapter's find method should be called\");\n return Ember.RSVP.resolve({ id: 1 });\n };\n\n env.store.push('post', { id: 1, user: 2});\n\n env.store.find('post', 1).then(async(function(post) {\n post.get('user');\n }));\n});\n\ntest(\"Only a record of the same type can be used with a monomorphic belongsTo relationship\", function() {\n expect(1);\n\n store.push('post', { id: 1 });\n store.push('comment', { id: 2 });\n\n hash({ post: store.find('post', 1), comment: store.find('comment', 2) }).then(async(function(records) {\n expectAssertion(function() {\n records.post.set('user', records.comment);\n }, /You can only add a 'user' record to this relationship/);\n }));\n});\n\ntest(\"Only a record of the same base type can be used with a polymorphic belongsTo relationship\", function() {\n expect(1);\n store.push('comment', { id: 1 });\n store.push('comment', { id: 2 });\n store.push('post', { id: 1 });\n store.push('user', { id: 3 });\n\n var asyncRecords = hash({\n user: store.find('user', 3),\n post: store.find('post', 1),\n comment: store.find('comment', 1),\n anotherComment: store.find('comment', 2)\n });\n\n asyncRecords.then(async(function(records) {\n var comment = records.comment;\n\n comment.set('message', records.anotherComment);\n comment.set('message', records.post);\n comment.set('message', null);\n\n expectAssertion(function() {\n comment.set('message', records.user);\n }, /You can only add a 'message' record to this relationship/);\n }));\n});\n\ntest(\"The store can load a polymorphic belongsTo association\", function() {\n env.store.push('post', { id: 1 });\n env.store.push('comment', { id: 2, message: 1, messageType: 'post' });\n\n hash({ message: store.find('post', 1), comment: store.find('comment', 2) }).then(async(function(records) {\n equal(records.comment.get('message'), records.message);\n }));\n});\n\ntest(\"The store can serialize a polymorphic belongsTo association\", function() {\n env.serializer.serializePolymorphicType = function(record, json, relationship) {\n ok(true, \"The serializer's serializePolymorphicType method should be called\");\n json[\"message_type\"] = \"post\";\n };\n env.store.push('post', { id: 1 });\n env.store.push('comment', { id: 2, message: 1, messageType: 'post' });\n\n store.find('comment', 2).then(async(function(comment) {\n var serialized = store.serialize(comment, { includeId: true });\n equal(serialized['message'], 1);\n equal(serialized['message_type'], 'post');\n }));\n});\n\ntest(\"A serializer can materialize a belongsTo as a link that gets sent back to findBelongsTo\", function() {\n var Group = DS.Model.extend({\n people: DS.hasMany()\n });\n\n var Person = DS.Model.extend({\n group: DS.belongsTo({ async: true })\n });\n\n env.container.register('model:group', Group);\n env.container.register('model:person', Person);\n\n store.push('person', { id: 1, links: { group: '/people/1/group' } });\n\n env.adapter.find = function() {\n throw new Error(\"Adapter's find method should not be called\");\n };\n\n env.adapter.findBelongsTo = async(function(store, record, link, relationship) {\n equal(relationship.type, Group);\n equal(relationship.key, 'group');\n equal(link, \"/people/1/group\");\n\n return Ember.RSVP.resolve({ id: 1, people: [1] });\n });\n\n env.store.find('person', 1).then(async(function(person) {\n return person.get('group');\n })).then(async(function(group) {\n ok(group instanceof Group, \"A group object is loaded\");\n ok(group.get('id') === '1', 'It is the group we are expecting');\n }));\n});\n\ntest('A record with an async belongsTo relationship always returns a promise for that relationship', function () {\n var Seat = DS.Model.extend({\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n seat: DS.belongsTo('seat', { async: true })\n });\n\n env.container.register('model:seat', Seat);\n env.container.register('model:person', Person);\n\n store.push('person', { id: 1, links: { seat: '/people/1/seat' } });\n\n env.adapter.find = function() {\n throw new Error(\"Adapter's find method should not be called\");\n };\n\n env.adapter.findBelongsTo = async(function(store, record, link, relationship) {\n return Ember.RSVP.resolve({ id: 1});\n });\n\n env.store.find('person', 1).then(async(function(person) {\n person.get('seat').then(async(function(seat) {\n // this assertion fails too\n // ok(seat.get('person') === person, 'parent relationship should be populated');\n seat.set('person', person);\n ok(person.get('seat').then, 'seat should be a PromiseObject');\n }));\n }));\n});\n\ntest(\"TODO (embedded): The store can load an embedded polymorphic belongsTo association\", function() {\n expect(0);\n //serializer.keyForEmbeddedType = function() {\n //return 'embeddedType';\n //};\n\n //adapter.load(store, App.User, { id: 2, favourite_message: { id: 1, embeddedType: 'comment'}});\n\n //var user = store.find(App.User, 2),\n //message = store.find(App.Comment, 1);\n\n //equal(user.get('favouriteMessage'), message);\n});\n\ntest(\"TODO (embedded): The store can serialize an embedded polymorphic belongsTo association\", function() {\n expect(0);\n //serializer.keyForEmbeddedType = function() {\n //return 'embeddedType';\n //};\n //adapter.load(store, App.User, { id: 2, favourite_message: { id: 1, embeddedType: 'comment'}});\n\n //var user = store.find(App.User, 2),\n //serialized = store.serialize(user, {includeId: true});\n\n //ok(serialized.hasOwnProperty('favourite_message'));\n //equal(serialized.favourite_message.id, 1);\n //equal(serialized.favourite_message.embeddedType, 'comment');\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/relationships/belongs_to_test");minispade.register('ember-data/~tests/integration/relationships/has_many_test', "(function() {var env, User, Contact, Email, Phone, Message, Post, Comment;\nvar get = Ember.get, set = Ember.set;\n\nvar attr = DS.attr, hasMany = DS.hasMany, belongsTo = DS.belongsTo;\n\nfunction stringify(string) {\n return function() { return string; };\n}\n\nmodule(\"integration/relationships/has_many - Has-Many Relationships\", {\n setup: function() {\n User = DS.Model.extend({\n name: attr('string'),\n messages: hasMany('message', { polymorphic: true }),\n contacts: hasMany()\n });\n\n Contact = DS.Model.extend({\n user: belongsTo('user')\n });\n\n Email = Contact.extend({\n email: attr('string')\n });\n\n Phone = Contact.extend({\n number: attr('string')\n });\n\n Message = DS.Model.extend({\n user: belongsTo('user'),\n created_at: attr('date')\n });\n Message.toString = stringify('Message');\n\n Post = Message.extend({\n title: attr('string'),\n comments: hasMany('comment')\n });\n Post.toString = stringify('Post');\n\n Comment = Message.extend({\n body: DS.attr('string'),\n message: DS.belongsTo('post', { polymorphic: true })\n });\n Comment.toString = stringify('Comment');\n\n env = setupStore({\n user: User,\n contact: Contact,\n email: Email,\n phone: Phone,\n post: Post,\n comment: Comment,\n message: Message\n });\n },\n\n teardown: function() {\n env.container.destroy();\n }\n});\n\ntest(\"When a hasMany relationship is accessed, the adapter's findMany method should not be called if all the records in the relationship are already loaded\", function() {\n expect(0);\n\n env.adapter.findMany = function() {\n ok(false, \"The adapter's find method should not be called\");\n };\n\n env.store.push('post', { id: 1, comments: [ 1 ] });\n env.store.push('comment', { id: 1 });\n\n env.store.find('post', 1).then(async(function(post) {\n post.get('comments');\n }));\n});\n\n// This tests the case where a serializer materializes a has-many\n// relationship as a reference that it can fetch lazily. The most\n// common use case of this is to provide a URL to a collection that\n// is loaded later.\ntest(\"A serializer can materialize a hasMany as an opaque token that can be lazily fetched via the adapter's findHasMany hook\", function() {\n Post.reopen({\n comments: DS.hasMany('comment', { async: true })\n });\n\n // When the store asks the adapter for the record with ID 1,\n // provide some fake data.\n env.adapter.find = function(store, type, id) {\n equal(type, Post, \"find type was Post\");\n equal(id, \"1\", \"find id was 1\");\n\n return Ember.RSVP.resolve({ id: 1, links: { comments: \"/posts/1/comments\" } });\n };\n\n env.adapter.findMany = function() {\n throw new Error(\"Adapter's findMany should not be called\");\n };\n\n env.adapter.findHasMany = function(store, record, link, relationship) {\n equal(relationship.type, Comment, \"findHasMany relationship type was Comment\");\n equal(relationship.key, 'comments', \"findHasMany relationship key was comments\");\n equal(link, \"/posts/1/comments\", \"findHasMany link was /posts/1/comments\");\n\n return Ember.RSVP.resolve([\n { id: 1, body: \"First\" },\n { id: 2, body: \"Second\" }\n ]);\n };\n\n env.store.find('post', 1).then(async(function(post) {\n return post.get('comments');\n })).then(async(function(comments) {\n equal(comments.get('isLoaded'), true, \"comments are loaded\");\n equal(comments.get('length'), 2, \"comments have 2 length\");\n }));\n});\n\ntest(\"An updated `links` value should invalidate a relationship cache\", function() {\n Post.reopen({\n comments: DS.hasMany('comment', { async: true })\n });\n\n env.adapter.createRecord = function(store, type, record) {\n var data = record.serialize();\n return Ember.RSVP.resolve({ id: 1, links: { comments: \"/posts/1/comments\" } });\n };\n\n env.adapter.findHasMany = function(store, record, link, relationship) {\n equal(relationship.type, Comment, \"findHasMany relationship type was Comment\");\n equal(relationship.key, 'comments', \"findHasMany relationship key was comments\");\n equal(link, \"/posts/1/comments\", \"findHasMany link was /posts/1/comments\");\n\n return Ember.RSVP.resolve([\n { id: 1, body: \"First\" },\n { id: 2, body: \"Second\" }\n ]);\n };\n\n env.store.createRecord('post', {}).save().then(async(function(post) {\n return post.get('comments');\n })).then(async(function(comments) {\n equal(comments.get('isLoaded'), true, \"comments are loaded\");\n equal(comments.get('length'), 2, \"comments have 2 length\");\n }));\n});\n\ntest(\"When a polymorphic hasMany relationship is accessed, the adapter's findMany method should not be called if all the records in the relationship are already loaded\", function() {\n expect(1);\n\n env.adapter.findMany = function() {\n ok(false, \"The adapter's find method should not be called\");\n };\n\n env.store.push('user', { id: 1, messages: [ {id: 1, type: 'post'}, {id: 3, type: 'comment'} ] });\n env.store.push('post', { id: 1 });\n env.store.push('comment', { id: 3 });\n\n env.store.find('user', 1).then(async(function(user) {\n var messages = user.get('messages');\n equal(messages.get('length'), 2, \"The messages are correctly loaded\");\n }));\n});\n\ntest(\"When a polymorphic hasMany relationship is accessed, the store can call multiple adapters' findMany method if the records are not loaded\", function() {\n User.reopen({\n messages: hasMany('message', { polymorphic: true, async: true })\n });\n\n env.adapter.findMany = function(store, type) {\n if (type === Post) {\n return Ember.RSVP.resolve([{ id: 1 }]);\n } else if (type === Comment) {\n return Ember.RSVP.resolve([{ id: 3 }]);\n }\n };\n\n env.store.push('user', { id: 1, messages: [ {id: 1, type: 'post'}, {id: 3, type: 'comment'} ] });\n\n env.store.find('user', 1).then(async(function(user) {\n return user.get('messages');\n })).then(async(function(messages) {\n equal(messages.get('length'), 2, \"The messages are correctly loaded\");\n }));\n});\n\ntest(\"Type can be inferred from the key of a hasMany relationship\", function() {\n expect(1);\n env.store.push('user', { id: 1, contacts: [ 1 ] });\n env.store.push('contact', { id: 1 });\n env.store.find('user', 1).then(async(function(user) {\n return user.get('contacts');\n })).then(async(function(contacts) {\n equal(contacts.get('length'), 1, \"The contacts relationship is correctly set up\");\n }));\n});\n\ntest(\"Type can be inferred from the key of an async hasMany relationship\", function() {\n User.reopen({\n contacts: DS.hasMany({ async: true })\n });\n\n expect(1);\n env.store.push('user', { id: 1, contacts: [ 1 ] });\n env.store.push('contact', { id: 1 });\n env.store.find('user', 1).then(async(function(user) {\n return user.get('contacts');\n })).then(async(function(contacts) {\n equal(contacts.get('length'), 1, \"The contacts relationship is correctly set up\");\n }));\n});\n\ntest(\"Polymorphic relationships work with a hasMany whose type is inferred\", function() {\n User.reopen({\n contacts: DS.hasMany({ polymorphic: true })\n });\n\n expect(1);\n env.store.push('user', { id: 1, contacts: [ { id: 1, type: 'email' }, { id: 2, type: 'phone' } ] });\n env.store.push('email', { id: 1 });\n env.store.push('phone', { id: 2 });\n env.store.find('user', 1).then(async(function(user) {\n return user.get('contacts');\n })).then(async(function(contacts) {\n equal(contacts.get('length'), 2, \"The contacts relationship is correctly set up\");\n }));\n});\n\ntest(\"A record can't be created from a polymorphic hasMany relationship\", function() {\n env.store.push('user', { id: 1, messages: [] });\n\n env.store.find('user', 1).then(async(function(user) {\n return user.get('messages');\n })).then(async(function(messages) {\n expectAssertion(function() {\n messages.createRecord();\n }, /You cannot add 'message' records to this polymorphic relationship/);\n }));\n});\n\ntest(\"Only records of the same type can be added to a monomorphic hasMany relationship\", function() {\n expect(1);\n env.store.push('post', { id: 1, comments: [] });\n env.store.push('post', { id: 2 });\n\n Ember.RSVP.all([ env.store.find('post', 1), env.store.find('post', 2) ]).then(async(function(records) {\n expectAssertion(function() {\n records[0].get('comments').pushObject(records[1]);\n }, /You cannot add 'post' records to this relationship/);\n }));\n\n});\n\ntest(\"Only records of the same base type can be added to a polymorphic hasMany relationship\", function() {\n expect(2);\n env.store.push('user', { id: 1, messages: [] });\n env.store.push('user', { id: 2, messages: [] });\n env.store.push('post', { id: 1, comments: [] });\n env.store.push('comment', { id: 3 });\n\n var asyncRecords = Ember.RSVP.hash({\n user: env.store.find('user', 1),\n anotherUser: env.store.find('user', 2),\n post: env.store.find('post', 1),\n comment: env.store.find('comment', 3)\n });\n\n asyncRecords.then(async(function(records) {\n records.messages = records.user.get('messages');\n return Ember.RSVP.hash(records);\n })).then(async(function(records) {\n records.messages.pushObject(records.post);\n records.messages.pushObject(records.comment);\n equal(records.messages.get('length'), 2, \"The messages are correctly added\");\n\n expectAssertion(function() {\n records.messages.pushObject(records.anotherUser);\n }, /You cannot add 'user' records to this relationship/);\n }));\n});\n\ntest(\"A record can be removed from a polymorphic association\", function() {\n expect(3);\n\n env.store.push('user', { id: 1 , messages: [{id: 3, type: 'comment'}]});\n env.store.push('comment', { id: 3 });\n\n var asyncRecords = Ember.RSVP.hash({\n user: env.store.find('user', 1),\n comment: env.store.find('comment', 3)\n });\n\n asyncRecords.then(async(function(records) {\n records.messages = records.user.get('messages');\n return Ember.RSVP.hash(records);\n })).then(async(function(records) {\n equal(records.messages.get('length'), 1, \"The user has 1 message\");\n\n var removedObject = records.messages.popObject();\n\n equal(removedObject, records.comment, \"The message is correctly removed\");\n equal(records.messages.get('length'), 0, \"The user does not have any messages\");\n }));\n});\n\ntest(\"When a record is created on the client, its hasMany arrays should be in a loaded state\", function() {\n expect(3);\n\n var post;\n\n Ember.run(function() {\n post = env.store.createRecord('post');\n });\n\n ok(get(post, 'isLoaded'), \"The post should have isLoaded flag\");\n\n var comments = get(post, 'comments');\n\n equal(get(comments, 'length'), 0, \"The comments should be an empty array\");\n\n ok(get(comments, 'isLoaded'), \"The comments should have isLoaded flag\");\n\n});\n\ntest(\"When a record is created on the client, its async hasMany arrays should be in a loaded state\", function() {\n expect(4);\n\n Post.reopen({\n comments: DS.hasMany('comment', { async: true })\n });\n\n var post;\n\n Ember.run(function() {\n post = env.store.createRecord('post');\n });\n\n ok(get(post, 'isLoaded'), \"The post should have isLoaded flag\");\n\n get(post, 'comments').then(function(comments) {\n ok(true, \"Comments array successfully resolves\");\n equal(get(comments, 'length'), 0, \"The comments should be an empty array\");\n ok(get(comments, 'isLoaded'), \"The comments should have isLoaded flag\");\n });\n\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/relationships/has_many_test");minispade.register('ember-data/~tests/integration/relationships/inverse_relationships_test', "(function() {var Post, Comment, Message, User, store, env;\n\nmodule('integration/relationships/inverse_relationships - Inverse Relationships');\n\ntest(\"When a record is added to a has-many relationship, the inverse belongsTo is determined automatically\", function() {\n Post = DS.Model.extend({\n comments: DS.hasMany('comment')\n });\n\n Comment = DS.Model.extend({\n post: DS.belongsTo('post')\n });\n\n var env = setupStore({ post: Post, comment: Comment }),\n store = env.store;\n\n var comment = store.createRecord('comment');\n var post = store.createRecord('post');\n\n equal(comment.get('post'), null, \"no post has been set on the comment\");\n\n post.get('comments').pushObject(comment);\n equal(comment.get('post'), post, \"post was set on the comment\");\n});\n\ntest(\"Inverse relationships can be explicitly nullable\", function () {\n User = DS.Model.extend();\n\n Post = DS.Model.extend({\n lastParticipant: DS.belongsTo(User, { inverse: null }),\n participants: DS.hasMany(User, { inverse: 'posts' })\n });\n\n User.reopen({\n posts: DS.hasMany(Post, { inverse: 'participants' })\n });\n\n equal(User.inverseFor('posts').name, 'participants', 'User.posts inverse is Post.participants');\n equal(Post.inverseFor('lastParticipant'), null, 'Post.lastParticipant has no inverse');\n equal(Post.inverseFor('participants').name, 'posts', 'Post.participants inverse is User.posts');\n});\n\ntest(\"When a record is added to a has-many relationship, the inverse belongsTo can be set explicitly\", function() {\n Post = DS.Model.extend({\n comments: DS.hasMany('comment', { inverse: 'redPost' })\n });\n\n Comment = DS.Model.extend({\n onePost: DS.belongsTo('post'),\n twoPost: DS.belongsTo('post'),\n redPost: DS.belongsTo('post'),\n bluePost: DS.belongsTo('post')\n });\n\n var env = setupStore({ post: Post, comment: Comment }),\n store = env.store;\n\n var comment = store.createRecord('comment');\n var post = store.createRecord('post');\n\n equal(comment.get('onePost'), null, \"onePost has not been set on the comment\");\n equal(comment.get('twoPost'), null, \"twoPost has not been set on the comment\");\n equal(comment.get('redPost'), null, \"redPost has not been set on the comment\");\n equal(comment.get('bluePost'), null, \"bluePost has not been set on the comment\");\n\n post.get('comments').pushObject(comment);\n\n equal(comment.get('onePost'), null, \"onePost has not been set on the comment\");\n equal(comment.get('twoPost'), null, \"twoPost has not been set on the comment\");\n equal(comment.get('redPost'), post, \"redPost has been set on the comment\");\n equal(comment.get('bluePost'), null, \"bluePost has not been set on the comment\");\n});\n\ntest(\"When a record's belongsTo relationship is set, it can specify the inverse hasMany to which the new child should be added\", function() {\n Post = DS.Model.extend({\n meComments: DS.hasMany('comment'),\n youComments: DS.hasMany('comment'),\n everyoneWeKnowComments: DS.hasMany('comment')\n });\n\n Comment = DS.Model.extend({\n post: DS.belongsTo('post', { inverse: 'youComments' })\n });\n\n var env = setupStore({ post: Post, comment: Comment }),\n store = env.store;\n\n var comment = store.createRecord('comment');\n var post = store.createRecord('post');\n\n equal(post.get('meComments.length'), 0, \"meComments has no posts\");\n equal(post.get('youComments.length'), 0, \"youComments has no posts\");\n equal(post.get('everyoneWeKnowComments.length'), 0, \"everyoneWeKnowComments has no posts\");\n\n comment.set('post', post);\n\n equal(post.get('meComments.length'), 0, \"meComments has no posts\");\n equal(post.get('youComments.length'), 1, \"youComments had the post added\");\n equal(post.get('everyoneWeKnowComments.length'), 0, \"everyoneWeKnowComments has no posts\");\n});\n\ntest(\"When a record is added to or removed from a polymorphic has-many relationship, the inverse belongsTo can be set explicitly\", function() {\n User = DS.Model.extend({\n messages: DS.hasMany('message', {\n inverse: 'redUser',\n polymorphic: true\n })\n });\n\n Message = DS.Model.extend({\n oneUser: DS.belongsTo('user'),\n twoUser: DS.belongsTo('user'),\n redUser: DS.belongsTo('user'),\n blueUser: DS.belongsTo('user')\n });\n\n Post = Message.extend();\n\n var env = setupStore({ user: User, message: Message, post: Post }),\n store = env.store;\n\n var post = store.createRecord('post');\n var user = store.createRecord('user');\n\n equal(post.get('oneUser'), null, \"oneUser has not been set on the user\");\n equal(post.get('twoUser'), null, \"twoUser has not been set on the user\");\n equal(post.get('redUser'), null, \"redUser has not been set on the user\");\n equal(post.get('blueUser'), null, \"blueUser has not been set on the user\");\n\n user.get('messages').pushObject(post);\n\n equal(post.get('oneUser'), null, \"oneUser has not been set on the user\");\n equal(post.get('twoUser'), null, \"twoUser has not been set on the user\");\n equal(post.get('redUser'), user, \"redUser has been set on the user\");\n equal(post.get('blueUser'), null, \"blueUser has not been set on the user\");\n\n user.get('messages').popObject();\n\n equal(post.get('oneUser'), null, \"oneUser has not been set on the user\");\n equal(post.get('twoUser'), null, \"twoUser has not been set on the user\");\n equal(post.get('redUser'), null, \"redUser has bot been set on the user\");\n equal(post.get('blueUser'), null, \"blueUser has not been set on the user\");\n});\n\ntest(\"When a record's belongsTo relationship is set, it can specify the inverse polymorphic hasMany to which the new child should be added or removed\", function() {\n User = DS.Model.extend({\n meMessages: DS.hasMany('message', { polymorphic: true }),\n youMessages: DS.hasMany('message', { polymorphic: true }),\n everyoneWeKnowMessages: DS.hasMany('message', { polymorphic: true })\n });\n\n Message = DS.Model.extend({\n user: DS.belongsTo('user', { inverse: 'youMessages' })\n });\n\n Post = Message.extend();\n\n var env = setupStore({ user: User, message: Message, post: Post }),\n store = env.store;\n\n var user = store.createRecord('user');\n var post = store.createRecord('post');\n\n equal(user.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(user.get('youMessages.length'), 0, \"youMessages has no posts\");\n equal(user.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n\n post.set('user', user);\n\n equal(user.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(user.get('youMessages.length'), 1, \"youMessages had the post added\");\n equal(user.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n\n post.set('user', null);\n\n equal(user.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(user.get('youMessages.length'), 0, \"youMessages has no posts\");\n equal(user.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n});\n\ntest(\"When a record's polymorphic belongsTo relationship is set, it can specify the inverse hasMany to which the new child should be added\", function() {\n Message = DS.Model.extend({\n meMessages: DS.hasMany('comment'),\n youMessages: DS.hasMany('comment'),\n everyoneWeKnowMessages: DS.hasMany('comment')\n });\n\n Post = Message.extend();\n\n Comment = Message.extend({\n message: DS.belongsTo('message', {\n polymorphic: true,\n inverse: 'youMessages'\n })\n });\n\n var env = setupStore({ comment: Comment, message: Message, post: Post }),\n store = env.store;\n\n var comment = store.createRecord('comment');\n var post = store.createRecord('post');\n\n equal(post.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(post.get('youMessages.length'), 0, \"youMessages has no posts\");\n equal(post.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n\n comment.set('message', post);\n\n equal(post.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(post.get('youMessages.length'), 1, \"youMessages had the post added\");\n equal(post.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n\n comment.set('message', null);\n\n equal(post.get('meMessages.length'), 0, \"meMessages has no posts\");\n equal(post.get('youMessages.length'), 0, \"youMessages has no posts\");\n equal(post.get('everyoneWeKnowMessages.length'), 0, \"everyoneWeKnowMessages has no posts\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/relationships/inverse_relationships_test");minispade.register('ember-data/~tests/integration/serializers/json_serializer_test', "(function() {var get = Ember.get, set = Ember.set;\nvar Post, post, Comment, comment, env;\n\nmodule(\"integration/serializer/json - JSONSerializer\", {\n setup: function() {\n Post = DS.Model.extend({\n title: DS.attr('string')\n });\n Comment = DS.Model.extend({\n body: DS.attr('string'),\n post: DS.belongsTo('post')\n });\n env = setupStore({\n post: Post,\n comment: Comment\n });\n env.store.modelFor('post');\n env.store.modelFor('comment');\n },\n\n teardown: function() {\n env.store.destroy();\n }\n});\n\ntest(\"serializeAttribute\", function() {\n post = env.store.createRecord(\"post\", { title: \"Rails is omakase\"});\n var json = {};\n\n env.serializer.serializeAttribute(post, json, \"title\", {type: \"string\"});\n\n deepEqual(json, {\n title: \"Rails is omakase\"\n });\n});\n\ntest(\"serializeAttribute respects keyForAttribute\", function() {\n env.container.register('serializer:post', DS.JSONSerializer.extend({\n keyForAttribute: function(key) {\n return key.toUpperCase();\n }\n }));\n\n post = env.store.createRecord(\"post\", { title: \"Rails is omakase\"});\n var json = {};\n\n env.container.lookup(\"serializer:post\").serializeAttribute(post, json, \"title\", {type: \"string\"});\n\n\n deepEqual(json, {\n TITLE: \"Rails is omakase\"\n });\n});\n\ntest(\"serializeBelongsTo\", function() {\n post = env.store.createRecord(Post, { title: \"Rails is omakase\", id: \"1\"});\n comment = env.store.createRecord(Comment, { body: \"Omakase is delicious\", post: post});\n var json = {};\n\n env.serializer.serializeBelongsTo(comment, json, {key: \"post\", options: {}});\n\n deepEqual(json, {\n post: \"1\"\n });\n\n json = {};\n\n set(comment, 'post', null);\n\n env.serializer.serializeBelongsTo(comment, json, {key: \"post\", options: {}});\n\n deepEqual(json, {\n post: null\n }, \"Can set a belongsTo to a null value\");\n\n});\n\ntest(\"serializeBelongsTo respects keyForRelationship\", function() {\n env.container.register('serializer:post', DS.JSONSerializer.extend({\n keyForRelationship: function(key, type) {\n return key.toUpperCase();\n }\n }));\n post = env.store.createRecord(Post, { title: \"Rails is omakase\", id: \"1\"});\n comment = env.store.createRecord(Comment, { body: \"Omakase is delicious\", post: post});\n var json = {};\n\n env.container.lookup(\"serializer:post\").serializeBelongsTo(comment, json, {key: \"post\", options: {}});\n\n deepEqual(json, {\n POST: \"1\"\n });\n});\n\ntest(\"serializePolymorphicType\", function() {\n env.container.register('serializer:comment', DS.JSONSerializer.extend({\n serializePolymorphicType: function(record, json, relationship) {\n var key = relationship.key,\n belongsTo = get(record, key);\n json[relationship.key + \"TYPE\"] = belongsTo.constructor.typeKey;\n }\n }));\n\n post = env.store.createRecord(Post, { title: \"Rails is omakase\", id: \"1\"});\n comment = env.store.createRecord(Comment, { body: \"Omakase is delicious\", post: post});\n var json = {};\n\n env.container.lookup(\"serializer:comment\").serializeBelongsTo(comment, json, {key: \"post\", options: { polymorphic: true}});\n\n deepEqual(json, {\n post: \"1\",\n postTYPE: \"post\"\n });\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/serializers/json_serializer_test");minispade.register('ember-data/~tests/integration/serializers/rest_serializer_test', "(function() {var get = Ember.get, set = Ember.set;\nvar HomePlanet, league, SuperVillain, superVillain, EvilMinion, YellowMinion, DoomsdayDevice, Comment, env;\n\nmodule(\"integration/serializer/rest - RESTSerializer\", {\n setup: function() {\n HomePlanet = DS.Model.extend({\n name: DS.attr('string'),\n superVillains: DS.hasMany('superVillain')\n });\n SuperVillain = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n homePlanet: DS.belongsTo(\"homePlanet\"),\n evilMinions: DS.hasMany(\"evilMinion\")\n });\n EvilMinion = DS.Model.extend({\n superVillain: DS.belongsTo('superVillain'),\n name: DS.attr('string')\n });\n YellowMinion = EvilMinion.extend();\n DoomsdayDevice = DS.Model.extend({\n name: DS.attr('string'),\n evilMinion: DS.belongsTo('evilMinion', {polymorphic: true})\n });\n Comment = DS.Model.extend({\n body: DS.attr('string'),\n root: DS.attr('boolean'),\n children: DS.hasMany('comment')\n });\n env = setupStore({\n superVillain: SuperVillain,\n homePlanet: HomePlanet,\n evilMinion: EvilMinion,\n yellowMinion: YellowMinion,\n doomsdayDevice: DoomsdayDevice,\n comment: Comment\n });\n env.store.modelFor('superVillain');\n env.store.modelFor('homePlanet');\n env.store.modelFor('evilMinion');\n env.store.modelFor('yellowMinion');\n env.store.modelFor('doomsdayDevice');\n env.store.modelFor('comment');\n },\n\n teardown: function() {\n env.store.destroy();\n }\n});\n\ntest(\"extractArray with custom typeForRoot\", function() {\n env.restSerializer.typeForRoot = function(root) {\n var camelized = Ember.String.camelize(root);\n return Ember.String.singularize(camelized);\n };\n\n var json_hash = {\n home_planets: [{id: \"1\", name: \"Umber\", superVillains: [1]}],\n super_villains: [{id: \"1\", firstName: \"Tom\", lastName: \"Dale\", homePlanet: \"1\"}]\n };\n\n var array = env.restSerializer.extractArray(env.store, HomePlanet, json_hash);\n\n deepEqual(array, [{\n \"id\": \"1\",\n \"name\": \"Umber\",\n \"superVillains\": [1]\n }]);\n\n env.store.find(\"superVillain\", 1).then(async(function(minion){\n equal(minion.get('firstName'), \"Tom\");\n }));\n});\n\ntest(\"extractArray failure with custom typeForRoot\", function() {\n env.restSerializer.typeForRoot = function(root) {\n //should be camelized too, but, whoops, the developer forgot!\n return Ember.String.singularize(root);\n };\n\n var json_hash = {\n home_planets: [{id: \"1\", name: \"Umber\", superVillains: [1]}],\n super_villains: [{id: \"1\", firstName: \"Tom\", lastName: \"Dale\", homePlanet: \"1\"}]\n };\n\n raises(function(){\n env.restSerializer.extractArray(env.store, HomePlanet, json_hash);\n }, \"No model was found for 'home_planets'\",\n \"raised error message expected to contain \\\"No model was found for 'home_planets'\\\"\");\n});\n\ntest(\"serialize polymorphicType\", function() {\n var tom = env.store.createRecord(YellowMinion, {name: \"Alex\", id: \"124\"});\n var ray = env.store.createRecord(DoomsdayDevice, {evilMinion: tom, name: \"DeathRay\"});\n\n var json = env.restSerializer.serialize(ray);\n\n deepEqual(json, {\n name: \"DeathRay\",\n evilMinionType: \"yellowMinion\",\n evilMinion: \"124\"\n });\n});\n\ntest(\"serialize polymorphicType with decamelized typeKey\", function() {\n YellowMinion.typeKey = 'yellow-minion';\n var tom = env.store.createRecord(YellowMinion, {name: \"Alex\", id: \"124\"});\n var ray = env.store.createRecord(DoomsdayDevice, {evilMinion: tom, name: \"DeathRay\"});\n\n var json = env.restSerializer.serialize(ray);\n\n deepEqual(json[\"evilMinionType\"], \"yellowMinion\");\n});\n\ntest(\"extractArray can load secondary records of the same type without affecting the query count\", function() {\n var json_hash = {\n comments: [{id: \"1\", body: \"Parent Comment\", root: true, children: [2, 3]}],\n _comments: [\n { id: \"2\", body: \"Child Comment 1\", root: false },\n { id: \"3\", body: \"Child Comment 2\", root: false }\n ]\n };\n\n var array = env.restSerializer.extractArray(env.store, Comment, json_hash);\n\n deepEqual(array, [{\n \"id\": \"1\",\n \"body\": \"Parent Comment\",\n \"root\": true,\n \"children\": [2, 3]\n }]);\n\n equal(array.length, 1, \"The query count is unaffected\");\n\n equal(env.store.recordForId(\"comment\", \"2\").get(\"body\"), \"Child Comment 1\", \"Secondary records are in the store\");\n equal(env.store.recordForId(\"comment\", \"3\").get(\"body\"), \"Child Comment 2\", \"Secondary records are in the store\");\n});\n\ntest(\"extractSingle loads secondary records with correct serializer\", function() {\n var superVillainNormalizeCount = 0;\n\n env.container.register('serializer:superVillain', DS.RESTSerializer.extend({\n normalize: function() {\n superVillainNormalizeCount++;\n return this._super.apply(this, arguments);\n }\n }));\n\n var json_hash = {\n evilMinion: {id: \"1\", name: \"Tom Dale\", superVillain: 1},\n superVillains: [{id: \"1\", firstName: \"Yehuda\", lastName: \"Katz\", homePlanet: \"1\"}]\n };\n\n var array = env.restSerializer.extractSingle(env.store, EvilMinion, json_hash);\n\n equal(superVillainNormalizeCount, 1, \"superVillain is normalized once\");\n});\n\ntest(\"extractArray loads secondary records with correct serializer\", function() {\n var superVillainNormalizeCount = 0;\n\n env.container.register('serializer:superVillain', DS.RESTSerializer.extend({\n normalize: function() {\n superVillainNormalizeCount++;\n return this._super.apply(this, arguments);\n }\n }));\n\n var json_hash = {\n evilMinions: [{id: \"1\", name: \"Tom Dale\", superVillain: 1}],\n superVillains: [{id: \"1\", firstName: \"Yehuda\", lastName: \"Katz\", homePlanet: \"1\"}]\n };\n\n var array = env.restSerializer.extractArray(env.store, EvilMinion, json_hash);\n\n equal(superVillainNormalizeCount, 1, \"superVillain is normalized once\");\n});\n\ntest('normalizeHash normalizes specific parts of the payload', function(){\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n normalizeHash: {\n homePlanets: function(hash) {\n hash.id = hash._id;\n delete hash._id;\n return hash;\n }\n }\n }));\n\n var jsonHash = { homePlanets: [{_id: \"1\", name: \"Umber\", superVillains: [1]}] };\n\n var array = env.restSerializer.extractArray(env.store, HomePlanet, jsonHash);\n\n deepEqual(array, [{\n \"id\": \"1\",\n \"name\": \"Umber\",\n \"superVillains\": [1]\n }]);\n});\n\ntest('normalizeHash works with transforms', function(){\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n normalizeHash: {\n evilMinions: function(hash) {\n hash.condition = hash._condition;\n delete hash._condition;\n return hash;\n }\n }\n }));\n\n env.container.register('transform:condition', DS.Transform.extend({\n deserialize: function(serialized) {\n if (serialized === 1) {\n return \"healing\";\n } else {\n return \"unknown\";\n }\n },\n serialize: function(deserialized) {\n if (deserialized === \"healing\") {\n return 1;\n } else {\n return 2;\n }\n }\n }));\n\n EvilMinion.reopen({ condition: DS.attr('condition') });\n\n var jsonHash = {\n evilMinions: [{id: \"1\", name: \"Tom Dale\", superVillain: 1, _condition: 1}]\n };\n\n var array = env.restSerializer.extractArray(env.store, EvilMinion, jsonHash);\n\n equal(array[0].condition, \"healing\");\n});\n\ntest('normalize should allow for different levels of normalization', function(){\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n attrs: {\n superVillain: 'is_super_villain'\n },\n keyForAttribute: function(attr) {\n return Ember.String.decamelize(attr);\n }\n }));\n\n var jsonHash = {\n evilMinions: [{id: \"1\", name: \"Tom Dale\", is_super_villain: 1}]\n };\n\n var array = env.restSerializer.extractArray(env.store, EvilMinion, jsonHash);\n\n equal(array[0].superVillain, 1);\n});\n\ntest(\"serializeIntoHash\", function() {\n league = env.store.createRecord(HomePlanet, { name: \"Umber\", id: \"123\" });\n var json = {};\n\n env.restSerializer.serializeIntoHash(json, HomePlanet, league);\n\n deepEqual(json, {\n homePlanet: {\n name: \"Umber\"\n }\n });\n});\n\ntest(\"serializeIntoHash with decamelized typeKey\", function() {\n HomePlanet.typeKey = 'home-planet';\n league = env.store.createRecord(HomePlanet, { name: \"Umber\", id: \"123\" });\n var json = {};\n\n env.restSerializer.serializeIntoHash(json, HomePlanet, league);\n\n deepEqual(json, {\n homePlanet: {\n name: \"Umber\"\n }\n });\n});\n\n})();\n//@ sourceURL=ember-data/~tests/integration/serializers/rest_serializer_test");minispade.register('ember-data/~tests/unit/adapters/rest_adapter/path_for_type_test', "(function() {var env, store, adapter;\nmodule(\"unit/adapters/rest_adapter/path_for_type - DS.RESTAdapter#pathForType\", {\n setup: function() {\n env = setupStore({\n adapter: DS.RESTAdapter\n });\n\n adapter = env.adapter;\n }\n});\n\ntest('pathForType - works with camelized types', function() {\n equal(adapter.pathForType('superUser'), \"superUsers\");\n});\n\ntest('pathForType - works with dasherized types', function() {\n equal(adapter.pathForType('super-user'), \"superUsers\");\n});\n\ntest('pathForType - works with underscored types', function() {\n equal(adapter.pathForType('super_user'), \"superUsers\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/adapters/rest_adapter/path_for_type_test");minispade.register('ember-data/~tests/unit/debug_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar store;\n\nvar TestAdapter = DS.Adapter.extend();\n\nmodule(\"Debug\", {\n setup: function() {\n store = DS.Store.create({\n adapter: TestAdapter.extend()\n });\n },\n\n teardown: function() {\n store.destroy();\n store = null;\n }\n});\n\ntest(\"_debugInfo groups the attributes and relationships correctly\", function() {\n var MaritalStatus = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Post = DS.Model.extend({\n title: DS.attr('string')\n });\n\n var User = DS.Model.extend({\n name: DS.attr('string'),\n isDrugAddict: DS.attr('boolean'),\n maritalStatus: DS.belongsTo(MaritalStatus),\n posts: DS.hasMany(Post)\n });\n\n var record = store.createRecord(User);\n\n var propertyInfo = record._debugInfo().propertyInfo;\n\n equal(propertyInfo.groups.length, 4);\n deepEqual(propertyInfo.groups[0].properties, ['id', 'name', 'isDrugAddict']);\n deepEqual(propertyInfo.groups[1].properties, ['maritalStatus']);\n deepEqual(propertyInfo.groups[2].properties, ['posts']);\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/debug_test");minispade.register('ember-data/~tests/unit/model/errors_test', "(function() {var errors;\n\nmodule(\"unit/model/errors\", {\n setup: function() {\n errors = DS.Errors.create();\n },\n\n teardown: function() {\n }\n});\n\nfunction becameInvalid(eventName) {\n if (eventName === 'becameInvalid') {\n ok(true, 'becameInvalid send');\n } else {\n ok(false, eventName + ' is send instead of becameInvalid');\n }\n}\n\nfunction becameValid(eventName) {\n if (eventName === 'becameValid') {\n ok(true, 'becameValid send');\n } else {\n ok(false, eventName + ' is send instead of becameValid');\n }\n}\n\nfunction unexpectedSend(eventName) {\n ok(false, 'unexpected send : ' + eventName);\n}\n\ntest(\"add error\", function() {\n expect(6);\n errors.trigger = becameInvalid;\n errors.add('firstName', 'error');\n errors.trigger = unexpectedSend;\n ok(errors.has('firstName'), 'it has firstName errors');\n equal(errors.get('length'), 1, 'it has 1 error');\n errors.add('firstName', ['error1', 'error2']);\n equal(errors.get('length'), 3, 'it has 3 errors');\n ok(!errors.get('isEmpty'), 'it is not empty');\n errors.add('lastName', 'error');\n errors.add('lastName', 'error');\n equal(errors.get('length'), 4, 'it has 4 errors');\n});\n\ntest(\"get error\", function() {\n expect(8);\n ok(errors.get('firstObject') === undefined, 'returns undefined');\n errors.trigger = becameInvalid;\n errors.add('firstName', 'error');\n errors.trigger = unexpectedSend;\n ok(errors.get('firstName').length === 1, 'returns errors');\n deepEqual(errors.get('firstObject'), {attribute: 'firstName', message: 'error'});\n errors.add('firstName', 'error2');\n ok(errors.get('firstName').length === 2, 'returns errors');\n errors.add('lastName', 'error3');\n deepEqual(errors.toArray(), [\n { attribute: 'firstName', message: 'error' },\n { attribute: 'firstName', message: 'error2' },\n { attribute: 'lastName', message: 'error3' }\n ]);\n deepEqual(errors.get('firstName'), [\n { attribute: 'firstName', message: 'error' },\n { attribute: 'firstName', message: 'error2' }\n ]);\n deepEqual(errors.get('messages'), ['error', 'error2', 'error3']);\n});\n\ntest(\"remove error\", function() {\n expect(5);\n errors.trigger = becameInvalid;\n errors.add('firstName', 'error');\n errors.trigger = becameValid;\n errors.remove('firstName');\n errors.trigger = unexpectedSend;\n ok(!errors.has('firstName'), 'it has no firstName errors');\n equal(errors.get('length'), 0, 'it has 0 error');\n ok(errors.get('isEmpty'), 'it is empty');\n errors.remove('firstName');\n});\n\ntest(\"remove same errors from different attributes\", function() {\n expect(5);\n errors.trigger = becameInvalid;\n errors.add('firstName', 'error');\n errors.add('lastName', 'error');\n errors.trigger = unexpectedSend;\n equal(errors.get('length'), 2, 'it has 2 error');\n errors.remove('firstName');\n equal(errors.get('length'), 1, 'it has 1 error');\n errors.trigger = becameValid;\n errors.remove('lastName');\n ok(errors.get('isEmpty'), 'it is empty');\n});\n\ntest(\"clear errors\", function() {\n expect(5);\n errors.trigger = becameInvalid;\n errors.add('firstName', ['error', 'error1']);\n equal(errors.get('length'), 2, 'it has 2 errors');\n errors.trigger = becameValid;\n errors.clear();\n errors.trigger = unexpectedSend;\n ok(!errors.has('firstName'), 'it has no firstName errors');\n equal(errors.get('length'), 0, 'it has 0 error');\n errors.clear();\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/errors_test");minispade.register('ember-data/~tests/unit/model/lifecycle_callbacks_test', "(function() {var get = Ember.get, set = Ember.set;\n\nmodule(\"unit/model/lifecycle_callbacks - Lifecycle Callbacks\");\n\ntest(\"a record receives a didLoad callback when it has finished loading\", function() {\n var Person = DS.Model.extend({\n name: DS.attr(),\n didLoad: function() {\n ok(\"The didLoad callback was called\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Foo\" });\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n store.find(Person, 1).then(async(function(person) {\n equal(person.get('id'), \"1\", \"The person's ID is available\");\n equal(person.get('name'), \"Foo\", \"The person's properties are available\");\n }));\n});\n\ntest(\"a record receives a didUpdate callback when it has finished updating\", function() {\n var callCount = 0;\n\n var Person = DS.Model.extend({\n bar: DS.attr('string'),\n\n didUpdate: function() {\n callCount++;\n equal(get(this, 'isSaving'), false, \"record should be saving\");\n equal(get(this, 'isDirty'), false, \"record should not be dirty\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Foo\" });\n },\n\n updateRecord: function(store, type, record) {\n equal(callCount, 0, \"didUpdate callback was not called until didSaveRecord is called\");\n\n return Ember.RSVP.resolve();\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n var asyncPerson = store.find(Person, 1);\n equal(callCount, 0, \"precond - didUpdate callback was not called yet\");\n\n asyncPerson.then(async(function(person) {\n person.set('bar', \"Bar\");\n return person.save();\n })).then(async(function() {\n equal(callCount, 1, \"didUpdate called after update\");\n }));\n});\n\ntest(\"a record receives a didCreate callback when it has finished updating\", function() {\n var callCount = 0;\n\n var Person = DS.Model.extend({\n didCreate: function() {\n callCount++;\n equal(get(this, 'isSaving'), false, \"record should not be saving\");\n equal(get(this, 'isDirty'), false, \"record should not be dirty\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n createRecord: function(store, type, record) {\n equal(callCount, 0, \"didCreate callback was not called until didSaveRecord is called\");\n\n return Ember.RSVP.resolve();\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n equal(callCount, 0, \"precond - didCreate callback was not called yet\");\n\n var person = store.createRecord(Person, { id: 69, name: \"Newt Gingrich\" });\n\n person.save().then(async(function() {\n equal(callCount, 1, \"didCreate called after commit\");\n }));\n});\n\ntest(\"a record receives a didDelete callback when it has finished deleting\", function() {\n var callCount = 0;\n\n var Person = DS.Model.extend({\n bar: DS.attr('string'),\n\n didDelete: function() {\n callCount++;\n\n equal(get(this, 'isSaving'), false, \"record should not be saving\");\n equal(get(this, 'isDirty'), false, \"record should not be dirty\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Foo\" });\n },\n\n deleteRecord: function(store, type, record) {\n equal(callCount, 0, \"didDelete callback was not called until didSaveRecord is called\");\n\n return Ember.RSVP.resolve();\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n var asyncPerson = store.find(Person, 1);\n equal(callCount, 0, \"precond - didDelete callback was not called yet\");\n\n asyncPerson.then(async(function(person) {\n person.deleteRecord();\n return person.save();\n })).then(async(function() {\n equal(callCount, 1, \"didDelete called after delete\");\n }));\n});\n\ntest(\"a record receives a becameInvalid callback when it became invalid\", function() {\n var callCount = 0;\n\n var Person = DS.Model.extend({\n bar: DS.attr('string'),\n\n becameInvalid: function() {\n callCount++;\n\n equal(get(this, 'isSaving'), false, \"record should not be saving\");\n equal(get(this, 'isDirty'), true, \"record should be dirty\");\n }\n });\n\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Foo\" });\n },\n\n updateRecord: function(store, type, record) {\n equal(callCount, 0, \"becameInvalid callback was not called until recordWasInvalid is called\");\n\n return Ember.RSVP.reject(new DS.InvalidError({ bar: 'error' }));\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n var asyncPerson = store.find(Person, 1);\n equal(callCount, 0, \"precond - becameInvalid callback was not called yet\");\n\n // Make sure that the error handler has a chance to attach before\n // save fails.\n Ember.run(function() {\n asyncPerson.then(async(function(person) {\n person.set('bar', \"Bar\");\n return person.save();\n })).then(null, async(function() {\n equal(callCount, 1, \"becameInvalid called after invalidating\");\n }));\n });\n});\n\ntest(\"an ID of 0 is allowed\", function() {\n var store = createStore();\n\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n store.push(Person, { id: 0, name: \"Tom Dale\" });\n equal(store.all(Person).objectAt(0).get('name'), \"Tom Dale\", \"found record with id 0\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/lifecycle_callbacks_test");minispade.register('ember-data/~tests/unit/model/merge_test', "(function() {var Person;\n\nmodule(\"unit/model/merge - Merging\", {\n setup: function() {\n Person = DS.Model.extend({\n name: DS.attr(),\n city: DS.attr()\n });\n },\n\n teardown: function() {\n\n }\n});\n\ntest(\"When a record is in flight, changes can be made\", function() {\n var adapter = DS.Adapter.extend({\n createRecord: function(store, type, record) {\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\" });\n }\n });\n\n var store = createStore({ adapter: adapter });\n\n var person = store.createRecord(Person, { name: \"Tom Dale\" });\n\n // Make sure saving isn't resolved synchronously\n Ember.run(function() {\n var promise = person.save();\n\n equal(person.get('name'), \"Tom Dale\");\n\n person.set('name', \"Thomas Dale\");\n\n promise.then(function(person) {\n equal(person.get('isDirty'), true, \"The person is still dirty\");\n equal(person.get('name'), \"Thomas Dale\", \"The changes made still apply\");\n });\n });\n});\n\ntest(\"When a record is in flight, pushes are applied underneath the in flight changes\", function() {\n var adapter = DS.Adapter.extend({\n updateRecord: function(store, type, record) {\n return Ember.RSVP.resolve({ id: 1, name: \"Senor Thomas Dale, Esq.\", city: \"Portland\" });\n }\n });\n\n var store = createStore({ adapter: adapter });\n\n var person = store.push(Person, { id: 1, name: \"Tom\" });\n person.set('name', \"Thomas Dale\");\n\n // Make sure saving isn't resolved synchronously\n Ember.run(function() {\n var promise = person.save();\n\n equal(person.get('name'), \"Thomas Dale\");\n\n person.set('name', \"Tomasz Dale\");\n\n store.push(Person, { id: 1, name: \"Tommy Dale\", city: \"PDX\" });\n\n equal(person.get('name'), \"Tomasz Dale\", \"the local changes applied on top\");\n equal(person.get('city'), \"PDX\", \"the pushed change is available\");\n\n promise.then(function(person) {\n equal(person.get('isDirty'), true, \"The person is still dirty\");\n equal(person.get('name'), \"Tomasz Dale\", \"The local changes apply\");\n equal(person.get('city'), \"Portland\", \"The updates from the server apply on top of the previous pushes\");\n });\n });\n});\n\ntest(\"When a record is dirty, pushes are overridden by local changes\", function() {\n var store = createStore({ adapter: DS.Adapter });\n\n var person = store.push(Person, { id: 1, name: \"Tom Dale\", city: \"San Francisco\" });\n\n person.set('name', \"Tomasz Dale\");\n\n equal(person.get('isDirty'), true, \"the person is currently dirty\");\n equal(person.get('name'), \"Tomasz Dale\", \"the update was effective\");\n equal(person.get('city'), \"San Francisco\", \"the original data applies\");\n\n store.push(Person, { id: 1, name: \"Thomas Dale\", city: \"Portland\" });\n\n equal(person.get('isDirty'), true, \"the local changes are reapplied\");\n equal(person.get('name'), \"Tomasz Dale\", \"the local changes are reapplied\");\n equal(person.get('city'), \"Portland\", \"if there are no local changes, the new data applied\");\n});\n\ntest(\"A record with no changes can still be saved\", function() {\n var adapter = DS.Adapter.extend({\n updateRecord: function(store, type, record) {\n return Ember.RSVP.resolve({ id: 1, name: \"Thomas Dale\" });\n }\n });\n\n var store = createStore({ adapter: adapter });\n\n var person = store.push(Person, { id: 1, name: \"Tom Dale\" });\n\n person.save().then(async(function() {\n equal(person.get('name'), \"Thomas Dale\", \"the updates occurred\");\n }));\n});\n\ntest(\"A dirty record can be reloaded\", function() {\n var adapter = DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"Thomas Dale\", city: \"Portland\" });\n }\n });\n\n var store = createStore({ adapter: adapter });\n\n var person = store.push(Person, { id: 1, name: \"Tom Dale\" });\n\n person.set('name', \"Tomasz Dale\");\n\n person.reload().then(async(function() {\n equal(person.get('isDirty'), true, \"the person is dirty\");\n equal(person.get('name'), \"Tomasz Dale\", \"the local changes remain\");\n equal(person.get('city'), \"Portland\", \"the new changes apply\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/merge_test");minispade.register('ember-data/~tests/unit/model/relationships_test', "(function() {/*global Tag App*/\n\nvar get = Ember.get, set = Ember.set;\n\nmodule(\"unit/model/relationships - DS.Model\");\n\ntest(\"exposes a hash of the relationships on a model\", function() {\n var Occupation = DS.Model.extend();\n\n var Person = DS.Model.extend({\n occupations: DS.hasMany(Occupation)\n });\n\n Person.reopen({\n people: DS.hasMany(Person),\n parent: DS.belongsTo(Person)\n });\n\n var relationships = get(Person, 'relationships');\n deepEqual(relationships.get(Person), [\n { name: \"people\", kind: \"hasMany\" },\n { name: \"parent\", kind: \"belongsTo\" }\n ]);\n\n deepEqual(relationships.get(Occupation), [\n { name: \"occupations\", kind: \"hasMany\" }\n ]);\n});\n\nvar env;\nmodule(\"unit/model/relationships - DS.hasMany\", {\n setup: function() {\n env = setupStore();\n }\n});\n\ntest(\"hasMany handles pre-loaded relationships\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Pet = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag'),\n pets: DS.hasMany('pet')\n });\n\n env.container.register('model:tag', Tag);\n env.container.register('model:pet', Pet);\n env.container.register('model:person', Person);\n\n env.adapter.find = function(store, type, id) {\n if (type === Tag && id === '12') {\n return Ember.RSVP.resolve({ id: 12, name: \"oohlala\" });\n } else {\n ok(false, \"find() should not be called with these values\");\n }\n };\n\n var store = env.store;\n\n store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }]);\n store.pushMany('pet', [{ id: 4, name: \"fluffy\" }, { id: 7, name: \"snowy\" }, { id: 12, name: \"cerberus\" }]);\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [5] });\n store.push('person', { id: 2, name: \"Yehuda Katz\", tags: [12] });\n\n var wycats;\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n\n var tags = get(person, 'tags');\n equal(get(tags, 'length'), 1, \"the list of tags should have the correct length\");\n equal(get(tags.objectAt(0), 'name'), \"friendly\", \"the first tag should be a Tag\");\n\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [5, 2] });\n equal(tags, get(person, 'tags'), \"a relationship returns the same object every time\");\n equal(get(get(person, 'tags'), 'length'), 2, \"the length is updated after new data is loaded\");\n\n strictEqual(get(person, 'tags').objectAt(0), get(person, 'tags').objectAt(0), \"the returned object is always the same\");\n asyncEqual(get(person, 'tags').objectAt(0), store.find(Tag, 5), \"relationship objects are the same as objects retrieved directly\");\n\n store.push('person', { id: 3, name: \"KSelden\" });\n\n return store.find('person', 3);\n })).then(async(function(kselden) {\n equal(get(get(kselden, 'tags'), 'length'), 0, \"a relationship that has not been supplied returns an empty array\");\n\n store.push('person', { id: 4, name: \"Cyvid Hamluck\", pets: [4] });\n return store.find('person', 4);\n })).then(async(function(cyvid) {\n equal(get(cyvid, 'name'), \"Cyvid Hamluck\", \"precond - retrieves person record from store\");\n\n var pets = get(cyvid, 'pets');\n equal(get(pets, 'length'), 1, \"the list of pets should have the correct length\");\n equal(get(pets.objectAt(0), 'name'), \"fluffy\", \"the first pet should be correct\");\n\n store.push(Person, { id: 4, name: \"Cyvid Hamluck\", pets: [4, 12] });\n equal(pets, get(cyvid, 'pets'), \"a relationship returns the same object every time\");\n equal(get(get(cyvid, 'pets'), 'length'), 2, \"the length is updated after new data is loaded\");\n }));\n});\n\ntest(\"hasMany lazily loads async relationships\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Pet = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag', { async: true }),\n pets: DS.hasMany('pet')\n });\n\n env.container.register('model:tag', Tag);\n env.container.register('model:pet', Pet);\n env.container.register('model:person', Person);\n\n env.adapter.find = function(store, type, id) {\n if (type === Tag && id === '12') {\n return Ember.RSVP.resolve({ id: 12, name: \"oohlala\" });\n } else {\n ok(false, \"find() should not be called with these values\");\n }\n };\n\n var store = env.store;\n\n store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }]);\n store.pushMany('pet', [{ id: 4, name: \"fluffy\" }, { id: 7, name: \"snowy\" }, { id: 12, name: \"cerberus\" }]);\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [5] });\n store.push('person', { id: 2, name: \"Yehuda Katz\", tags: [12] });\n\n var wycats;\n\n store.find('person', 2).then(async(function(person) {\n wycats = person;\n\n equal(get(wycats, 'name'), \"Yehuda Katz\", \"precond - retrieves person record from store\");\n\n return Ember.RSVP.hash({\n wycats: wycats,\n tags: wycats.get('tags')\n });\n })).then(async(function(records) {\n equal(get(records.tags, 'length'), 1, \"the list of tags should have the correct length\");\n equal(get(records.tags.objectAt(0), 'name'), \"oohlala\", \"the first tag should be a Tag\");\n\n strictEqual(records.tags.objectAt(0), records.tags.objectAt(0), \"the returned object is always the same\");\n asyncEqual(records.tags.objectAt(0), store.find(Tag, 12), \"relationship objects are the same as objects retrieved directly\");\n\n return get(wycats, 'tags');\n })).then(async(function(tags) {\n var newTag = store.createRecord(Tag);\n tags.pushObject(newTag);\n }));\n});\n\ntest(\"should be able to retrieve the type for a hasMany relationship from its metadata\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany(Tag)\n });\n\n equal(Person.typeForRelationship('tags'), Tag, \"returns the relationship type\");\n});\n\ntest(\"should be able to retrieve the type for a hasMany relationship specified using a string from its metadata\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var env = setupStore({\n tag: Tag,\n person: Person\n });\n\n equal(env.store.modelFor('person').typeForRelationship('tags'), Tag, \"returns the relationship type\");\n});\n\ntest(\"should be able to retrieve the type for a belongsTo relationship from its metadata\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.belongsTo('tag')\n });\n\n var env = setupStore({\n tag: Tag,\n person: Person\n });\n\n equal(env.store.modelFor('person').typeForRelationship('tags'), Tag, \"returns the relationship type\");\n});\n\ntest(\"should be able to retrieve the type for a belongsTo relationship specified using a string from its metadata\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.belongsTo('tag')\n });\n\n var env = setupStore({\n tag: Tag,\n person: Person\n });\n\n equal(env.store.modelFor('person').typeForRelationship('tags'), Tag, \"returns the relationship type\");\n});\n\ntest(\"relationships work when declared with a string path\", function() {\n window.App = {};\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var env = setupStore({\n person: Person,\n tag: Tag\n });\n\n env.store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }, { id: 12, name: \"oohlala\" }]);\n env.store.push('person', { id: 1, name: \"Tom Dale\", tags: [5, 2] });\n\n env.store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n equal(get(person, 'tags.length'), 2, \"the list of tags should have the correct length\");\n }));\n});\n\ntest(\"hasMany relationships work when the data hash has not been loaded\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n Tag.toString = function() { return \"Tag\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag', { async: true })\n });\n\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n env.adapter.findMany = function(store, type, ids) {\n equal(type, Tag, \"type should be Tag\");\n deepEqual(ids, ['5', '2'], \"ids should be 5 and 2\");\n\n return Ember.RSVP.resolve([{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }]);\n };\n\n env.adapter.find = function(store, type, id) {\n equal(type, Person, \"type should be Person\");\n equal(id, 1, \"id should be 1\");\n\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", tags: [5, 2] });\n };\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is now populated\");\n\n return person.get('tags');\n })).then(async(function(tags) {\n equal(get(tags, 'length'), 2, \"the tags object still exists\");\n equal(get(tags.objectAt(0), 'name'), \"friendly\", \"Tom Dale is now friendly\");\n equal(get(tags.objectAt(0), 'isLoaded'), true, \"Tom Dale is now loaded\");\n }));\n});\n\ntest(\"it is possible to add a new item to a relationship\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n people: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var env = setupStore({\n tag: Tag,\n person: Person\n });\n\n var store = env.store;\n\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [ 1 ] });\n store.push('tag', { id: 1, name: \"ember\" });\n\n store.find(Person, 1).then(async(function(person) {\n var tag = get(person, 'tags').objectAt(0);\n\n equal(get(tag, 'name'), \"ember\", \"precond - relationships work\");\n\n tag = store.createRecord(Tag, { name: \"js\" });\n get(person, 'tags').pushObject(tag);\n\n equal(get(person, 'tags').objectAt(1), tag, \"newly added relationship works\");\n }));\n});\n\ntest(\"it is possible to remove an item from a relationship\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.push('person', { id: 1, name: \"Tom Dale\", tags: [ 1 ] });\n store.push('tag', { id: 1, name: \"ember\" });\n\n store.find('person', 1).then(async(function(person) {\n var tag = get(person, 'tags').objectAt(0);\n\n equal(get(tag, 'name'), \"ember\", \"precond - relationships work\");\n\n get(person, 'tags').removeObject(tag);\n\n equal(get(person, 'tags.length'), 0, \"object is removed from the relationship\");\n }));\n});\n\ntest(\"it is possible to add an item to a relationship, remove it, then add it again\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n Tag.toString = function() { return \"Tag\"; };\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n var person = store.createRecord('person');\n var tag1 = store.createRecord('tag');\n var tag2 = store.createRecord('tag');\n var tag3 = store.createRecord('tag');\n\n var tags = get(person, 'tags');\n\n tags.pushObjects([tag1, tag2, tag3]);\n tags.removeObject(tag2);\n equal(tags.objectAt(0), tag1);\n equal(tags.objectAt(1), tag3);\n equal(get(person, 'tags.length'), 2, \"object is removed from the relationship\");\n\n tags.insertAt(0, tag2);\n equal(get(person, 'tags.length'), 3, \"object is added back to the relationship\");\n equal(tags.objectAt(0), tag2);\n equal(tags.objectAt(1), tag1);\n equal(tags.objectAt(2), tag3);\n});\n\nmodule(\"unit/model/relationships - RecordArray\");\n\ntest(\"updating the content of a RecordArray updates its content\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var env = setupStore({ tag: Tag }),\n store = env.store;\n\n var records = store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }, { id: 12, name: \"oohlala\" }]);\n\n var tags = DS.RecordArray.create({ content: Ember.A(records.slice(0, 2)), store: store, type: Tag });\n\n var tag = tags.objectAt(0);\n equal(get(tag, 'name'), \"friendly\", \"precond - we're working with the right tags\");\n\n set(tags, 'content', Ember.A(records.slice(1, 3)));\n tag = tags.objectAt(0);\n equal(get(tag, 'name'), \"smarmy\", \"the lookup was updated\");\n});\n\ntest(\"can create child record from a hasMany relationship\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tags: DS.hasMany('tag')\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.push('person', { id: 1, name: \"Tom Dale\"});\n\n store.find('person', 1).then(async(function(person) {\n person.get(\"tags\").createRecord({ name: \"cool\" });\n\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n equal(get(person, 'tags.length'), 1, \"tag is added to the parent record\");\n equal(get(person, 'tags').objectAt(0).get(\"name\"), \"cool\", \"tag values are passed along\");\n }));\n});\n\nmodule(\"unit/model/relationships - DS.belongsTo\");\n\ntest(\"belongsTo lazily loads relationships as needed\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n people: DS.hasMany('person')\n });\n Tag.toString = function() { return \"Tag\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag')\n });\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.pushMany('tag', [{ id: 5, name: \"friendly\" }, { id: 2, name: \"smarmy\" }, { id: 12, name: \"oohlala\" }]);\n store.push('person', { id: 1, name: \"Tom Dale\", tag: 5 });\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n\n equal(get(person, 'tag') instanceof Tag, true, \"the tag property should return a tag\");\n equal(get(person, 'tag.name'), \"friendly\", \"the tag shuld have name\");\n\n strictEqual(get(person, 'tag'), get(person, 'tag'), \"the returned object is always the same\");\n asyncEqual(get(person, 'tag'), store.find('tag', 5), \"relationship object is the same as object retrieved directly\");\n }));\n});\n\ntest(\"async belongsTo relationships work when the data hash has not been loaded\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag', { async: true })\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n env.adapter.find = function(store, type, id) {\n if (type === Person) {\n equal(id, 1, \"id should be 1\");\n\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", tag: 2 });\n } else if (type === Tag) {\n equal(id, 2, \"id should be 2\");\n\n return Ember.RSVP.resolve({ id: 2, name: \"friendly\" });\n }\n };\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is now populated\");\n\n return get(person, 'tag');\n })).then(async(function(tag) {\n equal(get(tag, 'name'), \"friendly\", \"Tom Dale is now friendly\");\n equal(get(tag, 'isLoaded'), true, \"Tom Dale is now loaded\");\n }));\n});\n\ntest(\"async belongsTo relationships work when the data hash has already been loaded\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag', { async: true })\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.push('tag', { id: 2, name: \"friendly\"});\n store.push('person', { id: 1, name: \"Tom Dale\", tag: 2});\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is now populated\");\n return get(person, 'tag');\n })).then(async(function(tag) {\n equal(get(tag, 'name'), \"friendly\", \"Tom Dale is now friendly\");\n equal(get(tag, 'isLoaded'), true, \"Tom Dale is now loaded\");\n }));\n});\n\ntest(\"calling createRecord and passing in an undefined value for a relationship should be treated as if null\", function () {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag')\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.createRecord('person', {id: 1, tag: undefined});\n\n store.find(Person, 1).then(async(function(person) {\n strictEqual(person.get('tag'), null, \"undefined values should return null relationships\");\n }));\n});\n\ntest(\"findMany is passed the owner record for adapters when some of the object graph is already loaded\", function() {\n var Occupation = DS.Model.extend({\n description: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n Occupation.toString = function() { return \"Occupation\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n occupations: DS.hasMany('occupation', { async: true })\n });\n\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ occupation: Occupation, person: Person }),\n store = env.store;\n\n env.adapter.findMany = function(store, type, ids, owner) {\n equal(type, Occupation, \"type should be Occupation\");\n deepEqual(ids, ['5', '2'], \"ids should be 5 and 2\");\n equal(get(owner, 'id'), 1, \"the owner record id should be 1\");\n\n return Ember.RSVP.resolve([{ id: 5, description: \"fifth\" }, { id: 2, description: \"second\" }]);\n };\n\n store.push('person', { id: 1, name: \"Tom Dale\", occupations: [5, 2] });\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'isLoaded'), true, \"isLoaded should be true\");\n equal(get(person, 'name'), \"Tom Dale\", \"the person is still Tom Dale\");\n\n return get(person, 'occupations');\n })).then(async(function(occupations) {\n equal(get(occupations, 'length'), 2, \"the list of occupations should have the correct length\");\n\n equal(get(occupations.objectAt(0), 'description'), \"fifth\", \"the occupation is the fifth\");\n equal(get(occupations.objectAt(0), 'isLoaded'), true, \"the occupation is now loaded\");\n }));\n});\n\ntest(\"findMany is passed the owner record for adapters when none of the object graph is loaded\", function() {\n var Occupation = DS.Model.extend({\n description: DS.attr('string'),\n person: DS.belongsTo('person')\n });\n\n Occupation.toString = function() { return \"Occupation\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n occupations: DS.hasMany('occupation', { async: true })\n });\n\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ occupation: Occupation, person: Person }),\n store = env.store;\n\n env.adapter.findMany = function(store, type, ids, owner) {\n equal(type, Occupation, \"type should be Occupation\");\n deepEqual(ids, ['5', '2'], \"ids should be 5 and 2\");\n equal(get(owner, 'id'), 1, \"the owner record id should be 1\");\n\n return Ember.RSVP.resolve([{ id: 5, description: \"fifth\" }, { id: 2, description: \"second\" }]);\n };\n\n env.adapter.find = function(store, type, id) {\n equal(type, Person, \"type should be Person\");\n equal(id, 1, \"id should be 1\");\n\n return Ember.RSVP.resolve({ id: 1, name: \"Tom Dale\", occupations: [5, 2] });\n };\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"The person is now populated\");\n\n return get(person, 'occupations');\n })).then(async(function(occupations) {\n equal(get(occupations, 'length'), 2, \"the occupation objects still exist\");\n equal(get(occupations.objectAt(0), 'description'), \"fifth\", \"the occupation is the fifth\");\n equal(get(occupations.objectAt(0), 'isLoaded'), true, \"the occupation is now loaded\");\n }));\n});\n\ntest(\"belongsTo supports relationships to models with id 0\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string'),\n people: DS.hasMany('person')\n });\n Tag.toString = function() { return \"Tag\"; };\n\n var Person = DS.Model.extend({\n name: DS.attr('string'),\n tag: DS.belongsTo('tag')\n });\n Person.toString = function() { return \"Person\"; };\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.pushMany('tag', [{ id: 0, name: \"friendly\" }, { id: 2, name: \"smarmy\" }, { id: 12, name: \"oohlala\" }]);\n store.push('person', { id: 1, name: \"Tom Dale\", tag: 0 });\n\n store.find('person', 1).then(async(function(person) {\n equal(get(person, 'name'), \"Tom Dale\", \"precond - retrieves person record from store\");\n\n equal(get(person, 'tag') instanceof Tag, true, \"the tag property should return a tag\");\n equal(get(person, 'tag.name'), \"friendly\", \"the tag should have name\");\n\n strictEqual(get(person, 'tag'), get(person, 'tag'), \"the returned object is always the same\");\n asyncEqual(get(person, 'tag'), store.find(Tag, 0), \"relationship object is the same as object retrieved directly\");\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/relationships_test");minispade.register('ember-data/~tests/unit/model/rollback_test', "(function() {var env, store, Person, Dog;\n\nmodule(\"unit/model/rollback - model.rollback()\", {\n setup: function() {\n Person = DS.Model.extend({\n firstName: DS.attr(),\n lastName: DS.attr()\n });\n\n env = setupStore({ person: Person });\n store = env.store;\n }\n});\n\ntest(\"changes to attributes can be rolled back\", function() {\n var person = store.push('person', { id: 1, firstName: \"Tom\", lastName: \"Dale\" });\n\n person.set('firstName', \"Thomas\");\n\n equal(person.get('firstName'), \"Thomas\");\n\n person.rollback();\n\n equal(person.get('firstName'), \"Tom\");\n equal(person.get('isDirty'), false);\n});\n\ntest(\"changes to attributes made after a record is in-flight only rolls back the local changes\", function() {\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.resolve();\n };\n\n var person = store.push('person', { id: 1, firstName: \"Tom\", lastName: \"Dale\" });\n\n person.set('firstName', \"Thomas\");\n\n // Make sure the save is async\n Ember.run(function() {\n var saving = person.save();\n\n equal(person.get('firstName'), \"Thomas\");\n\n person.set('lastName', \"Dolly\");\n\n equal(person.get('lastName'), \"Dolly\");\n\n person.rollback();\n\n equal(person.get('firstName'), \"Thomas\");\n equal(person.get('lastName'), \"Dale\");\n equal(person.get('isSaving'), true);\n\n saving.then(async(function() {\n equal(person.get('isDirty'), false, \"The person is now clean\");\n }));\n });\n});\n\ntest(\"a record's changes can be made if it fails to save\", function() {\n env.adapter.updateRecord = function(store, type, record) {\n return Ember.RSVP.reject();\n };\n\n var person = store.push('person', { id: 1, firstName: \"Tom\", lastName: \"Dale\" });\n\n person.set('firstName', \"Thomas\");\n\n person.save().then(null, async(function() {\n equal(person.get('isError'), true);\n\n person.rollback();\n\n equal(person.get('firstName'), \"Tom\");\n equal(person.get('isError'), false);\n }));\n});\n\ntest(\"new record can be rollbacked\", function() {\n var person = store.createRecord('person', { id: 1 });\n\n equal(person.get('isNew'), true, \"must be new\");\n equal(person.get('isDirty'), true, \"must be dirty\");\n\n Ember.run(person, 'rollback');\n\n equal(person.get('isNew'), false, \"must not be new\");\n equal(person.get('isDirty'), false, \"must not be dirty\");\n equal(person.get('isDeleted'), true, \"must be deleted\");\n});\n\ntest(\"deleted record can be rollbacked\", function() {\n var person = store.push('person', { id: 1 });\n\n person.deleteRecord();\n\n equal(person.get('isDeleted'), true, \"must be deleted\");\n\n person.rollback();\n\n equal(person.get('isDeleted'), false, \"must not be deleted\");\n equal(person.get('isDirty'), false, \"must not be dirty\");\n});\n\ntest(\"invalid record can be rollbacked\", function() {\n Dog = DS.Model.extend({\n name: DS.attr()\n });\n\n var adapter = DS.RESTAdapter.extend({\n ajax: function(url, type, hash) {\n var adapter = this;\n\n return new Ember.RSVP.Promise(function(resolve, reject) {\n Ember.run.next(function(){\n reject(adapter.ajaxError({name: 'is invalid'}));\n });\n });\n },\n\n ajaxError: function(jqXHR) {\n return new DS.InvalidError(jqXHR);\n }\n });\n\n env = setupStore({ dog: Dog, adapter: adapter});\n var dog = env.store.push('dog', { id: 1, name: \"Pluto\" });\n\n dog.set('name', \"is a dwarf planet\");\n\n dog.save().then(null, async(function() {\n dog.rollback();\n\n equal(dog.get('name'), \"Pluto\");\n ok(dog.get('isValid'));\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model/rollback_test");minispade.register('ember-data/~tests/unit/model_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar Person, store, array;\n\nmodule(\"unit/model - DS.Model\", {\n setup: function() {\n store = createStore();\n\n Person = DS.Model.extend({\n name: DS.attr('string'),\n isDrugAddict: DS.attr('boolean')\n });\n },\n\n teardown: function() {\n Person = null;\n store = null;\n }\n});\n\ntest(\"can have a property set on it\", function() {\n var record = store.createRecord(Person);\n set(record, 'name', 'bar');\n\n equal(get(record, 'name'), 'bar', \"property was set on the record\");\n});\n\ntest(\"setting a property on a record that has not changed does not cause it to become dirty\", function() {\n store.push(Person, { id: 1, name: \"Peter\", isDrugAddict: true });\n store.find(Person, 1).then(async(function(person) {\n equal(person.get('isDirty'), false, \"precond - person record should not be dirty\");\n person.set('name', \"Peter\");\n person.set('isDrugAddict', true);\n equal(person.get('isDirty'), false, \"record does not become dirty after setting property to old value\");\n }));\n});\n\ntest(\"resetting a property on a record cause it to become clean again\", function() {\n store.push(Person, { id: 1, name: \"Peter\", isDrugAddict: true });\n store.find(Person, 1).then(async(function(person) {\n equal(person.get('isDirty'), false, \"precond - person record should not be dirty\");\n person.set('isDrugAddict', false);\n equal(person.get('isDirty'), true, \"record becomes dirty after setting property to a new value\");\n person.set('isDrugAddict', true);\n equal(person.get('isDirty'), false, \"record becomes clean after resetting property to the old value\");\n }));\n});\n\ntest(\"a record reports its unique id via the `id` property\", function() {\n store.push(Person, { id: 1 });\n\n store.find(Person, 1).then(async(function(record) {\n equal(get(record, 'id'), 1, \"reports id as id by default\");\n }));\n});\n\ntest(\"a record's id is included in its toString representation\", function() {\n store.push(Person, { id: 1 });\n\n store.find(Person, 1).then(async(function(record) {\n equal(record.toString(), '<(subclass of DS.Model):'+Ember.guidFor(record)+':1>', \"reports id in toString\");\n }));\n});\n\ntest(\"trying to set an `id` attribute should raise\", function() {\n Person = DS.Model.extend({\n id: DS.attr('number'),\n name: \"Scumdale\"\n });\n\n expectAssertion(function() {\n store.push(Person, { id: 1, name: \"Scumdale\" });\n var person = store.find(Person, 1);\n }, /You may not set `id`/);\n});\n\ntest(\"it should use `_reference` and not `reference` to store its reference\", function() {\n store.push(Person, { id: 1 });\n\n store.find(Person, 1).then(async(function(record) {\n equal(record.get('reference'), undefined, \"doesn't shadow reference key\");\n }));\n});\n\ntest(\"it should cache attributes\", function() {\n var store = createStore();\n\n var Post = DS.Model.extend({\n updatedAt: DS.attr('string')\n });\n\n var dateString = \"Sat, 31 Dec 2011 00:08:16 GMT\";\n var date = new Date(dateString);\n\n store.push(Post, { id: 1 });\n\n store.find(Post, 1).then(async(function(record) {\n record.set('updatedAt', date);\n deepEqual(date, get(record, 'updatedAt'), \"setting a date returns the same date\");\n strictEqual(get(record, 'updatedAt'), get(record, 'updatedAt'), \"second get still returns the same object\");\n }));\n});\n\nmodule(\"unit/model - DS.Model updating\", {\n setup: function() {\n array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n Person = DS.Model.extend({ name: DS.attr('string') });\n store = createStore();\n store.pushMany(Person, array);\n },\n teardown: function() {\n Person = null;\n store = null;\n array = null;\n }\n});\n\ntest(\"a DS.Model can update its attributes\", function() {\n store.find(Person, 2).then(async(function(person) {\n set(person, 'name', \"Brohuda Katz\");\n equal(get(person, 'name'), \"Brohuda Katz\", \"setting took hold\");\n }));\n});\n\ntest(\"a DS.Model can have a defaultValue\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string', { defaultValue: \"unknown\" })\n });\n\n var tag = store.createRecord(Tag);\n\n equal(get(tag, 'name'), \"unknown\", \"the default value is found\");\n\n set(tag, 'name', null);\n\n equal(get(tag, 'name'), null, \"null doesn't shadow defaultValue\");\n});\n\ntest(\"a defaultValue for an attribute can be a function\", function() {\n var Tag = DS.Model.extend({\n createdAt: DS.attr('string', {\n defaultValue: function() {\n return \"le default value\";\n }\n })\n });\n\n var tag = store.createRecord(Tag);\n equal(get(tag, 'createdAt'), \"le default value\", \"the defaultValue function is evaluated\");\n});\n\ntest(\"setting a property to undefined on a newly created record should not impact the current state\", function() {\n var Tag = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var tag = store.createRecord(Tag);\n\n set(tag, 'name', 'testing');\n set(tag, 'name', undefined);\n\n equal(get(tag, 'currentState.stateName'), \"root.loaded.created.uncommitted\");\n\n tag = store.createRecord(Tag, {name: undefined});\n\n equal(get(tag, 'currentState.stateName'), \"root.loaded.created.uncommitted\");\n});\n\nmodule(\"unit/model - with a simple Person model\", {\n setup: function() {\n array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n Person = DS.Model.extend({\n name: DS.attr('string')\n });\n store = createStore({\n person: Person\n });\n store.pushMany(Person, array);\n },\n teardown: function() {\n Person = null;\n store = null;\n array = null;\n }\n});\n\ntest(\"can ask if record with a given id is loaded\", function() {\n equal(store.recordIsLoaded(Person, 1), true, 'should have person with id 1');\n equal(store.recordIsLoaded('person', 1), true, 'should have person with id 1');\n equal(store.recordIsLoaded(Person, 4), false, 'should not have person with id 4');\n equal(store.recordIsLoaded('person', 4), false, 'should not have person with id 4');\n});\n\ntest(\"a listener can be added to a record\", function() {\n var count = 0;\n var F = function() { count++; };\n var record = store.createRecord(Person);\n\n record.on('event!', F);\n record.trigger('event!');\n\n equal(count, 1, \"the event was triggered\");\n\n record.trigger('event!');\n\n equal(count, 2, \"the event was triggered\");\n});\n\ntest(\"when an event is triggered on a record the method with the same name is invoked with arguments\", function(){\n var count = 0;\n var F = function() { count++; };\n var record = store.createRecord(Person);\n\n record.eventNamedMethod = F;\n\n record.trigger('eventNamedMethod');\n\n equal(count, 1, \"the corresponding method was called\");\n});\n\ntest(\"when a method is invoked from an event with the same name the arguments are passed through\", function(){\n var eventMethodArgs = null;\n var F = function() { eventMethodArgs = arguments; };\n var record = store.createRecord(Person);\n\n record.eventThatTriggersMethod = F;\n\n record.trigger('eventThatTriggersMethod', 1, 2);\n\n equal( eventMethodArgs[0], 1);\n equal( eventMethodArgs[1], 2);\n});\n\nvar converts = function(type, provided, expected) {\n var Model = DS.Model.extend({\n name: DS.attr(type)\n });\n\n var container = new Ember.Container();\n\n var testStore = createStore({model: Model}),\n serializer = DS.JSONSerializer.create({ store: testStore, container: container });\n\n testStore.push(Model, serializer.normalize(Model, { id: 1, name: provided }));\n testStore.push(Model, serializer.normalize(Model, { id: 2 }));\n\n testStore.find('model', 1).then(async(function(record) {\n deepEqual(get(record, 'name'), expected, type + \" coerces \" + provided + \" to \" + expected);\n }));\n\n // See: Github issue #421\n // record = testStore.find(Model, 2);\n // set(record, 'name', provided);\n // deepEqual(get(record, 'name'), expected, type + \" coerces \" + provided + \" to \" + expected);\n};\n\nvar convertsFromServer = function(type, provided, expected) {\n var Model = DS.Model.extend({\n name: DS.attr(type)\n });\n\n var container = new Ember.Container();\n\n var testStore = createStore({model: Model}),\n serializer = DS.JSONSerializer.create({ store: testStore, container: container });\n\n testStore.push(Model, serializer.normalize(Model, { id: \"1\", name: provided }));\n testStore.find('model', 1).then(async(function(record) {\n deepEqual(get(record, 'name'), expected, type + \" coerces \" + provided + \" to \" + expected);\n }));\n};\n\nvar convertsWhenSet = function(type, provided, expected) {\n var Model = DS.Model.extend({\n name: DS.attr(type)\n });\n\n var testStore = createStore({model: Model});\n\n testStore.push(Model, { id: 2 });\n var record = testStore.find('model', 2).then(async(function(record) {\n set(record, 'name', provided);\n deepEqual(record.serialize().name, expected, type + \" saves \" + provided + \" as \" + expected);\n }));\n};\n\ntest(\"a DS.Model can describe String attributes\", function() {\n converts('string', \"Scumbag Tom\", \"Scumbag Tom\");\n converts('string', 1, \"1\");\n converts('string', \"\", \"\");\n converts('string', null, null);\n converts('string', undefined, null);\n convertsFromServer('string', undefined, null);\n});\n\ntest(\"a DS.Model can describe Number attributes\", function() {\n converts('number', \"1\", 1);\n converts('number', \"0\", 0);\n converts('number', 1, 1);\n converts('number', 0, 0);\n converts('number', \"\", null);\n converts('number', null, null);\n converts('number', undefined, null);\n converts('number', true, 1);\n converts('number', false, 0);\n});\n\ntest(\"a DS.Model can describe Boolean attributes\", function() {\n converts('boolean', \"1\", true);\n converts('boolean', \"\", false);\n converts('boolean', 1, true);\n converts('boolean', 0, false);\n converts('boolean', null, false);\n converts('boolean', true, true);\n converts('boolean', false, false);\n});\n\ntest(\"a DS.Model can describe Date attributes\", function() {\n converts('date', null, null);\n converts('date', undefined, undefined);\n\n var date = new Date(\"Sat, 31 Dec 2011 00:08:16 GMT\");\n date.setMilliseconds(54);\n var expectedSerializedDate = Number(date);\n\n var store = createStore();\n\n var Person = DS.Model.extend({\n updatedAt: DS.attr('date')\n });\n\n store.push(Person, { id: 1 });\n store.find(Person, 1).then(async(function(record) {\n record.set('updatedAt', date);\n deepEqual(date, get(record, 'updatedAt'), \"setting a date returns the same date\");\n }));\n\n convertsFromServer('date', expectedSerializedDate, date);\n convertsWhenSet('date', date, expectedSerializedDate);\n});\n\ntest(\"don't allow setting\", function(){\n var store = createStore();\n\n var Person = DS.Model.extend();\n var record = store.createRecord(Person);\n\n raises(function(){\n record.set('isLoaded', true);\n }, \"raised error when trying to set an unsettable record\");\n});\n\ntest(\"ensure model exits loading state, materializes data and fulfills promise only after data is available\", function () {\n var store = createStore({\n adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n return Ember.RSVP.resolve({ id: 1, name: \"John\", isDrugAddict: false });\n }\n })\n });\n\n store.find(Person, 1).then(async(function(person) {\n equal(get(person, 'currentState.stateName'), 'root.loaded.saved', 'model is in loaded state');\n equal(get(person, 'isLoaded'), true, 'model is loaded');\n }));\n});\n\ntest(\"A DS.Model can be JSONified\", function() {\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var store = createStore({ person: Person });\n var record = store.createRecord('person', { name: \"TomHuda\" });\n deepEqual(record.toJSON(), { name: \"TomHuda\" });\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/model_test");minispade.register('ember-data/~tests/unit/record_array_test', "(function() {var get = Ember.get, set = Ember.set;\nvar indexOf = Ember.EnumerableUtils.indexOf;\n\nvar Person, array;\n\nmodule(\"unit/record_array - DS.RecordArray\", {\n setup: function() {\n array = [{ id: '1', name: \"Scumbag Dale\" }, { id: '2', name: \"Scumbag Katz\" }, { id: '3', name: \"Scumbag Bryn\" }];\n\n Person = DS.Model.extend({\n name: DS.attr('string')\n });\n }\n});\n\ntest(\"a record array is backed by records\", function() {\n var store = createStore();\n store.pushMany(Person, array);\n\n store.findByIds(Person, [1,2,3]).then(async(function(records) {\n for (var i=0, l=get(array, 'length'); i<l; i++) {\n deepEqual(records[i].getProperties('id', 'name'), array[i], \"a record array materializes objects on demand\");\n }\n }));\n});\n\ntest(\"acts as a live query\", function() {\n var store = createStore();\n\n var recordArray = store.all(Person);\n store.push(Person, { id: 1, name: 'wycats' });\n equal(get(recordArray, 'lastObject.name'), 'wycats');\n\n store.push(Person, { id: 2, name: 'brohuda' });\n equal(get(recordArray, 'lastObject.name'), 'brohuda');\n});\n\ntest(\"a loaded record is removed from a record array when it is deleted\", function() {\n var Tag = DS.Model.extend({\n people: DS.hasMany('person')\n });\n\n Person.reopen({\n tag: DS.belongsTo('tag')\n });\n\n var env = setupStore({ tag: Tag, person: Person }),\n store = env.store;\n\n store.pushMany('person', array);\n store.push('tag', { id: 1 });\n\n var asyncRecords = Ember.RSVP.hash({\n scumbag: store.find('person', 1),\n tag: store.find('tag', 1)\n });\n\n asyncRecords.then(async(function(records) {\n var scumbag = records.scumbag, tag = records.tag;\n\n tag.get('people').addObject(scumbag);\n equal(get(scumbag, 'tag'), tag, \"precond - the scumbag's tag has been set\");\n\n var recordArray = tag.get('people');\n\n equal(get(recordArray, 'length'), 1, \"precond - record array has one item\");\n equal(get(recordArray.objectAt(0), 'name'), \"Scumbag Dale\", \"item at index 0 is record with id 1\");\n\n scumbag.deleteRecord();\n\n equal(get(recordArray, 'length'), 0, \"record is removed from the record array\");\n }));\n});\n\n// GitHub Issue #168\ntest(\"a newly created record is removed from a record array when it is deleted\", function() {\n var store = createStore(),\n recordArray;\n\n recordArray = store.all(Person);\n\n var scumbag = store.createRecord(Person, {\n name: \"Scumbag Dale\"\n });\n\n equal(get(recordArray, 'length'), 1, \"precond - record array already has the first created item\");\n\n // guarantee coalescence\n Ember.run(function() {\n store.createRecord(Person, { name: 'p1'});\n store.createRecord(Person, { name: 'p2'});\n store.createRecord(Person, { name: 'p3'});\n });\n\n equal(get(recordArray, 'length'), 4, \"precond - record array has the created item\");\n equal(get(recordArray.objectAt(0), 'name'), \"Scumbag Dale\", \"item at index 0 is record with id 1\");\n\n scumbag.deleteRecord();\n\n equal(get(recordArray, 'length'), 3, \"record is removed from the record array\");\n\n recordArray.objectAt(0).set('name', 'toto');\n\n equal(get(recordArray, 'length'), 3, \"record is still removed from the record array\");\n});\n\ntest(\"a record array returns undefined when asking for a member outside of its content Array's range\", function() {\n var store = createStore();\n\n store.pushMany(Person, array);\n\n var recordArray = store.all(Person);\n\n strictEqual(recordArray.objectAt(20), undefined, \"objects outside of the range just return undefined\");\n});\n\n// This tests for a bug in the recordCache, where the records were being cached in the incorrect order.\ntest(\"a record array should be able to be enumerated in any order\", function() {\n var store = createStore();\n store.pushMany(Person, array);\n\n var recordArray = store.all(Person);\n\n equal(get(recordArray.objectAt(2), 'id'), 3, \"should retrieve correct record at index 2\");\n equal(get(recordArray.objectAt(1), 'id'), 2, \"should retrieve correct record at index 1\");\n equal(get(recordArray.objectAt(0), 'id'), 1, \"should retrieve correct record at index 0\");\n});\n\nvar shouldContain = function(array, item) {\n ok(indexOf(array, item) !== -1, \"array should contain \"+item.get('name'));\n};\n\nvar shouldNotContain = function(array, item) {\n ok(indexOf(array, item) === -1, \"array should not contain \"+item.get('name'));\n};\n\ntest(\"an AdapterPopulatedRecordArray knows if it's loaded or not\", function() {\n var env = setupStore({ person: Person }),\n store = env.store;\n\n env.adapter.findQuery = function(store, type, query, recordArray) {\n return Ember.RSVP.resolve(array);\n };\n\n store.find('person', { page: 1 }).then(async(function(people) {\n equal(get(people, 'isLoaded'), true, \"The array is now loaded\");\n }));\n});\n\ntest(\"a record array should return a promise when updating\", function() {\n var env = setupStore({ person: Person }),\n store = env.store, recordArray, promise;\n\n env.adapter.findAll = function(store, type, query, recordArray) {\n return Ember.RSVP.resolve(array);\n };\n\n recordArray = store.all(Person);\n promise = recordArray.update();\n ok((promise.then && typeof promise.then === \"function\"), \"#update returns a promise\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/record_array_test");minispade.register('ember-data/~tests/unit/states_test', "(function() {var get = Ember.get, set = Ember.set;\n\nvar rootState, stateName;\n\nmodule(\"unit/states - Flags for record states\", {\n setup: function() {\n rootState = DS.RootState;\n }\n});\n\nvar isTrue = function(flag) {\n equal(get(rootState, stateName + \".\" + flag), true, stateName + \".\" + flag + \" should be true\");\n};\n\nvar isFalse = function(flag) {\n equal(get(rootState, stateName + \".\" + flag), false, stateName + \".\" + flag + \" should be false\");\n};\n\ntest(\"the empty state\", function() {\n stateName = \"empty\";\n isFalse(\"isLoading\");\n isFalse(\"isLoaded\");\n isFalse(\"isDirty\");\n isFalse(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the loading state\", function() {\n stateName = \"loading\";\n isTrue(\"isLoading\");\n isFalse(\"isLoaded\");\n isFalse(\"isDirty\");\n isFalse(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the loaded state\", function() {\n stateName = \"loaded\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isFalse(\"isDirty\");\n isFalse(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the updated state\", function() {\n stateName = \"loaded.updated\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isTrue(\"isDirty\");\n isFalse(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the saving state\", function() {\n stateName = \"loaded.updated.inFlight\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isTrue(\"isDirty\");\n isTrue(\"isSaving\");\n isFalse(\"isDeleted\");\n});\n\ntest(\"the deleted state\", function() {\n stateName = \"deleted\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isTrue(\"isDirty\");\n isFalse(\"isSaving\");\n isTrue(\"isDeleted\");\n});\n\ntest(\"the deleted.saving state\", function() {\n stateName = \"deleted.inFlight\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isTrue(\"isDirty\");\n isTrue(\"isSaving\");\n isTrue(\"isDeleted\");\n});\n\ntest(\"the deleted.saved state\", function() {\n stateName = \"deleted.saved\";\n isFalse(\"isLoading\");\n isTrue(\"isLoaded\");\n isFalse(\"isDirty\");\n isFalse(\"isSaving\");\n isTrue(\"isDeleted\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/states_test");minispade.register('ember-data/~tests/unit/store/adapter_interop_test', "(function() {var get = Ember.get, set = Ember.set;\nvar resolve = Ember.RSVP.resolve;\nvar TestAdapter, store;\n\nmodule(\"unit/store/adapter_interop - DS.Store working with a DS.Adapter\", {\n setup: function() {\n TestAdapter = DS.Adapter.extend();\n },\n teardown: function() {\n if (store) { store.destroy(); }\n }\n});\n\ntest(\"Adapter can be set as a factory\", function() {\n store = createStore({adapter: TestAdapter});\n\n ok(store.get('defaultAdapter') instanceof TestAdapter);\n});\n\ntest('Adapter can be set as a name', function() {\n store = createStore({adapter: '-rest'});\n\n ok(store.get('defaultAdapter') instanceof DS.RESTAdapter);\n});\n\ntest('Adapter can not be set as an instance', function() {\n store = DS.Store.create({\n adapter: DS.Adapter.create()\n });\n var assert = Ember.assert;\n Ember.assert = function() { ok(true, \"raises an error when passing in an instance\"); };\n store.get('defaultAdapter');\n Ember.assert = assert;\n});\n\ntest(\"Calling Store#find invokes its adapter#find\", function() {\n expect(4);\n\n var adapter = TestAdapter.extend({\n find: function(store, type, id) {\n ok(true, \"Adapter#find was called\");\n equal(store, currentStore, \"Adapter#find was called with the right store\");\n equal(type, currentType, \"Adapter#find was called with the type passed into Store#find\");\n equal(id, 1, \"Adapter#find was called with the id passed into Store#find\");\n\n return Ember.RSVP.resolve({ id: 1 });\n }\n });\n\n var currentStore = createStore({ adapter: adapter });\n var currentType = DS.Model.extend();\n\n currentStore.find(currentType, 1);\n});\n\ntest(\"Returning a promise from `find` asynchronously loads data\", function() {\n var adapter = TestAdapter.extend({\n find: function(store, type, id) {\n return resolve({ id: 1, name: \"Scumbag Dale\" });\n }\n });\n\n var currentStore = createStore({ adapter: adapter });\n var currentType = DS.Model.extend({\n name: DS.attr('string')\n });\n\n currentStore.find(currentType, 1).then(async(function(object) {\n strictEqual(get(object, 'name'), \"Scumbag Dale\", \"the data was pushed\");\n }));\n});\n\ntest(\"IDs provided as numbers are coerced to strings\", function() {\n var adapter = TestAdapter.extend({\n find: function(store, type, id) {\n equal(typeof id, 'string', \"id has been normalized to a string\");\n return resolve({ id: 1, name: \"Scumbag Sylvain\" });\n }\n });\n\n var currentStore = createStore({ adapter: adapter });\n var currentType = DS.Model.extend({\n name: DS.attr('string')\n });\n\n currentStore.find(currentType, 1).then(async(function(object) {\n equal(typeof object.get('id'), 'string', \"id was coerced to a string\");\n currentStore.push(currentType, { id: 2, name: \"Scumbag Sam Saffron\" });\n return currentStore.find(currentType, 2);\n })).then(async(function(object) {\n ok(object, \"object was found\");\n equal(typeof object.get('id'), 'string', \"id is a string despite being supplied and searched for as a number\");\n }));\n});\n\n\nvar array = [{ id: \"1\", name: \"Scumbag Dale\" }, { id: \"2\", name: \"Scumbag Katz\" }, { id: \"3\", name: \"Scumbag Bryn\" }];\n\ntest(\"can load data for the same record if it is not dirty\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n store.push(Person, { id: 1, name: \"Tom Dale\" });\n\n var tom = store.find(Person, 1).then(async(function(tom) {\n equal(get(tom, 'isDirty'), false, \"precond - record is not dirty\");\n equal(get(tom, 'name'), \"Tom Dale\", \"returns the correct name\");\n\n store.push(Person, { id: 1, name: \"Captain Underpants\" });\n equal(get(tom, 'name'), \"Captain Underpants\", \"updated record with new date\");\n }));\n\n});\n\n/*\ntest(\"DS.Store loads individual records without explicit IDs with a custom primaryKey\", function() {\n var store = DS.Store.create();\n var Person = DS.Model.extend({ name: DS.attr('string'), primaryKey: 'key' });\n\n store.load(Person, { key: 1, name: \"Tom Dale\" });\n\n var tom = store.find(Person, 1);\n equal(get(tom, 'name'), \"Tom Dale\", \"the person was successfully loaded for the given ID\");\n});\n*/\n\ntest(\"pushMany extracts ids from an Array of hashes if no ids are specified\", function() {\n var store = createStore();\n\n var Person = DS.Model.extend({ name: DS.attr('string') });\n\n store.pushMany(Person, array);\n store.find(Person, 1).then(async(function(person) {\n equal(get(person, 'name'), \"Scumbag Dale\", \"correctly extracted id for loaded data\");\n }));\n});\n\ntest(\"loadMany takes an optional Object and passes it on to the Adapter\", function() {\n var passedQuery = { page: 1 };\n\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var adapter = TestAdapter.extend({\n findQuery: function(store, type, query) {\n equal(type, Person, \"The type was Person\");\n equal(query, passedQuery, \"The query was passed in\");\n return Ember.RSVP.resolve([]);\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n store.find(Person, passedQuery);\n});\n\ntest(\"Find with query calls the correct extract\", function() {\n var passedQuery = { page: 1 };\n\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var adapter = TestAdapter.extend({\n findQuery: function(store, type, query) {\n return Ember.RSVP.resolve([]);\n }\n });\n\n var callCount = 0;\n\n var ApplicationSerializer = DS.JSONSerializer.extend({\n extractFindQuery: function(store, type, payload) {\n callCount++;\n return [];\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n store.container.register('serializer:application', ApplicationSerializer);\n\n store.find(Person, passedQuery);\n equal(callCount, 1, 'extractFindQuery was called');\n});\n\ntest(\"all(type) returns a record array of all records of a specific type\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n store.push(Person, { id: 1, name: \"Tom Dale\" });\n\n var results = store.all(Person);\n equal(get(results, 'length'), 1, \"record array should have the original object\");\n equal(get(results.objectAt(0), 'name'), \"Tom Dale\", \"record has the correct information\");\n\n store.push(Person, { id: 2, name: \"Yehuda Katz\" });\n equal(get(results, 'length'), 2, \"record array should have the new object\");\n equal(get(results.objectAt(1), 'name'), \"Yehuda Katz\", \"record has the correct information\");\n\n strictEqual(results, store.all(Person), \"subsequent calls to all return the same recordArray)\");\n});\n\ntest(\"a new record of a particular type is created via store.createRecord(type)\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var person = store.createRecord(Person);\n\n equal(get(person, 'isLoaded'), true, \"A newly created record is loaded\");\n equal(get(person, 'isNew'), true, \"A newly created record is new\");\n equal(get(person, 'isDirty'), true, \"A newly created record is dirty\");\n\n set(person, 'name', \"Braaahm Dale\");\n\n equal(get(person, 'name'), \"Braaahm Dale\", \"Even if no hash is supplied, `set` still worked\");\n});\n\ntest(\"a new record with a specific id can't be created if this id is already used in the store\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n Person.reopenClass({\n toString: function() {\n return 'Person';\n }\n });\n\n store.createRecord(Person, {id: 5});\n\n expectAssertion(function() {\n store.createRecord(Person, {id: 5});\n }, /The id 5 has already been used with another record of type Person/);\n});\n\ntest(\"an initial data hash can be provided via store.createRecord(type, hash)\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var person = store.createRecord(Person, { name: \"Brohuda Katz\" });\n\n equal(get(person, 'isLoaded'), true, \"A newly created record is loaded\");\n equal(get(person, 'isNew'), true, \"A newly created record is new\");\n equal(get(person, 'isDirty'), true, \"A newly created record is dirty\");\n\n equal(get(person, 'name'), \"Brohuda Katz\", \"The initial data hash is provided\");\n});\n\ntest(\"if an id is supplied in the initial data hash, it can be looked up using `store.find`\", function() {\n var store = createStore();\n var Person = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var person = store.createRecord(Person, { id: 1, name: \"Brohuda Katz\" });\n\n store.find(Person, 1).then(async(function(again) {\n strictEqual(person, again, \"the store returns the loaded object\");\n }));\n});\n\ntest(\"records inside a collection view should have their ids updated\", function() {\n var Person = DS.Model.extend();\n\n var idCounter = 1;\n var adapter = TestAdapter.extend({\n createRecord: function(store, type, record) {\n return Ember.RSVP.resolve({name: record.get('name'), id: idCounter++});\n }\n });\n\n var store = createStore({\n adapter: adapter\n });\n\n var container = Ember.CollectionView.create({\n content: store.all(Person)\n });\n\n container.appendTo('#qunit-fixture');\n\n var tom = store.createRecord(Person, {name: 'Tom Dale'});\n var yehuda = store.createRecord(Person, {name: 'Yehuda Katz'});\n\n Ember.RSVP.all([ tom.save(), yehuda.save() ]).then(async(function() {\n container.content.forEach(function(person, index) {\n equal(person.get('id'), index + 1, \"The record's id should be correct.\");\n });\n\n container.destroy();\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/adapter_interop_test");minispade.register('ember-data/~tests/unit/store/create_record_test', "(function() {var get = Ember.get, set = Ember.set;\nvar store, Record;\n\nmodule(\"unit/store/createRecord - Store creating records\", {\n setup: function() {\n store = createStore({ adapter: DS.Adapter.extend()});\n\n Record = DS.Model.extend({\n title: DS.attr('string')\n });\n }\n});\n\ntest(\"doesn't modify passed in properties hash\", function(){\n var attributes = { foo: 'bar' },\n record1 = store.createRecord(Record, attributes),\n record2 = store.createRecord(Record, attributes);\n\n deepEqual(attributes, { foo: 'bar' }, \"The properties hash is not modified\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/create_record_test");minispade.register('ember-data/~tests/unit/store/model_for_test', "(function() {var container, store;\n\nmodule(\"unit/store/model_for - DS.Store#modelFor\", {\n setup: function() {\n store = createStore({blogPost: DS.Model.extend()});\n container = store.container;\n },\n\n teardown: function() {\n container.destroy();\n store.destroy();\n }\n});\n\ntest(\"sets a normalized key as typeKey\", function() {\n container.normalize = function(fullName){\n return Ember.String.camelize(fullName);\n };\n\n ok(store.modelFor(\"blog.post\").typeKey, \"blogPost\", \"typeKey is normalized\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/model_for_test");minispade.register('ember-data/~tests/unit/store/push_test', "(function() {var env, store, Person, PhoneNumber, Post;\nvar attr = DS.attr, hasMany = DS.hasMany, belongsTo = DS.belongsTo;\n\nmodule(\"unit/store/push - DS.Store#push\", {\n setup: function() {\n Person = DS.Model.extend({\n firstName: attr('string'),\n lastName: attr('string'),\n phoneNumbers: hasMany('phone-number')\n });\n\n PhoneNumber = DS.Model.extend({\n number: attr('string'),\n person: belongsTo('person')\n });\n\n Post = DS.Model.extend({\n postTitle: attr('string')\n });\n\n env = setupStore({\"post\": Post,\n \"person\": Person,\n \"phone-number\": PhoneNumber});\n\n store = env.store;\n\n env.container.register('serializer:post', DS.ActiveModelSerializer);\n },\n\n teardown: function() {\n Ember.run(function() {\n store.destroy();\n });\n }\n});\n\ntest(\"Calling push with a normalized hash returns a record\", function() {\n var person = store.push('person', {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n\n store.find('person', 'wat').then(async(function(foundPerson) {\n equal(foundPerson, person, \"record returned via load() is the same as the record returned from find()\");\n deepEqual(foundPerson.getProperties('id', 'firstName', 'lastName'), {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n }));\n});\n\ntest(\"Supplying a model class for `push` is the same as supplying a string\", function () {\n var Programmer = Person.extend();\n env.container.register('model:programmer', Programmer);\n\n var programmer = store.push(Programmer, {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n\n store.find('programmer', 'wat').then(async(function(foundProgrammer) {\n deepEqual(foundProgrammer.getProperties('id', 'firstName', 'lastName'), {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n }));\n});\n\ntest(\"Calling push triggers `didLoad` even if the record hasn't been requested from the adapter\", function() {\n Person.reopen({\n didLoad: async(function() {\n ok(true, \"The didLoad callback was called\");\n })\n });\n\n store.push('person', {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n});\n\ntest(\"Calling update with partial records updates just those attributes\", function() {\n var person = store.push('person', {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n });\n\n store.update('person', {\n id: 'wat',\n lastName: \"Katz!\"\n });\n\n store.find('person', 'wat').then(async(function(foundPerson) {\n equal(foundPerson, person, \"record returned via load() is the same as the record returned from find()\");\n deepEqual(foundPerson.getProperties('id', 'firstName', 'lastName'), {\n id: 'wat',\n firstName: \"Yehuda\",\n lastName: \"Katz!\"\n });\n }));\n});\n\ntest(\"Calling push with a normalized hash containing related records returns a record\", function() {\n var number1 = store.push('phone-number', {\n id: 1,\n number: '5551212',\n person: 'wat'\n });\n\n var number2 = store.push('phone-number', {\n id: 2,\n number: '5552121',\n person: 'wat'\n });\n\n var person = store.push('person', {\n id: 'wat',\n firstName: 'John',\n lastName: 'Smith',\n phoneNumbers: [number1, number2]\n });\n\n deepEqual(person.get('phoneNumbers').toArray(), [ number1, number2 ], \"phoneNumbers array is correct\");\n});\n\ntest(\"Calling push with a normalized hash containing IDs of related records returns a record\", function() {\n Person.reopen({\n phoneNumbers: hasMany('phone-number', { async: true })\n });\n\n env.adapter.find = function(store, type, id) {\n if (id === \"1\") {\n return Ember.RSVP.resolve({\n id: 1,\n number: '5551212',\n person: 'wat'\n });\n }\n\n if (id === \"2\") {\n return Ember.RSVP.resolve({\n id: 2,\n number: '5552121',\n person: 'wat'\n });\n }\n };\n\n var person = store.push('person', {\n id: 'wat',\n firstName: 'John',\n lastName: 'Smith',\n phoneNumbers: [\"1\", \"2\"]\n });\n\n person.get('phoneNumbers').then(async(function(phoneNumbers) {\n deepEqual(phoneNumbers.map(function(item) {\n return item.getProperties('id', 'number', 'person');\n }), [{\n id: \"1\",\n number: '5551212',\n person: person\n }, {\n id: \"2\",\n number: '5552121',\n person: person\n }]);\n }));\n});\n\ntest(\"Calling pushPayload allows pushing raw JSON\", function () {\n store.pushPayload('post', {posts: [{\n id: '1',\n post_title: \"Ember rocks\"\n }]});\n\n var post = store.getById('post', 1);\n\n equal(post.get('postTitle'), \"Ember rocks\", \"you can push raw JSON into the store\");\n\n store.pushPayload('post', {posts: [{\n id: '1',\n post_title: \"Ember rocks (updated)\"\n }]});\n\n equal(post.get('postTitle'), \"Ember rocks (updated)\", \"You can update data in the store\");\n});\n\ntest(\"Calling pushPayload allows pushing singular payload properties\", function () {\n store.pushPayload('post', {post: {\n id: '1',\n post_title: \"Ember rocks\"\n }});\n\n var post = store.getById('post', 1);\n\n equal(post.get('postTitle'), \"Ember rocks\", \"you can push raw JSON into the store\");\n\n store.pushPayload('post', {post: {\n id: '1',\n post_title: \"Ember rocks (updated)\"\n }});\n\n equal(post.get('postTitle'), \"Ember rocks (updated)\", \"You can update data in the store\");\n});\n\ntest(\"Calling pushPayload without a type uses application serializer\", function () {\n expect(2);\n\n env.container.register('serializer:application', DS.RESTSerializer.extend({\n pushPayload: function(store, payload) {\n ok(true, \"pushPayload is called on Application serializer\");\n return this._super(store, payload);\n }\n }));\n\n store.pushPayload({posts: [{\n id: '1',\n postTitle: \"Ember rocks\"\n }]});\n\n var post = store.getById('post', 1);\n\n equal(post.get('postTitle'), \"Ember rocks\", \"you can push raw JSON into the store\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/push_test");minispade.register('ember-data/~tests/unit/store/serializer_for_test', "(function() {var container, store, app;\n\nmodule(\"unit/store/serializer_for - DS.Store#serializerFor\", {\n setup: function() {\n store = createStore({person: DS.Model.extend()});\n container = store.container;\n },\n\n teardown: function() {\n container.destroy();\n store.destroy();\n }\n});\n\ntest(\"Calling serializerFor looks up 'serializer:<type>' from the container\", function() {\n var PersonSerializer = DS.JSONSerializer.extend();\n\n container.register('serializer:person', PersonSerializer);\n\n ok(store.serializerFor('person') instanceof PersonSerializer, \"serializer returned from serializerFor is an instance of the registered Serializer class\");\n});\n\ntest(\"Calling serializerFor with a type that has not been registered looks up the default ApplicationSerializer\", function() {\n var ApplicationSerializer = DS.JSONSerializer.extend();\n\n container.register('serializer:application', ApplicationSerializer);\n\n ok(store.serializerFor('person') instanceof ApplicationSerializer, \"serializer returned from serializerFor is an instance of ApplicationSerializer\");\n});\n\ntest(\"Calling serializerFor with a type that has not been registered and in an application that does not have an ApplicationSerializer looks up the default Ember Data serializer\", function() {\n ok(store.serializerFor('person') instanceof DS.JSONSerializer, \"serializer returned from serializerFor is an instance of DS.JSONSerializer\");\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/serializer_for_test");minispade.register('ember-data/~tests/unit/store/unload_test', "(function() {var get = Ember.get, set = Ember.set;\nvar store, tryToFind, Record;\n\nmodule(\"unit/store/unload - Store unloading records\", {\n setup: function() {\n store = createStore({ adapter: DS.Adapter.extend({\n find: function(store, type, id) {\n tryToFind = true;\n return Ember.RSVP.resolve({ id: id, wasFetched: true });\n }\n })\n });\n\n Record = DS.Model.extend({\n title: DS.attr('string')\n });\n },\n\n teardown: function() {\n Ember.run(store, 'destroy');\n }\n});\n\ntest(\"unload a dirty record\", function() {\n store.push(Record, {id: 1, title: 'toto'});\n\n store.find(Record, 1).then(async(function(record) {\n record.set('title', 'toto2');\n\n equal(get(record, 'isDirty'), true, \"record is dirty\");\n expectAssertion(function() {\n record.unloadRecord();\n }, \"You can only unload a loaded, non-dirty record.\", \"can not unload dirty record\");\n }));\n});\n\ntest(\"unload a record\", function() {\n store.push(Record, {id: 1, title: 'toto'});\n\n store.find(Record, 1).then(async(function(record) {\n equal(get(record, 'id'), 1, \"found record with id 1\");\n equal(get(record, 'isDirty'), false, \"record is not dirty\");\n\n store.unloadRecord(record);\n\n equal(get(record, 'isDirty'), false, \"record is not dirty\");\n equal(get(record, 'isDeleted'), true, \"record is deleted\");\n\n tryToFind = false;\n store.find(Record, 1);\n equal(tryToFind, true, \"not found record with id 1\");\n }));\n});\n\nmodule(\"DS.Store - unload record with relationships\");\n\ntest(\"can commit store after unload record with relationships\", function() {\n store = createStore({ adapter: DS.Adapter.extend({\n find: function() {\n return Ember.RSVP.resolve({ id: 1, description: 'cuisinart', brand: 1 });\n },\n createRecord: function(store, type, record) {\n return Ember.RSVP.resolve();\n }\n })\n });\n\n var like, product, brand;\n\n var Brand = DS.Model.extend({\n name: DS.attr('string')\n });\n\n var Product = DS.Model.extend({\n description: DS.attr('string'),\n brand: DS.belongsTo(Brand)\n });\n\n var Like = DS.Model.extend({\n product: DS.belongsTo(Product)\n });\n\n store.push(Brand, { id: 1, name: 'EmberJS' });\n store.push(Product, { id: 1, description: 'toto', brand: 1 });\n\n var asyncRecords = Ember.RSVP.hash({\n brand: store.find(Brand, 1),\n product: store.find(Product, 1)\n });\n\n asyncRecords.then(async(function(records) {\n like = store.createRecord(Like, { id: 1, product: product });\n records.like = like.save();\n return Ember.RSVP.hash(records);\n })).then(async(function(records) {\n store.unloadRecord(records.product);\n\n return store.find(Product, 1);\n })).then(async(function(product) {\n equal(product.get('description'), 'cuisinart', \"The record was unloaded and the adapter's `find` was called\");\n store.destroy();\n }));\n});\n\n})();\n//@ sourceURL=ember-data/~tests/unit/store/unload_test");minispade.register('ember-inflector/~tests/system/inflector_test', "(function() {var inflector;\nmodule('ember-inflector.dsl', {\n setup: function() {\n inflector = new Ember.Inflector(/* no rulest == no rules */);\n },\n teardown: function() {\n inflector = undefined;\n }\n});\n\ntest('ability to add additonal pluralization rules', function(){\n equal(inflector.pluralize('cow'), 'cow', 'no pluralization rule');\n\n inflector.plural(/$/, 's');\n\n equal(inflector.pluralize('cow'), 'cows', 'pluralization rule was applied');\n});\n\ntest('ability to add additonal singularization rules', function(){\n equal(inflector.singularize('cows'), 'cows', 'no singularization rule was applied');\n\n inflector.singular(/s$/, '');\n\n equal(inflector.singularize('cows'), 'cow', 'singularization rule was applied');\n});\n\ntest('ability to add additonal uncountable rules', function(){\n inflector.plural(/$/, 's');\n equal(inflector.pluralize('cow'), 'cows', 'pluralization rule was applied');\n\n inflector.uncountable('cow');\n equal(inflector.pluralize('cow'), 'cow', 'pluralization rule NOT was applied');\n});\n\ntest('ability to add additonal irregular rules', function(){\n inflector.singular(/s$/, '');\n inflector.plural(/$/, 's');\n\n equal(inflector.singularize('cows'), 'cow', 'regular singularization rule was applied');\n equal(inflector.pluralize('cow'), 'cows', 'regular pluralization rule was applied');\n\n inflector.irregular('cow', 'kine');\n\n equal(inflector.singularize('kine'), 'cow', 'irregular singularization rule was applied');\n equal(inflector.pluralize('cow'), 'kine', 'irregular pluralization rule was applied');\n});\n\ntest('ability to add identical singular and pluralizations',function(){\n\n inflector.singular(/s$/, '');\n inflector.plural(/$/, 's');\n\n equal(inflector.singularize('settings'),'setting','regular singularization rule was applied');\n equal(inflector.pluralize('setting'),'settings','regular pluralization rule was applied');\n\n inflector.irregular('settings','settings');\n inflector.irregular('userPreferences','userPreferences');\n\n equal(inflector.singularize('settings'),'settings','irregular singularization rule was applied on lowercase word');\n equal(inflector.pluralize('settings'),'settings','irregular pluralization rule was applied on lowercase word');\n\n equal(inflector.singularize('userPreferences'),'userPreferences','irregular singularization rule was applied on camelcase word');\n equal(inflector.pluralize('userPreferences'),'userPreferences','irregular pluralization rule was applied on camelcase word');\n});\n\nmodule('ember-inflector.unit');\n\ntest('plurals', function() {\n expect(1);\n\n var inflector = new Ember.Inflector({\n plurals: [\n [/$/, 's'],\n [/s$/i, 's']\n ]\n });\n\n equal(inflector.pluralize('apple'), 'apples');\n});\n\ntest('singularization',function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n singular: [\n [/s$/i, ''],\n [/(ss)$/i, '$1']\n ]\n });\n\n equal(inflector.singularize('apple'), 'apple');\n});\n\ntest('singularization of irregulars', function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n irregularPairs: [\n ['person', 'people']\n ]\n });\n\n equal(inflector.singularize('person'), 'person');\n});\n\ntest('plural',function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n plurals: [\n ['1', '1'],\n ['2', '2'],\n ['3', '3']\n ]\n });\n\n equal(inflector.rules.plurals.length, 3);\n});\n\ntest('singular',function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n singular: [\n ['1', '1'],\n ['2', '2'],\n ['3', '3']\n ]\n });\n\n equal(inflector.rules.singular.length, 3);\n});\n\ntest('irregular',function(){\n expect(6);\n\n var inflector = new Ember.Inflector({\n irregularPairs: [\n ['1', '12'],\n ['2', '22'],\n ['3', '32']\n ]\n });\n\n equal(inflector.rules.irregular['1'], '12');\n equal(inflector.rules.irregular['2'], '22');\n equal(inflector.rules.irregular['3'], '32');\n\n equal(inflector.rules.irregularInverse['12'], '1');\n equal(inflector.rules.irregularInverse['22'], '2');\n equal(inflector.rules.irregularInverse['32'], '3');\n});\n\ntest('uncountable',function(){\n expect(3);\n\n var inflector = new Ember.Inflector({\n uncountable: [\n '1',\n '2',\n '3'\n ]\n });\n\n equal(inflector.rules.uncountable['1'], true);\n equal(inflector.rules.uncountable['2'], true);\n equal(inflector.rules.uncountable['3'], true);\n});\n\ntest('inflect.nothing', function(){\n expect(2);\n\n var inflector = new Ember.Inflector();\n\n equal(inflector.inflect('', []), '');\n equal(inflector.inflect(' ', []), ' ');\n});\n\ntest('inflect.noRules',function(){\n expect(1);\n\n var inflector = new Ember.Inflector();\n\n equal(inflector.inflect('word', []),'word');\n});\n\ntest('inflect.uncountable', function(){\n expect(1);\n\n var inflector = new Ember.Inflector({\n plural: [\n [/$/,'s']\n ],\n uncountable: [\n 'word'\n ]\n });\n\n var rules = [];\n\n equal(inflector.inflect('word', rules), 'word');\n});\n\ntest('inflect.irregular', function(){\n expect(2);\n\n var inflector = new Ember.Inflector({\n irregularPairs: [\n ['word', 'wordy']\n ]\n });\n\n var rules = [];\n\n equal(inflector.inflect('word', rules, inflector.rules.irregular), 'wordy');\n equal(inflector.inflect('wordy', rules, inflector.rules.irregularInverse), 'word');\n});\n\ntest('inflect.basicRules', function(){\n expect(1);\n\n var inflector = new Ember.Inflector();\n var rules = [[/$/, 's']];\n\n equal(inflector.inflect('word', rules ), 'words');\n});\n\ntest('inflect.advancedRules', function(){\n expect(1);\n\n var inflector = new Ember.Inflector();\n var rules = [[/^(ox)$/i, '$1en']];\n\n equal(inflector.inflect('ox', rules), 'oxen');\n});\n\n})();\n//@ sourceURL=ember-inflector/~tests/system/inflector_test");minispade.register('ember-inflector/~tests/system/integration_test', "(function() {module(\"ember-inflector.integration\");\n\ntest(\"pluralize\", function(){\n expect(3);\n\n equal(Ember.String.pluralize('word'), 'words');\n equal(Ember.String.pluralize('ox'), 'oxen');\n equal(Ember.String.pluralize('octopus'), 'octopi');\n});\n\ntest(\"singularize\", function(){\n expect(3);\n\n equal(Ember.String.singularize('words'), 'word');\n equal(Ember.String.singularize('oxen'), 'ox');\n equal(Ember.String.singularize('octopi'), 'octopus');\n});\n\n})();\n//@ sourceURL=ember-inflector/~tests/system/integration_test");
@@ -3,7 +3,7 @@
3
3
  * @copyright Copyright 2011-2014 Tilde Inc. and contributors.
4
4
  * Portions Copyright 2011 LivingSocial Inc.
5
5
  * @license Licensed under MIT license (see license.js)
6
- * @version 1.0.0-beta.5
6
+ * @version 1.0.0-beta.6
7
7
  */
8
8
 
9
9
 
@@ -62,11 +62,11 @@ if ('undefined' === typeof DS) {
62
62
  /**
63
63
  @property VERSION
64
64
  @type String
65
- @default '1.0.0-beta.5'
65
+ @default '1.0.0-beta.6'
66
66
  @static
67
67
  */
68
68
  DS = Ember.Namespace.create({
69
- VERSION: '1.0.0-beta.5'
69
+ VERSION: '1.0.0-beta.6'
70
70
  });
71
71
 
72
72
  if ('undefined' !== typeof window) {
@@ -82,6 +82,60 @@ if ('undefined' === typeof DS) {
82
82
 
83
83
 
84
84
 
85
+ (function() {
86
+ /**
87
+ This is used internally to enable deprecation of container paths and provide
88
+ a decent message to the user indicating how to fix the issue.
89
+
90
+ @class ContainerProxy
91
+ @namespace DS
92
+ @private
93
+ */
94
+ var ContainerProxy = function (container){
95
+ this.container = container;
96
+ };
97
+
98
+ ContainerProxy.prototype.aliasedFactory = function(path, preLookup) {
99
+ var _this = this;
100
+
101
+ return {create: function(){
102
+ if (preLookup) { preLookup(); }
103
+
104
+ return _this.container.lookup(path);
105
+ }};
106
+ };
107
+
108
+ ContainerProxy.prototype.registerAlias = function(source, dest, preLookup) {
109
+ var factory = this.aliasedFactory(dest, preLookup);
110
+
111
+ return this.container.register(source, factory);
112
+ };
113
+
114
+ ContainerProxy.prototype.registerDeprecation = function(deprecated, valid) {
115
+ var preLookupCallback = function(){
116
+ Ember.deprecate("You tried to look up '" + deprecated + "', " +
117
+ "but this has been deprecated in favor of '" + valid + "'.", false);
118
+ };
119
+
120
+ return this.registerAlias(deprecated, valid, preLookupCallback);
121
+ };
122
+
123
+ ContainerProxy.prototype.registerDeprecations = function(proxyPairs) {
124
+ for (var i = proxyPairs.length; i > 0; i--) {
125
+ var proxyPair = proxyPairs[i - 1],
126
+ deprecated = proxyPair['deprecated'],
127
+ valid = proxyPair['valid'];
128
+
129
+ this.registerDeprecation(deprecated, valid);
130
+ }
131
+ };
132
+
133
+ DS.ContainerProxy = ContainerProxy;
134
+
135
+ })();
136
+
137
+
138
+
85
139
  (function() {
86
140
  var get = Ember.get, set = Ember.set, isNone = Ember.isNone;
87
141
 
@@ -95,11 +149,11 @@ function aliasMethod(methodName) {
95
149
 
96
150
  /**
97
151
  In Ember Data a Serializer is used to serialize and deserialize
98
- records when they are transfered in and out of an external source.
152
+ records when they are transferred in and out of an external source.
99
153
  This process involves normalizing property names, transforming
100
- attribute values and serializeing relationships.
154
+ attribute values and serializing relationships.
101
155
 
102
- For maximum performance Ember Data recomends you use the
156
+ For maximum performance Ember Data recommends you use the
103
157
  [RESTSerializer](DS.RESTSerializer.html) or one of its subclasses.
104
158
 
105
159
  `JSONSerializer` is useful for simpler or legacy backends that may
@@ -111,9 +165,9 @@ function aliasMethod(methodName) {
111
165
  DS.JSONSerializer = Ember.Object.extend({
112
166
  /**
113
167
  The primaryKey is used when serializing and deserializing
114
- data. Ember Data always uses the `id` propery to store the id of
168
+ data. Ember Data always uses the `id` property to store the id of
115
169
  the record. The external source may not always follow this
116
- convention. In these cases it is usesful to override the
170
+ convention. In these cases it is useful to override the
117
171
  primaryKey property to match the primaryKey of your external
118
172
  store.
119
173
 
@@ -517,7 +571,7 @@ DS.JSONSerializer = Ember.Object.extend({
517
571
  such as the `RESTSerializer` may push records into the store as
518
572
  part of the extract call.
519
573
 
520
- This method deletegates to a more specific extract method based on
574
+ This method delegates to a more specific extract method based on
521
575
  the `requestType`.
522
576
 
523
577
  Example
@@ -777,7 +831,7 @@ DS.JSONSerializer = Ember.Object.extend({
777
831
 
778
832
  /**
779
833
  `keyForRelationship` can be used to define a custom key when
780
- serializeing relationship properties. By default `JSONSerializer`
834
+ serializing relationship properties. By default `JSONSerializer`
781
835
  does not provide an implementation of this method.
782
836
 
783
837
  Example
@@ -1095,32 +1149,12 @@ DS.DateTransform = DS.Transform.extend({
1095
1149
 
1096
1150
  serialize: function(date) {
1097
1151
  if (date instanceof Date) {
1098
- var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
1099
- var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
1100
-
1101
- var pad = function(num) {
1102
- return num < 10 ? "0"+num : ""+num;
1103
- };
1104
-
1105
- var utcYear = date.getUTCFullYear(),
1106
- utcMonth = date.getUTCMonth(),
1107
- utcDayOfMonth = date.getUTCDate(),
1108
- utcDay = date.getUTCDay(),
1109
- utcHours = date.getUTCHours(),
1110
- utcMinutes = date.getUTCMinutes(),
1111
- utcSeconds = date.getUTCSeconds();
1112
-
1113
-
1114
- var dayOfWeek = days[utcDay];
1115
- var dayOfMonth = pad(utcDayOfMonth);
1116
- var month = months[utcMonth];
1117
-
1118
- return dayOfWeek + ", " + dayOfMonth + " " + month + " " + utcYear + " " +
1119
- pad(utcHours) + ":" + pad(utcMinutes) + ":" + pad(utcSeconds) + " GMT";
1152
+ // Serialize it as a number to maintain millisecond precision
1153
+ return Number(date);
1120
1154
  } else {
1121
1155
  return null;
1122
1156
  }
1123
- }
1157
+ }
1124
1158
 
1125
1159
  });
1126
1160
 
@@ -1255,9 +1289,20 @@ Ember.onLoad('Ember.Application', function(Application) {
1255
1289
 
1256
1290
  initialize: function(container, application) {
1257
1291
  application.register('store:main', application.Store || DS.Store);
1258
- application.register('serializer:_default', DS.JSONSerializer);
1259
- application.register('serializer:_rest', DS.RESTSerializer);
1260
- application.register('adapter:_rest', DS.RESTAdapter);
1292
+
1293
+ // allow older names to be looked up
1294
+
1295
+ var proxy = new DS.ContainerProxy(container);
1296
+ proxy.registerDeprecations([
1297
+ {deprecated: 'serializer:_default', valid: 'serializer:-default'},
1298
+ {deprecated: 'serializer:_rest', valid: 'serializer:-rest'},
1299
+ {deprecated: 'adapter:_rest', valid: 'adapter:-rest'}
1300
+ ]);
1301
+
1302
+ // new go forward paths
1303
+ application.register('serializer:-default', DS.JSONSerializer);
1304
+ application.register('serializer:-rest', DS.RESTSerializer);
1305
+ application.register('adapter:-rest', DS.RESTAdapter);
1261
1306
 
1262
1307
  // Eagerly generate the store so defaultStore is populated.
1263
1308
  // TODO: Do this in a finisher hook
@@ -1278,11 +1323,11 @@ Ember.onLoad('Ember.Application', function(Application) {
1278
1323
  });
1279
1324
 
1280
1325
  Application.initializer({
1281
- name: "dataAdapter",
1326
+ name: "data-adapter",
1282
1327
  before: "store",
1283
1328
 
1284
1329
  initialize: function(container, application) {
1285
- application.register('dataAdapter:main', DS.DebugAdapter);
1330
+ application.register('data-adapter:main', DS.DebugAdapter);
1286
1331
  }
1287
1332
  });
1288
1333
 
@@ -1294,7 +1339,7 @@ Ember.onLoad('Ember.Application', function(Application) {
1294
1339
  application.inject('controller', 'store', 'store:main');
1295
1340
  application.inject('route', 'store', 'store:main');
1296
1341
  application.inject('serializer', 'store', 'store:main');
1297
- application.inject('dataAdapter', 'store', 'store:main');
1342
+ application.inject('data-adapter', 'store', 'store:main');
1298
1343
  }
1299
1344
  });
1300
1345
 
@@ -1492,7 +1537,7 @@ DS.RecordArray = Ember.ArrayProxy.extend(Ember.Evented, {
1492
1537
  var store = get(this, 'store'),
1493
1538
  type = get(this, 'type');
1494
1539
 
1495
- store.fetchAll(type, this);
1540
+ return store.fetchAll(type, this);
1496
1541
  },
1497
1542
 
1498
1543
  /**
@@ -2026,7 +2071,7 @@ DS.Store = Ember.Object.extend({
2026
2071
  @default DS.RESTAdapter
2027
2072
  @type {DS.Adapter|String}
2028
2073
  */
2029
- adapter: '_rest',
2074
+ adapter: '-rest',
2030
2075
 
2031
2076
  /**
2032
2077
  Returns a JSON representation of the record using a custom
@@ -2067,7 +2112,7 @@ DS.Store = Ember.Object.extend({
2067
2112
  Ember.assert('You tried to set `adapter` property to an instance of `DS.Adapter`, where it should be a name or a factory', !(adapter instanceof DS.Adapter));
2068
2113
 
2069
2114
  if (typeof adapter === 'string') {
2070
- adapter = this.container.lookup('adapter:' + adapter) || this.container.lookup('adapter:application') || this.container.lookup('adapter:_rest');
2115
+ adapter = this.container.lookup('adapter:' + adapter) || this.container.lookup('adapter:application') || this.container.lookup('adapter:-rest');
2071
2116
  }
2072
2117
 
2073
2118
  if (DS.Adapter.detect(adapter)) {
@@ -2161,7 +2206,7 @@ DS.Store = Ember.Object.extend({
2161
2206
  title: "Rails is omakase"
2162
2207
  });
2163
2208
 
2164
- store.deletedRecord(post);
2209
+ store.deleteRecord(post);
2165
2210
  ```
2166
2211
 
2167
2212
  @method deleteRecord
@@ -2660,7 +2705,7 @@ DS.Store = Ember.Object.extend({
2660
2705
  type = this.modelFor(type);
2661
2706
 
2662
2707
  var typeMap = this.typeMapFor(type),
2663
- records = typeMap.records, record;
2708
+ records = typeMap.records.splice(0), record;
2664
2709
 
2665
2710
  while(record = records.pop()) {
2666
2711
  record.unloadRecord();
@@ -2697,7 +2742,7 @@ DS.Store = Ember.Object.extend({
2697
2742
  }).then(function(unreadPosts) {
2698
2743
  unreadPosts.get('length'); // 5
2699
2744
  var unreadPost = unreadPosts.objectAt(0);
2700
- unreadPosts.set('unread', false);
2745
+ unreadPost.set('unread', false);
2701
2746
  unreadPosts.get('length'); // 4
2702
2747
  });
2703
2748
  ```
@@ -3456,12 +3501,12 @@ function serializerFor(container, type, defaultSerializer) {
3456
3501
  return container.lookup('serializer:'+type) ||
3457
3502
  container.lookup('serializer:application') ||
3458
3503
  container.lookup('serializer:' + defaultSerializer) ||
3459
- container.lookup('serializer:_default');
3504
+ container.lookup('serializer:-default');
3460
3505
  }
3461
3506
 
3462
3507
  function defaultSerializer(container) {
3463
3508
  return container.lookup('serializer:application') ||
3464
- container.lookup('serializer:_default');
3509
+ container.lookup('serializer:-default');
3465
3510
  }
3466
3511
 
3467
3512
  function serializerForAdapter(adapter, type) {
@@ -4010,6 +4055,8 @@ createdState.uncommitted.rollback = function(record) {
4010
4055
  record.transitionTo('deleted.saved');
4011
4056
  };
4012
4057
 
4058
+ createdState.uncommitted.propertyWasReset = Ember.K;
4059
+
4013
4060
  updatedState.uncommitted.deleteRecord = function(record) {
4014
4061
  record.transitionTo('deleted.uncommitted');
4015
4062
  record.clearRelationships();
@@ -4066,7 +4113,7 @@ var RootState = {
4066
4113
  }
4067
4114
  },
4068
4115
 
4069
- // A record enters this state when the store askes
4116
+ // A record enters this state when the store asks
4070
4117
  // the adapter for its data. It remains in this state
4071
4118
  // until the adapter provides the requested data.
4072
4119
  //
@@ -4505,7 +4552,7 @@ DS.Errors = Ember.Object.extend(Ember.Enumerable, Ember.Evented, {
4505
4552
  */
4506
4553
 
4507
4554
  var get = Ember.get, set = Ember.set,
4508
- merge = Ember.merge, once = Ember.run.once;
4555
+ merge = Ember.merge;
4509
4556
 
4510
4557
  var retrieveFromCurrentState = Ember.computed('currentState', function(key, value) {
4511
4558
  return get(get(this, 'currentState'), key);
@@ -4537,7 +4584,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
4537
4584
  isEmpty: retrieveFromCurrentState,
4538
4585
  /**
4539
4586
  If this property is `true` the record is in the `loading` state. A
4540
- record enters this state when the store askes the adapter for its
4587
+ record enters this state when the store asks the adapter for its
4541
4588
  data. It remains in this state until the adapter provides the
4542
4589
  requested data.
4543
4590
 
@@ -4649,7 +4696,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
4649
4696
  var record = store.createRecord(App.Model);
4650
4697
  record.get('isNew'); // true
4651
4698
 
4652
- store.find('model', 1).then(function(model) {
4699
+ record.save().then(function(model) {
4653
4700
  model.get('isNew'); // false
4654
4701
  });
4655
4702
  ```
@@ -4771,7 +4818,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
4771
4818
  /**
4772
4819
  When the record is in the `invalid` state this object will contain
4773
4820
  any errors returned by the adapter. When present the errors hash
4774
- typically contains keys coresponding to the invalid property names
4821
+ typically contains keys corresponding to the invalid property names
4775
4822
  and values which are an array of error messages.
4776
4823
 
4777
4824
  ```javascript
@@ -5097,6 +5144,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5097
5144
  @private
5098
5145
  */
5099
5146
  updateRecordArrays: function() {
5147
+ this._updatingRecordArraysLater = false;
5100
5148
  get(this, 'store').dataWasUpdated(this.constructor, this);
5101
5149
  },
5102
5150
 
@@ -5211,7 +5259,11 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5211
5259
  @private
5212
5260
  */
5213
5261
  updateRecordArraysLater: function() {
5214
- Ember.run.once(this, this.updateRecordArrays);
5262
+ // quick hack (something like this could be pushed into run.once
5263
+ if (this._updatingRecordArraysLater) { return; }
5264
+ this._updatingRecordArraysLater = true;
5265
+
5266
+ Ember.run.schedule('actions', this, this.updateRecordArrays);
5215
5267
  },
5216
5268
 
5217
5269
  /**
@@ -5277,7 +5329,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5277
5329
  },
5278
5330
 
5279
5331
  /**
5280
- If the model `isDirty` this function will which discard any unsaved
5332
+ If the model `isDirty` this function will discard any unsaved
5281
5333
  changes
5282
5334
 
5283
5335
  Example
@@ -5478,8 +5530,8 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5478
5530
  },
5479
5531
 
5480
5532
  triggerLater: function() {
5481
- this._deferredTriggers.push(arguments);
5482
- once(this, '_triggerDeferredTriggers');
5533
+ if (this._deferredTriggers.push(arguments) !== 1) { return; }
5534
+ Ember.run.schedule('actions', this, '_triggerDeferredTriggers');
5483
5535
  },
5484
5536
 
5485
5537
  _triggerDeferredTriggers: function() {
@@ -5487,7 +5539,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
5487
5539
  this.trigger.apply(this, this._deferredTriggers[i]);
5488
5540
  }
5489
5541
 
5490
- this._deferredTriggers = [];
5542
+ this._deferredTriggers.length = 0;
5491
5543
  }
5492
5544
  });
5493
5545
 
@@ -5686,7 +5738,7 @@ DS.Model.reopenClass({
5686
5738
  ```
5687
5739
 
5688
5740
  - `name` the name of the current property in the iteration
5689
- - `type` a tring contrining the name of the type of transformed
5741
+ - `type` a string containing the name of the type of transformed
5690
5742
  applied to the attribute
5691
5743
 
5692
5744
  Note that in addition to a callback, you can also pass an optional target
@@ -5902,7 +5954,7 @@ var forEach = Ember.EnumerableUtils.forEach;
5902
5954
  @class RelationshipChange
5903
5955
  @namespace DS
5904
5956
  @private
5905
- @construtor
5957
+ @constructor
5906
5958
  */
5907
5959
  DS.RelationshipChange = function(options) {
5908
5960
  this.parentRecord = options.parentRecord;
@@ -5923,7 +5975,7 @@ DS.RelationshipChange = function(options) {
5923
5975
  @class RelationshipChangeAdd
5924
5976
  @namespace DS
5925
5977
  @private
5926
- @construtor
5978
+ @constructor
5927
5979
  */
5928
5980
  DS.RelationshipChangeAdd = function(options){
5929
5981
  DS.RelationshipChange.call(this, options);
@@ -5933,7 +5985,7 @@ DS.RelationshipChangeAdd = function(options){
5933
5985
  @class RelationshipChangeRemove
5934
5986
  @namespace DS
5935
5987
  @private
5936
- @construtor
5988
+ @constructor
5937
5989
  */
5938
5990
  DS.RelationshipChangeRemove = function(options){
5939
5991
  DS.RelationshipChange.call(this, options);
@@ -6802,7 +6854,7 @@ DS.Model.reopenClass({
6802
6854
  var options = this.metaForProperty(name).options;
6803
6855
 
6804
6856
  if (options.inverse === null) { return null; }
6805
-
6857
+
6806
6858
  var inverseName, inverseKind;
6807
6859
 
6808
6860
  if (options.inverse) {
@@ -7170,7 +7222,6 @@ DS.Model.reopen({
7170
7222
  */
7171
7223
 
7172
7224
  var get = Ember.get, set = Ember.set;
7173
- var once = Ember.run.once;
7174
7225
  var forEach = Ember.EnumerableUtils.forEach;
7175
7226
 
7176
7227
  /**
@@ -7189,8 +7240,9 @@ DS.RecordArrayManager = Ember.Object.extend({
7189
7240
  },
7190
7241
 
7191
7242
  recordDidChange: function(record) {
7192
- this.changedRecords.push(record);
7193
- once(this, this.updateRecordArrays);
7243
+ if (this.changedRecords.push(record) !== 1) { return; }
7244
+
7245
+ Ember.run.schedule('actions', this, this.updateRecordArrays);
7194
7246
  },
7195
7247
 
7196
7248
  recordArraysForRecord: function(record) {
@@ -7219,7 +7271,7 @@ DS.RecordArrayManager = Ember.Object.extend({
7219
7271
  }
7220
7272
  }, this);
7221
7273
 
7222
- this.changedRecords = [];
7274
+ this.changedRecords.length = 0;
7223
7275
  },
7224
7276
 
7225
7277
  _recordWasDeleted: function (record) {
@@ -7498,7 +7550,7 @@ DS.InvalidError.prototype = Ember.create(Error.prototype);
7498
7550
 
7499
7551
  ```javascript
7500
7552
  App.store = DS.Store.create({
7501
- adapter: App.MyAdapter.create()
7553
+ adapter: 'MyAdapter'
7502
7554
  });
7503
7555
  ```
7504
7556
 
@@ -8302,7 +8354,7 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8302
8354
  The key under `normalizeHash` is usually just the original key
8303
8355
  that was in the original payload. However, key names will be
8304
8356
  impacted by any modifications done in the `normalizePayload`
8305
- method. The `DS.RESTSerializer`'s default implemention makes no
8357
+ method. The `DS.RESTSerializer`'s default implementation makes no
8306
8358
  changes to the payload keys.
8307
8359
 
8308
8360
  @property normalizeHash
@@ -8568,7 +8620,8 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8568
8620
 
8569
8621
  for (var prop in payload) {
8570
8622
  var typeName = this.typeForRoot(prop),
8571
- isPrimary = typeName === primaryTypeName;
8623
+ type = store.modelFor(typeName),
8624
+ isPrimary = type.typeKey === primaryTypeName;
8572
8625
 
8573
8626
  // legacy support for singular resources
8574
8627
  if (isPrimary && Ember.typeOf(payload[prop]) !== "array" ) {
@@ -8576,8 +8629,6 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8576
8629
  continue;
8577
8630
  }
8578
8631
 
8579
- var type = store.modelFor(typeName);
8580
-
8581
8632
  /*jshint loopfunc:true*/
8582
8633
  forEach.call(payload[prop], function(hash) {
8583
8634
  var typeName = this.typeForRoot(prop),
@@ -8725,7 +8776,7 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8725
8776
  var typeName = this.typeForRoot(typeKey),
8726
8777
  type = store.modelFor(typeName),
8727
8778
  typeSerializer = store.serializerFor(type),
8728
- isPrimary = (!forcedSecondary && (typeName === primaryTypeName));
8779
+ isPrimary = (!forcedSecondary && (type.typeKey === primaryTypeName));
8729
8780
 
8730
8781
  /*jshint loopfunc:true*/
8731
8782
  var normalizedArray = map.call(payload[prop], function(hash) {
@@ -8982,7 +9033,8 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8982
9033
  @param {Object} options
8983
9034
  */
8984
9035
  serializeIntoHash: function(hash, type, record, options) {
8985
- hash[type.typeKey] = this.serialize(record, options);
9036
+ var root = Ember.String.camelize(type.typeKey);
9037
+ hash[root] = this.serialize(record, options);
8986
9038
  },
8987
9039
 
8988
9040
  /**
@@ -8999,7 +9051,7 @@ DS.RESTSerializer = DS.JSONSerializer.extend({
8999
9051
  var key = relationship.key,
9000
9052
  belongsTo = get(record, key);
9001
9053
  key = this.keyForAttribute ? this.keyForAttribute(key) : key;
9002
- json[key + "Type"] = belongsTo.constructor.typeKey;
9054
+ json[key + "Type"] = Ember.String.camelize(belongsTo.constructor.typeKey);
9003
9055
  }
9004
9056
  });
9005
9057
 
@@ -9114,7 +9166,7 @@ var forEach = Ember.ArrayPolyfills.forEach;
9114
9166
  @extends DS.Adapter
9115
9167
  */
9116
9168
  DS.RESTAdapter = DS.Adapter.extend({
9117
- defaultSerializer: '_rest',
9169
+ defaultSerializer: '-rest',
9118
9170
 
9119
9171
 
9120
9172
  /**
@@ -9172,7 +9224,7 @@ DS.RESTAdapter = DS.Adapter.extend({
9172
9224
  The `find` method makes an Ajax request to a URL computed by `buildURL`, and returns a
9173
9225
  promise for the resulting payload.
9174
9226
 
9175
- This method performs an HTTP `GET` request with the id provided as part of the querystring.
9227
+ This method performs an HTTP `GET` request with the id provided as part of the query string.
9176
9228
 
9177
9229
  @method find
9178
9230
  @param {DS.Store} store
@@ -9502,11 +9554,12 @@ DS.RESTAdapter = DS.Adapter.extend({
9502
9554
  @returns {String} path
9503
9555
  **/
9504
9556
  pathForType: function(type) {
9505
- return Ember.String.pluralize(type);
9557
+ var camelized = Ember.String.camelize(type);
9558
+ return Ember.String.pluralize(camelized);
9506
9559
  },
9507
9560
 
9508
9561
  /**
9509
- Takes an ajax response, and returns a relavant error.
9562
+ Takes an ajax response, and returns a relevant error.
9510
9563
 
9511
9564
  Returning a `DS.InvalidError` from this method will cause the
9512
9565
  record to transition into the `invalid` state and make the
@@ -9567,7 +9620,7 @@ DS.RESTAdapter = DS.Adapter.extend({
9567
9620
  @method ajax
9568
9621
  @private
9569
9622
  @param {String} url
9570
- @param {String} type The request type GET, POST, PUT, DELETE ect.
9623
+ @param {String} type The request type GET, POST, PUT, DELETE etc.
9571
9624
  @param {Object} hash
9572
9625
  @return {Promise} promise
9573
9626
  */
@@ -9593,7 +9646,7 @@ DS.RESTAdapter = DS.Adapter.extend({
9593
9646
  @method ajaxOptions
9594
9647
  @private
9595
9648
  @param {String} url
9596
- @param {String} type The request type GET, POST, PUT, DELETE ect.
9649
+ @param {String} type The request type GET, POST, PUT, DELETE etc.
9597
9650
  @param {Object} hash
9598
9651
  @return {Object} hash
9599
9652
  */
@@ -10073,8 +10126,13 @@ Ember.Inflector.inflector = new Ember.Inflector(Ember.Inflector.defaultRules);
10073
10126
  @module ember-data
10074
10127
  */
10075
10128
 
10076
- var get = Ember.get;
10077
- var forEach = Ember.EnumerableUtils.forEach;
10129
+ var get = Ember.get,
10130
+ forEach = Ember.EnumerableUtils.forEach,
10131
+ camelize = Ember.String.camelize,
10132
+ capitalize = Ember.String.capitalize,
10133
+ decamelize = Ember.String.decamelize,
10134
+ singularize = Ember.String.singularize,
10135
+ underscore = Ember.String.underscore;
10078
10136
 
10079
10137
  DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10080
10138
  // SERIALIZE
@@ -10087,7 +10145,7 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10087
10145
  @returns String
10088
10146
  */
10089
10147
  keyForAttribute: function(attr) {
10090
- return Ember.String.decamelize(attr);
10148
+ return decamelize(attr);
10091
10149
  },
10092
10150
 
10093
10151
  /**
@@ -10100,11 +10158,11 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10100
10158
  @returns String
10101
10159
  */
10102
10160
  keyForRelationship: function(key, kind) {
10103
- key = Ember.String.decamelize(key);
10161
+ key = decamelize(key);
10104
10162
  if (kind === "belongsTo") {
10105
10163
  return key + "_id";
10106
10164
  } else if (kind === "hasMany") {
10107
- return Ember.String.singularize(key) + "_ids";
10165
+ return singularize(key) + "_ids";
10108
10166
  } else {
10109
10167
  return key;
10110
10168
  }
@@ -10125,7 +10183,7 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10125
10183
  @param {Object} options
10126
10184
  */
10127
10185
  serializeIntoHash: function(data, type, record, options) {
10128
- var root = Ember.String.decamelize(type.typeKey);
10186
+ var root = underscore(decamelize(type.typeKey));
10129
10187
  data[root] = this.serialize(record, options);
10130
10188
  },
10131
10189
 
@@ -10141,7 +10199,7 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10141
10199
  var key = relationship.key,
10142
10200
  belongsTo = get(record, key);
10143
10201
  key = this.keyForAttribute(key);
10144
- json[key + "_type"] = Ember.String.capitalize(belongsTo.constructor.typeKey);
10202
+ json[key + "_type"] = capitalize(camelize(belongsTo.constructor.typeKey));
10145
10203
  },
10146
10204
 
10147
10205
  // EXTRACT
@@ -10154,8 +10212,8 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10154
10212
  @returns String the model's typeKey
10155
10213
  */
10156
10214
  typeForRoot: function(root) {
10157
- var camelized = Ember.String.camelize(root);
10158
- return Ember.String.singularize(camelized);
10215
+ var camelized = camelize(root);
10216
+ return singularize(camelized);
10159
10217
  },
10160
10218
 
10161
10219
  /**
@@ -10210,7 +10268,7 @@ DS.ActiveModelSerializer = DS.RESTSerializer.extend({
10210
10268
  var links = data.links;
10211
10269
 
10212
10270
  for (var link in links) {
10213
- var camelizedLink = Ember.String.camelize(link);
10271
+ var camelizedLink = camelize(link);
10214
10272
 
10215
10273
  if (camelizedLink !== link) {
10216
10274
  links[camelizedLink] = links[link];
@@ -10410,6 +10468,9 @@ function updatePayloadWithEmbedded(store, serializer, type, partial, payload) {
10410
10468
  */
10411
10469
 
10412
10470
  var forEach = Ember.EnumerableUtils.forEach;
10471
+ var decamelize = Ember.String.decamelize,
10472
+ underscore = Ember.String.underscore,
10473
+ pluralize = Ember.String.pluralize;
10413
10474
 
10414
10475
  /**
10415
10476
  The ActiveModelAdapter is a subclass of the RESTAdapter designed to integrate
@@ -10461,7 +10522,7 @@ var forEach = Ember.EnumerableUtils.forEach;
10461
10522
  **/
10462
10523
 
10463
10524
  DS.ActiveModelAdapter = DS.RESTAdapter.extend({
10464
- defaultSerializer: '_ams',
10525
+ defaultSerializer: '-active-model',
10465
10526
  /**
10466
10527
  The ActiveModelAdapter overrides the `pathForType` method to build
10467
10528
  underscored URLs by decamelizing and pluralizing the object type name.
@@ -10476,8 +10537,9 @@ DS.ActiveModelAdapter = DS.RESTAdapter.extend({
10476
10537
  @returns String
10477
10538
  */
10478
10539
  pathForType: function(type) {
10479
- var decamelized = Ember.String.decamelize(type);
10480
- return Ember.String.pluralize(decamelized);
10540
+ var decamelized = decamelize(type);
10541
+ var underscored = underscore(decamelized);
10542
+ return pluralize(underscored);
10481
10543
  },
10482
10544
 
10483
10545
  /**
@@ -10500,12 +10562,16 @@ DS.ActiveModelAdapter = DS.RESTAdapter.extend({
10500
10562
  var error = this._super(jqXHR);
10501
10563
 
10502
10564
  if (jqXHR && jqXHR.status === 422) {
10503
- var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)["errors"],
10565
+ var response = Ember.$.parseJSON(jqXHR.responseText),
10504
10566
  errors = {};
10505
10567
 
10506
- forEach(Ember.keys(jsonErrors), function(key) {
10507
- errors[Ember.String.camelize(key)] = jsonErrors[key];
10508
- });
10568
+ if (response.errors !== undefined) {
10569
+ var jsonErrors = response.errors;
10570
+
10571
+ forEach(Ember.keys(jsonErrors), function(key) {
10572
+ errors[Ember.String.camelize(key)] = jsonErrors[key];
10573
+ });
10574
+ }
10509
10575
 
10510
10576
  return new DS.InvalidError(errors);
10511
10577
  } else {
@@ -10530,8 +10596,14 @@ Ember.onLoad('Ember.Application', function(Application) {
10530
10596
  name: "activeModelAdapter",
10531
10597
 
10532
10598
  initialize: function(container, application) {
10533
- application.register('serializer:_ams', DS.ActiveModelSerializer);
10534
- application.register('adapter:_ams', DS.ActiveModelAdapter);
10599
+ var proxy = new DS.ContainerProxy(container);
10600
+ proxy.registerDeprecations([
10601
+ {deprecated: 'serializer:_ams', valid: 'serializer:-active-model'},
10602
+ {deprecated: 'adapter:_ams', valid: 'adapter:-active-model'}
10603
+ ]);
10604
+
10605
+ application.register('serializer:-active-model', DS.ActiveModelSerializer);
10606
+ application.register('adapter:-active-model', DS.ActiveModelAdapter);
10535
10607
  }
10536
10608
  });
10537
10609
  });