Browse Source

do some 'proper' 'inheritance' for plugins

master
Brett Langdon 12 years ago
parent
commit
9dc84d0ce3
1 changed files with 8 additions and 2 deletions
  1. +8
    -2
      lib/server.js

+ 8
- 2
lib/server.js View File

@ -71,8 +71,14 @@ server.prototype.errorHandler = function(error){
}; };
server.prototype.registerPlugin = function(plugin_constructor){ 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); this.enabledPlugins.push(plugin);
for(var method in plugin.routes){ for(var method in plugin.routes){
this.routes[method] = this.routes[method] || {}; this.routes[method] = this.routes[method] || {};


Loading…
Cancel
Save