Fix scopeMethods closure issue

This commit is contained in:
Fabien Franzen 2014-08-11 19:07:48 +02:00
parent dd9ea68f47
commit 3b398c5f77
1 changed files with 7 additions and 4 deletions

View File

@ -64,12 +64,15 @@ function extendScopeMethods(definition, scopeMethods, ext) {
if (typeof ext === 'function') {
customMethods = ext.call(definition, scopeMethods, relationClass);
} else if (typeof ext === 'object') {
function createFunc(definition, relationMethod) {
return function() {
var relation = new relationClass(definition, this);
return relationMethod.apply(relation, arguments);
};
};
for (var key in ext) {
var relationMethod = ext[key];
var method = scopeMethods[key] = function () {
var relation = new relationClass(definition, this);
return relationMethod.apply(relation, arguments);
};
var method = scopeMethods[key] = createFunc(definition, relationMethod);
if (relationMethod.shared) {
sharedMethod(definition, key, method, relationMethod);
}