Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming cleanup #4601

Merged
merged 1 commit into from
Oct 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions addon/-private/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ export function debugSeal() {
return Ember.debugSeal(...arguments);
}

function checkPolymorphic(typeClass, addedRecord) {
if (typeClass.__isMixin) {
function checkPolymorphic(modelClass, addedModelClass) {
if (modelClass.__isMixin) {
//TODO Need to do this in order to support mixins, should convert to public api
//once it exists in Ember
return typeClass.__mixin.detect(addedRecord.type.PrototypeMixin);
return modelClass.__mixin.detect(addedModelClass.PrototypeMixin);
}
if (Ember.MODEL_FACTORY_INJECTIONS) {
typeClass = typeClass.superclass;
modelClass = modelClass.superclass;
}
return typeClass.detect(addedRecord.type);
return modelClass.detect(addedModelClass);
}

/*
Expand All @@ -57,19 +57,18 @@ function checkPolymorphic(typeClass, addedRecord) {
`record.relationshipFor(key)`.

@method assertPolymorphicType
@param {InternalModel} record
@param {InternalModel} internalModel
@param {RelationshipMeta} relationshipMeta retrieved via
`record.relationshipFor(key)`
@param {InternalModel} addedRecord record which
should be added/set for the relationship
*/
export function assertPolymorphicType(record, relationshipMeta, addedRecord) {
var addedType = addedRecord.type.modelName;
var recordType = record.type.modelName;
var key = relationshipMeta.key;
var typeClass = record.store.modelFor(relationshipMeta.type);
export function assertPolymorphicType(parentInternalModel, relationshipMeta, addedInternalModel) {
let addedModelName = addedInternalModel.modelName;
let parentModelName = parentInternalModel.modelName;
let key = relationshipMeta.key;
let relationshipClass = parentInternalModel.store.modelFor(relationshipMeta.type);
let assertionMessage = `You cannot add a record of modelClass '${addedModelName}' to the '${parentModelName}.${key}' relationship (only '${relationshipClass.modelName}' allowed)`;

var assertionMessage = `You cannot add a record of type '${addedType}' to the '${recordType}.${key}' relationship (only '${typeClass.modelName}' allowed)`;

assert(assertionMessage, checkPolymorphic(typeClass, addedRecord));
assert(assertionMessage, checkPolymorphic(relationshipClass, addedInternalModel.modelClass));
}
1 change: 1 addition & 0 deletions addon/-private/system/many-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default Ember.Object.extend(Ember.MutableArray, Ember.Evented, {
if (!this.currentState[index]) {
return undefined;
}

return this.currentState[index].getRecord();
},

Expand Down
Loading