Module: Nanoc3::PluginRegistry::PluginMethods
- Included in:
- DataSource, Extra::VCS, Filter
- Defined in:
- lib/nanoc3/base/plugin_registry.rb
Overview
A module that contains class methods for plugins. It provides functions for setting identifiers, registering plugins and finding plugins. Plugin classes should extend this module.
Instance Method Summary collapse
-
#identifier(identifier) ⇒ void
Sets the identifier for this plugin.
-
#identifiers(*identifiers) ⇒ void
Sets the identifiers for this plugin.
-
#named(name) ⇒ Class
Returns the plugin with the given name (identifier).
-
#register(class_or_name, *identifiers) ⇒ void
Registers the given class as a plugin with the given identifier.
Instance Method Details
#identifier(identifier) ⇒ void
This method returns an undefined value.
Sets the identifier for this plugin.
30 31 32 |
# File 'lib/nanoc3/base/plugin_registry.rb', line 30 def identifier(identifier) register(self, identifier) end |
#identifiers(*identifiers) ⇒ void
This method returns an undefined value.
Sets the identifiers for this plugin.
21 22 23 |
# File 'lib/nanoc3/base/plugin_registry.rb', line 21 def identifiers(*identifiers) register(self, *identifiers) end |
#named(name) ⇒ Class
Returns the plugin with the given name (identifier)
58 59 60 |
# File 'lib/nanoc3/base/plugin_registry.rb', line 58 def named(name) Nanoc3::Plugin.find(self, name) end |
#register(class_or_name, *identifiers) ⇒ void
This method returns an undefined value.
Registers the given class as a plugin with the given identifier.
43 44 45 46 47 48 49 50 51 |
# File 'lib/nanoc3/base/plugin_registry.rb', line 43 def register(class_or_name, *identifiers) # Find plugin class klass = self klass = klass.superclass while klass.superclass.respond_to?(:register) # Register registry = Nanoc3::PluginRegistry.instance registry.register(klass, class_or_name, *identifiers) end |