-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
30 lines (30 loc) · 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"use strict";
var ModelRegister = (function () {
function ModelRegister(Model, reference) {
Model.model = reference;
Object.keys(Model.hooks).forEach(function (hook) {
switch (Model.hooks[hook].type) {
case 'operation':
reference.observe(Model.hooks[hook].name, function () {
Model[hook].apply(Model, arguments);
});
break;
case 'beforeRemote':
case 'afterRemote':
reference[Model.hooks[hook].type](Model.hooks[hook].name, function () {
Model[hook].apply(Model, arguments);
});
break;
default:
throw new Error('FireLoop: Unexpected hook type');
}
});
Object.keys(Model.remotes).forEach(function (remote) {
reference[remote] = function () { Model[remote].apply(Model, arguments); };
reference.remoteMethod(remote, Model.remotes[remote]);
});
}
return ModelRegister;
}());
exports.ModelRegister = ModelRegister;
//# sourceMappingURL=index.js.map