diff --git a/lib/model.js b/lib/model.js index 9c03ce03..432083ec 100644 --- a/lib/model.js +++ b/lib/model.js @@ -126,17 +126,9 @@ module.exports = function(registry) { var options = this.settings; var typeName = this.modelName; - var remotingOptions = {}; - extend(remotingOptions, options.remoting || {}); - - // create a sharedClass - var sharedClass = ModelCtor.sharedClass = new SharedClass( - ModelCtor.modelName, - ModelCtor, - remotingOptions - ); - // support remoting prototype methods + // it's important to setup this function *before* calling `new SharedClass` + // otherwise remoting metadata from our base model is picked up ModelCtor.sharedCtor = function(data, id, options, fn) { var ModelCtor = this; @@ -208,6 +200,16 @@ module.exports = function(registry) { ModelCtor.sharedCtor.returns = {root: true}; + var remotingOptions = {}; + extend(remotingOptions, options.remoting || {}); + + // create a sharedClass + var sharedClass = ModelCtor.sharedClass = new SharedClass( + ModelCtor.modelName, + ModelCtor, + remotingOptions + ); + // before remote hook ModelCtor.beforeRemote = function(name, fn) { var className = this.modelName;