Class HandlerPlugin
In: lib/webgen/plugin.rb
Parent: Plugin
RuntimeError PluginParamNotFound PluginNotFound ConfigurationFileInvalid CmdParse::CommandParser CommandParser DirectoryInfo GalleryStyle WebSiteStyle WebSiteTemplate SipttraStyle Test::Unit::TestCase TestCase PluginTestCase TagTestCase CmdParse::Command ShowCommand CheckCommand UseCommand CreateCommand TSort DependencyHash Hash Comparable Language ::Logger Logger Logger DEFAULT_WRAPPER_MODULE WebSite Qt::MainWindow MainWindow Qt::Dialog NewWebsiteDialog Qt::TextEdit LogWidget ::Rake::TaskLib WebgenTask ConfigurationFile Website PluginManager PluginLoader PluginParamValueNotFound Dummy Color CliUtils PluginDefs OpenStruct HandlerPlugin Plugin CommandPlugin lib/webgen/languages.rb lib/webgen/website.rb lib/webgen/gui/common.rb lib/webgen/plugin.rb lib/webgen/test.rb lib/webgen/cli.rb ClassMethods PluginDefs LanguageManager lib/webgen/gui/new_website_dlg.rb lib/webgen/gui/main.rb GUI lib/webgen/rake/webgentask.rb Rake Webgen dot/f_60.png

You can use this class for easily handling similiar things, for example, various markup to HTML converters.

To use it, just create a subclass of HandlerPlugin which will be the manager for a class of plugins. This subclass should specify all the methods, specific implementations should provide. The specific implementations should then be derived from this subclass, each using a different name for register_handler. Then you can retrieve a specific implementation by using the method registered_handlers[<NAME>] on the manager class.

Methods

Public Class methods

Defines the name for the specific handler under which the handler instance can be retrieved.

[Source]

     # File lib/webgen/plugin.rb, line 517
517:       def self.register_handler( name )
518:         self.config.infos[:handler_for] = name
519:       end

Returns the name of the specific handler.

[Source]

     # File lib/webgen/plugin.rb, line 522
522:       def self.registered_handler
523:         self.config.infos[:handler_for]
524:       end

Public Instance methods

Returns all handler instances as a hash. The names defined with HandlerPlugin#register_handler can be used to retrieve a specific handler instance.

[Source]

     # File lib/webgen/plugin.rb, line 528
528:       def registered_handlers
529:         if !defined?( @registered_handlers_cache ) || @cached_plugins_hash != @plugin_manager.plugins.keys.hash
530:           @registered_handlers_cache = {}
531:           @plugin_manager.plugins.each do |name, plugin|
532:             if plugin.kind_of?( self.class ) && plugin.class.registered_handler
533:               @registered_handlers_cache[plugin.class.registered_handler] = plugin
534:             end
535:           end
536:           @cached_plugins_hash = @plugin_manager.plugins.keys.hash
537:         end
538:         @registered_handlers_cache
539:       end

[Validate]