Module: ProxES::Container::Plugins
- Defined in:
- lib/proxes/container.rb
Overview
Ripped off from Roda - github.com/jeremyevans/roda
Defined Under Namespace
Modules: Base
Class Method Summary collapse
-
.load_plugin(name) ⇒ Object
If the registered plugin already exists, use it.
- .plugins ⇒ Object
-
.register_plugin(name, mod) ⇒ Object
Register the given plugin with Container, so that it can be loaded using #plugin with a symbol.
Class Method Details
.load_plugin(name) ⇒ Object
If the registered plugin already exists, use it. Otherwise, require it and return it. This raises a LoadError if such a plugin doesn’t exist, or a ContainerError if it exists but it does not register itself correctly.
43 44 45 46 47 48 49 50 |
# File 'lib/proxes/container.rb', line 43 def self.load_plugin(name) h = @plugins unless plugin = h[name] require "proxes/plugins/#{name}" raise ContainerError, "Plugin #{name} did not register itself correctly in ProxES::Container::Plugins" unless plugin = h[name] end plugin end |
.plugins ⇒ Object
60 61 62 |
# File 'lib/proxes/container.rb', line 60 def self.plugins @plugins end |
.register_plugin(name, mod) ⇒ Object
Register the given plugin with Container, so that it can be loaded using #plugin with a symbol. Should be used by plugin files. Example:
ProxES::Container::Plugins.register_plugin(:plugin_name, PluginModule)
56 57 58 |
# File 'lib/proxes/container.rb', line 56 def self.register_plugin(name, mod) @plugins[name] = mod end |