Module: Nanoc::PluginRegistry::PluginMethods
- Included in:
- DataSource, Extra::Checking::Check, Extra::Deployer, Extra::VCS, Filter
- Defined in:
- lib/nanoc/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)
-
- (Hash<Symbol, Class>) all
All plugins of this type, with keys being the identifiers and values the plugin classes.
-
- (Object) identifier(identifier = nil)
-
- (Object) identifiers(*identifiers)
-
- (Class) named(name)
Returns the plugin with the given name (identifier).
-
- (void) register(class_or_name, *identifiers)
Registers the given class as a plugin with the given identifier.
Instance Method Details
- (Hash<Symbol, Class>) all
Returns All plugins of this type, with keys being the identifiers and values the plugin classes
77 78 79 |
# File 'lib/nanoc/base/plugin_registry.rb', line 77 def all Nanoc::Plugin.find_all(self) end |
- (void) identifier(identifier) - (Symbol) identifier
48 49 50 51 52 53 54 |
# File 'lib/nanoc/base/plugin_registry.rb', line 48 def identifier(identifier = nil) if identifier identifiers(identifier) else Nanoc::PluginRegistry.instance.identifiers_of(superclass, self).first end end |
- (void) identifiers(*identifiers) - (Array<Symbol>) identifiers
29 30 31 32 33 34 35 |
# File 'lib/nanoc/base/plugin_registry.rb', line 29 def identifiers(*identifiers) if identifiers.empty? Nanoc::PluginRegistry.instance.identifiers_of(superclass, self) else register(self, *identifiers) end end |
- (Class) named(name)
Returns the plugin with the given name (identifier)
86 87 88 |
# File 'lib/nanoc/base/plugin_registry.rb', line 86 def named(name) Nanoc::Plugin.find(self, name) end |
- (void) register(class_or_name, *identifiers)
This method returns an undefined value.
Registers the given class as a plugin with the given identifier.
65 66 67 68 69 70 71 72 73 |
# File 'lib/nanoc/base/plugin_registry.rb', line 65 def register(class_or_name, *identifiers) # Find plugin class klass = self klass = klass.superclass while klass.superclass.respond_to?(:register) # Register registry = Nanoc::PluginRegistry.instance registry.register(klass, class_or_name, *identifiers) end |