Pass fn to proxy method

This commit is contained in:
Brandon Keepers 2016-11-22 23:35:56 -06:00
parent b8a71dcfdc
commit f13c96b5a2
No known key found for this signature in database
GPG Key ID: F9533396D5FACBF6
1 changed files with 3 additions and 3 deletions

View File

@ -17,7 +17,7 @@ module.exports = class Workflow {
if (method !== 'constructor') { if (method !== 'constructor') {
// Define a new function in the API for this plugin method, forcing // Define a new function in the API for this plugin method, forcing
// the binding to this to prevent any tampering. // the binding to this to prevent any tampering.
this.api[method] = this.proxy(plugin, method).bind(this); this.api[method] = this.proxy(plugin[method]).bind(this);
} }
} }
} }
@ -37,10 +37,10 @@ module.exports = class Workflow {
}) && this.filterFn(event); }) && this.filterFn(event);
} }
proxy(plugin, method) { proxy(fn) {
return (...args) => { return (...args) => {
// Push new function on the stack that calls the plugin method with a context. // Push new function on the stack that calls the plugin method with a context.
this.stack.push(context => plugin[method](context, ...args)); this.stack.push(context => fn(context, ...args));
// Return the API to allow methods to be chained. // Return the API to allow methods to be chained.
return this.api; return this.api;