Skip to content

Commit

Permalink
Merge branch 'master' of github.com:emberjs/data into remove-passing-…
Browse files Browse the repository at this point in the history
…factories-to-store-methods
  • Loading branch information
Stanley Stuart committed Jun 3, 2015
2 parents f4cd218 + cf87126 commit c3197d6
Show file tree
Hide file tree
Showing 36 changed files with 464 additions and 222 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ember-data",
"private": true,
"dependencies": {
"ember": "~1.11.1"
"ember": "~1.12.1"
},
"devDependencies": {
"qunit": "~1.17.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/ember-data/lib/adapters/build-url-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default Ember.Mixin.create({
@method buildURL
@param {String} modelName
@param {String|Array|Object} id single id or array of ids or query
@param {DS.Snapshot|Array} snapshot single snapshot or array of snapshots
@param {(String|Array|Object)} id single id or array of ids or query
@param {(DS.Snapshot|Array)} snapshot single snapshot or array of snapshots
@param {String} requestType
@param {Object} query object of query parameters to send for findQuery requests.
@return {String} url
Expand Down Expand Up @@ -136,7 +136,7 @@ export default Ember.Mixin.create({
/**
* @method urlForFindMany
* @param {Array} ids
* @param {String} type
* @param {String} modelName
* @param {Array} snapshots
* @return {String} url
*/
Expand Down Expand Up @@ -200,7 +200,7 @@ export default Ember.Mixin.create({
@method urlPrefix
@private
@param {String} path
@param {String} parentUrl
@param {String} parentURL
@return {String} urlPrefix
*/
urlPrefix: function(path, parentURL) {
Expand Down
30 changes: 14 additions & 16 deletions packages/ember-data/lib/adapters/fixture-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default Adapter.extend({
Implement this method in order to provide data associated with a type
@method fixturesForType
@param {Subclass of DS.Model} typeClass
@param {DS.Model} typeClass
@return {Array}
*/
fixturesForType: function(typeClass) {
Expand All @@ -82,18 +82,18 @@ export default Adapter.extend({
Implement this method in order to query fixtures data
@method queryFixtures
@param {Array} fixture
@param {Array} fixtures
@param {Object} query
@param {Subclass of DS.Model} typeClass
@return {Promise|Array}
@param {DS.Model} typeClass
@return {(Promise|Array)}
*/
queryFixtures: function(fixtures, query, typeClass) {
Ember.assert('Not implemented: You must override the DS.FixtureAdapter::queryFixtures method to support querying the fixture store.');
},

/**
@method updateFixtures
@param {Subclass of DS.Model} typeClass
@param {DS.Model} typeClass
@param {Array} fixture
*/
updateFixtures: function(typeClass, fixture) {
Expand All @@ -113,7 +113,7 @@ export default Adapter.extend({
@method mockJSON
@param {DS.Store} store
@param {Subclass of DS.Model} typeClass
@param {DS.Model} typeClass
@param {DS.Snapshot} snapshot
*/
mockJSON: function(store, typeClass, snapshot) {
Expand All @@ -123,7 +123,6 @@ export default Adapter.extend({
/**
@method generateIdForRecord
@param {DS.Store} store
@param {DS.Model} record
@return {String} id
*/
generateIdForRecord: function(store) {
Expand All @@ -133,7 +132,7 @@ export default Adapter.extend({
/**
@method find
@param {DS.Store} store
@param {subclass of DS.Model} typeClass
@param {DS.Model} typeClass
@param {String} id
@param {DS.Snapshot} snapshot
@return {Promise} promise
Expand All @@ -158,7 +157,7 @@ export default Adapter.extend({
/**
@method findMany
@param {DS.Store} store
@param {subclass of DS.Model} typeClass
@param {DS.Model} typeClass
@param {Array} ids
@param {Array} snapshots
@return {Promise} promise
Expand All @@ -185,8 +184,7 @@ export default Adapter.extend({
@private
@method findAll
@param {DS.Store} store
@param {subclass of DS.Model} typeClass
@param {String} sinceToken
@param {DS.Model} typeClass
@return {Promise} promise
*/
findAll: function(store, typeClass) {
Expand All @@ -203,9 +201,9 @@ export default Adapter.extend({
@private
@method findQuery
@param {DS.Store} store
@param {subclass of DS.Model} typeClass
@param {DS.Model} typeClass
@param {Object} query
@param {DS.AdapterPopulatedRecordArray} recordArray
@param {DS.AdapterPopulatedRecordArray} array
@return {Promise} promise
*/
findQuery: function(store, typeClass, query, array) {
Expand All @@ -225,7 +223,7 @@ export default Adapter.extend({
/**
@method createRecord
@param {DS.Store} store
@param {subclass of DS.Model} typeClass
@param {DS.Model} typeClass
@param {DS.Snapshot} snapshot
@return {Promise} promise
*/
Expand All @@ -242,7 +240,7 @@ export default Adapter.extend({
/**
@method updateRecord
@param {DS.Store} store
@param {subclass of DS.Model} type
@param {DS.Model} typeClass
@param {DS.Snapshot} snapshot
@return {Promise} promise
*/
Expand All @@ -259,7 +257,7 @@ export default Adapter.extend({
/**
@method deleteRecord
@param {DS.Store} store
@param {subclass of DS.Model} typeClass
@param {DS.Model} typeClass
@param {DS.Snapshot} snapshot
@return {Promise} promise
*/
Expand Down
14 changes: 7 additions & 7 deletions packages/ember-data/lib/adapters/rest-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export default Adapter.extend(BuildURLMixin, {
@method find
@param {DS.Store} store
@param {subclass of DS.Model} type
@param {DS.Model} type
@param {String} id
@param {DS.Snapshot} snapshot
@return {Promise} promise
Expand All @@ -357,7 +357,7 @@ export default Adapter.extend(BuildURLMixin, {
@private
@method findAll
@param {DS.Store} store
@param {subclass of DS.Model} type
@param {DS.Model} type
@param {String} sinceToken
@return {Promise} promise
*/
Expand Down Expand Up @@ -386,7 +386,7 @@ export default Adapter.extend(BuildURLMixin, {
@private
@method findQuery
@param {DS.Store} store
@param {subclass of DS.Model} type
@param {DS.Model} type
@param {Object} query
@return {Promise} promise
*/
Expand Down Expand Up @@ -428,7 +428,7 @@ export default Adapter.extend(BuildURLMixin, {
@method findMany
@param {DS.Store} store
@param {subclass of DS.Model} type
@param {DS.Model} type
@param {Array} ids
@param {Array} snapshots
@return {Promise} promise
Expand Down Expand Up @@ -521,7 +521,7 @@ export default Adapter.extend(BuildURLMixin, {
@method createRecord
@param {DS.Store} store
@param {subclass of DS.Model} type
@param {DS.Model} type
@param {DS.Snapshot} snapshot
@return {Promise} promise
*/
Expand All @@ -547,7 +547,7 @@ export default Adapter.extend(BuildURLMixin, {
@method updateRecord
@param {DS.Store} store
@param {subclass of DS.Model} type
@param {DS.Model} type
@param {DS.Snapshot} snapshot
@return {Promise} promise
*/
Expand All @@ -570,7 +570,7 @@ export default Adapter.extend(BuildURLMixin, {
@method deleteRecord
@param {DS.Store} store
@param {subclass of DS.Model} type
@param {DS.Model} type
@param {DS.Snapshot} snapshot
@return {Promise} promise
*/
Expand Down
20 changes: 17 additions & 3 deletions packages/ember-data/lib/ember-initializer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import setupContainer from 'ember-data/setup-container';
import { initializeInjects } from 'ember-data/setup-container';
import initializeStoreService from 'ember-data/instance-initializers/initialize-store-service';


var K = Ember.K;

Expand Down Expand Up @@ -42,11 +44,23 @@ Ember.onLoad('Ember.Application', function(Application) {

Application.initializer({
name: "ember-data",
initialize: setupContainer
initialize: initializeInjects
});

// Deprecated initializers to satisfy old code that depended on them
if (Application.instanceInitializer) {
Application.instanceInitializer({
name: "ember-data",
initialize: initializeStoreService
});
} else {
Ember.initializer({
name: "ember-data-store-service",
after: "ember-data",
initialize: initializeStoreService
});
}

// Deprecated initializers to satisfy old code that depended on them
Application.initializer({
name: "store",
after: "ember-data",
Expand Down
6 changes: 3 additions & 3 deletions packages/ember-data/lib/initializers/store-injections.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@param {Ember.Registry} registry
*/
export default function initializeStoreInjections(registry) {
registry.injection('controller', 'store', 'store:main');
registry.injection('route', 'store', 'store:main');
registry.injection('data-adapter', 'store', 'store:main');
registry.injection('controller', 'store', 'store:application');
registry.injection('route', 'store', 'store:application');
registry.injection('data-adapter', 'store', 'store:application');
}
10 changes: 3 additions & 7 deletions packages/ember-data/lib/initializers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,20 @@ export default function initializeStore(registry, application) {
registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });

registry.register('store:main', registry.lookupFactory('store:application') || (application && application.Store) || Store);
registry.register('store:application', application && application.Store || Store);

// allow older names to be looked up

var proxy = new ContainerProxy(registry);
proxy.registerDeprecations([
{ deprecated: 'serializer:_default', valid: 'serializer:-default' },
{ deprecated: 'serializer:_rest', valid: 'serializer:-rest' },
{ deprecated: 'adapter:_rest', valid: 'adapter:-rest' }
{ deprecated: 'adapter:_rest', valid: 'adapter:-rest' },
{ deprecated: 'store:main', valid: 'store:application' }
]);

// new go forward paths
registry.register('serializer:-default', JSONSerializer);
registry.register('serializer:-rest', RESTSerializer);
registry.register('adapter:-rest', RESTAdapter);

// Eagerly generate the store so defaultStore is populated.
// TODO: Do this in a finisher hook
var store = registry.lookup('store:main');
registry.register('service:store', store, { instantiate: false });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
Configures a registry for use with an Ember-Data
store.
@method initializeStore
@param {Ember.ApplicationInstance} applicationOrRegistry
*/
export default function initializeStoreService(applicationOrRegistry) {
var registry, container;
if (applicationOrRegistry.registry && applicationOrRegistry.container) {
// initializeStoreService was registered with an
// instanceInitializer. The first argument is the application
// instance.
registry = applicationOrRegistry.registry;
container = applicationOrRegistry.container;
} else {
// initializeStoreService was called by an initializer instead of
// an instanceInitializer. The first argument is a registy. This
// case allows ED to support Ember pre 1.12
registry = applicationOrRegistry;
container = registry.container();
}
// Eagerly generate the store so defaultStore is populated.
var store = container.lookup('store:application');
registry.register('service:store', store, { instantiate: false });
}
4 changes: 2 additions & 2 deletions packages/ember-data/lib/serializers/embedded-records-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ var EmbeddedRecordsMixin = Ember.Mixin.create({
}
```
@method normalize
@param {subclass of DS.Model} typeClass
@param {DS.Model} typeClass
@param {Object} hash to be normalized
@param {String} key the hash has been referenced by
@param {String} prop the hash has been referenced by
@return {Object} the normalized hash
**/
normalize: function(typeClass, hash, prop) {
Expand Down
Loading

0 comments on commit c3197d6

Please sign in to comment.