filterMethod can also be a direct callback

This commit is contained in:
Fabien Franzen 2014-08-04 19:08:43 +02:00
parent 097daf1deb
commit cc0d376cc3
1 changed files with 8 additions and 3 deletions

View File

@ -473,9 +473,14 @@ Model.scopeRemoting = function(relationName, relation, define) {
});
};
Model.nestRemoting = function(relationName, options) {
var regExp = /^__([^_]+)__([^_]+)$/;
Model.nestRemoting = function(relationName, options, cb) {
if (typeof options === 'function' && !cb) {
cb = options;
options = {};
}
options = options || {};
var regExp = /^__([^_]+)__([^_]+)$/;
var relation = this.relations[relationName];
if (relation && relation.modelTo && relation.modelTo.sharedClass) {
var self = this;
@ -504,7 +509,7 @@ Model.nestRemoting = function(relationName, options) {
// A method should return the method name to use, if it is to be
// included as a nested method - a falsy return value will skip.
var filter = options.filterMethod || function(method, relation) {
var filter = cb || options.filterMethod || function(method, relation) {
var matches = method.name.match(regExp);
if (matches) {
return '__' + matches[1] + '__' + relation.name + '__' + matches[2];