76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Adds pluginhost constructor configuration and static configuration support
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @submodule pluginhost-config
d34e98574c42591f6e01ee482f163c7817a81324Satyen Desai * A protected initialization method, used by the host class to initialize
d34e98574c42591f6e01ee482f163c7817a81324Satyen Desai * plugin configurations passed the constructor, through the config object.
d34e98574c42591f6e01ee482f163c7817a81324Satyen Desai * Host objects should invoke this method at the appropriate time in their
d34e98574c42591f6e01ee482f163c7817a81324Satyen Desai * construction lifecycle.
d34e98574c42591f6e01ee482f163c7817a81324Satyen Desai * @method _initConfigPlugins
d34e98574c42591f6e01ee482f163c7817a81324Satyen Desai * @param {Object} config The configuration object passed to the constructor
d34e98574c42591f6e01ee482f163c7817a81324Satyen Desai * @protected
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @for Plugin.Host
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass PluginHost.prototype._initConfigPlugins = function(config) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // Class Configuration
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var classes = (this._getClasses) ? this._getClasses() : [this.constructor],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass constructor, i, classPlug, classUnplug, pluginClassName;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // TODO: Room for optimization. Can we apply statically/unplug in same pass?
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // subclasses over-write
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // subclasses over-write
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // User Configuration
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Registers plugins to be instantiated at the class level (plugins
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * which should be plugged into every instance of the class by default).
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @method plug
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Function} hostClass The host class on which to register the plugins
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined)
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @for Plugin.Host
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass PluginHost.plug = function(hostClass, plugin, config) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // Cannot plug into Base, since Plugins derive from Base [ will cause infinite recurrsion ]
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var p, i, l, name;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Unregisters any class level plugins which have been registered by the host class, or any
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * other class in the hierarchy.
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @method unplug
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Function} hostClass The host class from which to unregister the plugins
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Function | Array} plugin The plugin class, or an array of plugin classes
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @for Plugin.Host
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var p, i, l, name;