Module: Webgen::ExtensionManager
- Included in:
- ContentProcessor, Destination, ItemTracker, PathHandler, Source, Tag, Task
- Defined in:
- lib/webgen/extension_manager.rb
Overview
Provides common functionality for extension manager classes.
This module is intended for mixing into an extension manager class. An example for an extension manage class is the Webgen::ContentProcessor class which manages all content processors. Extension manager classes provide methods for registering a certain type of extension and invoking methods on them via a common interface.
It is assumed that one wants to associate one or more names with an extension object.
Instance Method Summary collapse
-
#initialize ⇒ Object
Create a new extension manager.
-
#initialize_copy(orig) ⇒ Object
:nodoc:.
-
#register(klass, options = {}, &block) ⇒ Object
Register a new extension.
-
#registered?(name) ⇒ Boolean
Return
trueif an extension with the given name has been registered with this manager class. -
#registered_extensions ⇒ Object
Return the meta data of all extensions registered with this manager class.
Instance Method Details
#initialize ⇒ Object
Create a new extension manager.
20 21 22 |
# File 'lib/webgen/extension_manager.rb', line 20 def initialize @extensions = {} end |
#initialize_copy(orig) ⇒ Object
:nodoc:
24 25 26 27 28 |
# File 'lib/webgen/extension_manager.rb', line 24 def initialize_copy(orig) #:nodoc: super @extensions = {} orig.instance_eval { @extensions }.each {|k,v| @extensions[k] = v.clone} end |
#register(klass, options = {}, &block) ⇒ Object
Register a new extension.
Note that this method has to be implemented by classes that include this module. It should register one or more names for an extension object by associating the names with the extension object data (should be an object that responds at least to :object) via the @extensions hash.
The simplest way to achieve this is to use the #do_register method.
37 38 39 |
# File 'lib/webgen/extension_manager.rb', line 37 def register(klass, = {}, &block) raise NotImplementedError end |
#registered?(name) ⇒ Boolean
Return true if an extension with the given name has been registered with this manager class.
110 111 112 |
# File 'lib/webgen/extension_manager.rb', line 110 def registered?(name) @extensions.has_key?(name.to_sym) end |
#registered_extensions ⇒ Object
Return the meta data of all extensions registered with this manager class.
115 116 117 |
# File 'lib/webgen/extension_manager.rb', line 115 def registered_extensions @extensions.dup end |