Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions lib/jsonrpc-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,26 @@ JsonRpcAdapter.errorHandler = function() {
};
};

// A mock wrapper function to help code generation via mockWrapper.toString()
function mockWrapper(method) {
return function(__args__) {
var args = Array.prototype.slice.call(arguments);
if (method.isStatic) {
method.getFunction().apply(method.ctor, args);
} else {
method.sharedCtor.invoke(method, function(err, instance) {
method.getFunction().apply(instance, args);
});
}
};
}

// A mock wrapper function to help code generation.
// Note that we can't make it a real function and use .toString() on it because
// that causes a whole world of trouble when we run strong-remoting's unit tests
// with code coverage.
var mockWrapper = [
'function mockWrapper(method) {',
' return function(__args__) {',
' var args = Array.prototype.slice.call(arguments);',
' if (method.isStatic) {',
' method.getFunction().apply(method.ctor, args);',
' } else {',
' method.sharedCtor.invoke(method, function(err, instance) {',
' method.getFunction().apply(instance, args);',
' });',
' }',
' };',
'}',
].join('\n');

/* istanbul ignore next */
JsonRpcAdapter.prototype.createHandler = function() {

var root = express.Router();
Expand Down