Merge pull request #3070 from strongloop/fix/sharedCtor-remoting

Fix construction of sharedCtor remoting metadata
This commit is contained in:
Miroslav Bajtoš 2017-01-05 11:37:30 +01:00 committed by GitHub
commit 8a2c01b3d8
1 changed files with 12 additions and 10 deletions

View File

@ -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;