Module: DDPlugin::Plugin
- Defined in:
- lib/ddplugin/plugin.rb
Overview
A module that contains class methods for plugins. It provides functions for setting identifiers and finding plugins. Plugin classes should extend this module.
Instance Method Summary collapse
-
#all ⇒ Enumerable<Class>
All classes of this type.
- #identifier(identifier = nil) ⇒ Object
- #identifiers(*identifiers) ⇒ Object
-
#named(identifier) ⇒ Class
The class with the given identifier.
-
#root_class ⇒ Class
The root class for this class.
Instance Method Details
#all ⇒ Enumerable<Class>
Returns All classes of this type.
56 57 58 |
# File 'lib/ddplugin/plugin.rb', line 56 def all DDPlugin::Registry.instance.find_all(self) end |
#identifier(identifier) ⇒ void #identifier ⇒ Symbol
47 48 49 50 51 52 53 |
# File 'lib/ddplugin/plugin.rb', line 47 def identifier(identifier = nil) if identifier identifiers(identifier) else identifiers.first end end |
#identifiers(*identifiers) ⇒ void #identifiers ⇒ Array<Symbol>
20 21 22 23 24 25 26 |
# File 'lib/ddplugin/plugin.rb', line 20 def identifiers(*identifiers) if identifiers.empty? DDPlugin::Registry.instance.identifiers_of(root_class, self) else DDPlugin::Registry.instance.register(root_class, self, *identifiers) end end |
#named(identifier) ⇒ Class
Returns The class with the given identifier.
63 64 65 |
# File 'lib/ddplugin/plugin.rb', line 63 def named(identifier) DDPlugin::Registry.instance.find(self, identifier) end |
#root_class ⇒ Class
Returns The root class for this class.
29 30 31 32 33 |
# File 'lib/ddplugin/plugin.rb', line 29 def root_class klass = self klass = klass.superclass while klass.superclass.respond_to?(:identifiers) klass end |