Skip to content

Commit

Permalink
Merge pull request #4897 from yethon/3250-privatize-buildInternalModel
Browse files Browse the repository at this point in the history
Deprecate buildInternalModel, add _buildInternalModel.
  • Loading branch information
bmac authored Mar 28, 2017
2 parents 42c97d4 + 6972fd7 commit f818378
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const {
_pushInternalModel,
_setupRelationships,
adapterFor,
buildInternalModel,
_buildInternalModel,
didUpdateAll,
modelFactoryFor,
modelFor,
Expand All @@ -121,7 +121,7 @@ const {
'_pushInternalModel',
'_setupRelationships',
'adapterFor',
'buildInternalModel',
'_buildInternalModel',
'didUpdateAll',
'modelFactoryFor',
'modelFor',
Expand Down Expand Up @@ -364,7 +364,7 @@ Store = Service.extend({
// Coerce ID to a string
properties.id = coerceId(properties.id);

let internalModel = this.buildInternalModel(normalizedModelName, properties.id);
let internalModel = this._buildInternalModel(normalizedModelName, properties.id);
let record = internalModel.getRecord();

// Move the record out of its initial `empty` state into
Expand Down Expand Up @@ -1132,7 +1132,7 @@ Store = Service.extend({
let internalModel = this._internalModelsFor(modelName).get(trueId);

if (!internalModel) {
internalModel = this.buildInternalModel(modelName, trueId);
internalModel = this._buildInternalModel(modelName, trueId);
}

return internalModel;
Expand Down Expand Up @@ -2548,17 +2548,17 @@ Store = Service.extend({
Build a brand new record for a given type, ID, and
initial data.
@method buildRecord
@method _buildInternalModel
@private
@param {String} modelName
@param {String} id
@param {Object} data
@return {InternalModel} internal model
*/
buildInternalModel(modelName, id, data) {
heimdall.increment(buildInternalModel);
_buildInternalModel(modelName, id, data) {
heimdall.increment(_buildInternalModel);

assert(`You can no longer pass a modelClass as the first argument to store.buildInternalModel. Pass modelName instead.`, typeof modelName === 'string');
assert(`You can no longer pass a modelClass as the first argument to store._buildInternalModel. Pass modelName instead.`, typeof modelName === 'string');

let recordMap = this._internalModelsFor(modelName);

Expand All @@ -2573,6 +2573,11 @@ Store = Service.extend({
return internalModel;
},

buildInternalModel(modelName, id, data) {
deprecate('buildInternalModel was documented as private and will be removed in the next version of Ember Data.');
return this._buildInternalModel(modelName, id, data);
},

//Called by the state machine to notify the store that the record is ready to be interacted with
recordWasLoaded(record) {
this.recordArrayManager.recordWasLoaded(record);
Expand Down

0 comments on commit f818378

Please sign in to comment.