diff --git a/lib/models/model.js b/lib/models/model.js index 3c9a21c9..73ab8737 100644 --- a/lib/models/model.js +++ b/lib/models/model.js @@ -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];