Merge pull request #3070 from strongloop/fix/sharedCtor-remoting
Fix construction of sharedCtor remoting metadata
This commit is contained in:
commit
8a2c01b3d8
22
lib/model.js
22
lib/model.js
|
@ -126,17 +126,9 @@ module.exports = function(registry) {
|
||||||
var options = this.settings;
|
var options = this.settings;
|
||||||
var typeName = this.modelName;
|
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
|
// 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) {
|
ModelCtor.sharedCtor = function(data, id, options, fn) {
|
||||||
var ModelCtor = this;
|
var ModelCtor = this;
|
||||||
|
|
||||||
|
@ -208,6 +200,16 @@ module.exports = function(registry) {
|
||||||
|
|
||||||
ModelCtor.sharedCtor.returns = {root: true};
|
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
|
// before remote hook
|
||||||
ModelCtor.beforeRemote = function(name, fn) {
|
ModelCtor.beforeRemote = function(name, fn) {
|
||||||
var className = this.modelName;
|
var className = this.modelName;
|
||||||
|
|
Loading…
Reference in New Issue