Skip to content

Commit

Permalink
Release 2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Burgov committed May 10, 2014
1 parent b8d1645 commit 6ad4c54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions build/rrm.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@ var ObjectManager = function(proxyFactory) {
return null;
}

var schemaConstructor = entityClassMap[entityName].prototype.$schema.constructor;
var idProperty = 'id' in schemaConstructor ? schemaConstructor.id : 'id';

var map = objectMap[entityName];
for (var i in map) {
if (map[i][idProperty] == id) {
if (map[i][ObjectManager.getIdProperty(entityClassMap[entityName])] == id) {
return map[i];
}
}
Expand Down Expand Up @@ -195,7 +192,7 @@ var ObjectManager = function(proxyFactory) {
return entity;
}

var existing = getFromObjectMap(entityName, data.id);
var existing = getFromObjectMap(entityName, data[ObjectManager.getIdProperty(entityClassMap[entityName])]);
if (null !== existing) {
if (!(this.isProxy(existing))) {
this.update(existing, data);
Expand Down Expand Up @@ -319,6 +316,10 @@ Object.defineProperty(ObjectManager, 'prepareEntity', {
}
});

Object.defineProperty(ObjectManager, 'getIdProperty', { value: function(entityClass) {
var schemaConstructor = entityClass.prototype.$schema.constructor;
return 'id' in schemaConstructor ? schemaConstructor.id : 'id';
} });
"use strict";

var RRM = RRM || {};
Expand Down Expand Up @@ -592,15 +593,17 @@ var ProxyFactory = function() {
})
}

var idProperty = ObjectManager.getIdProperty(entityClass);

for (var i in entityClass.prototype.$schema) {
if (i == 'id') {
if (i == idProperty) {
continue;
}

this.addProperty(i);
}

Object.defineProperty(this, 'id', {
Object.defineProperty(this, idProperty, {
get: function() {
return id;
},
Expand Down
2 changes: 1 addition & 1 deletion build/rrm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6ad4c54

Please sign in to comment.