From 9dc84d0ce31c901597d8596cf85778db54797b5a Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Sat, 31 Aug 2013 08:54:33 -0400 Subject: [PATCH] do some 'proper' 'inheritance' for plugins --- lib/server.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/server.js b/lib/server.js index cefedd4..e258629 100644 --- a/lib/server.js +++ b/lib/server.js @@ -71,8 +71,14 @@ server.prototype.errorHandler = function(error){ }; server.prototype.registerPlugin = function(plugin_constructor){ - util.inherits(plugin_constructor, yaps_plugin); - var plugin = new plugin_constructor(this.settings); + var new_plugin = function(options){ + yaps_plugin.call(this, options); + plugin_constructor.call(this, options); + }; + // dont judge me! + util._extend(new_plugin.prototype, yaps_plugin.prototype); + util._extend(new_plugin.prototype, plugin_constructor.prototype); + var plugin = new new_plugin(this.settings); this.enabledPlugins.push(plugin); for(var method in plugin.routes){ this.routes[method] = this.routes[method] || {};