Module: S3Browser::Store::StorePlugins
- Defined in:
- lib/s3browser/store.rb,
lib/s3browser/plugins/es.rb,
lib/s3browser/plugins/images.rb,
lib/s3browser/plugins/manager.rb
Overview
Ripped off from Roda - github.com/jeremyevans/roda
Defined Under Namespace
Modules: Base, ES, Images, Manager
Class Method Summary collapse
-
.load_plugin(name) ⇒ Object
If the registered plugin already exists, use it.
-
.register_plugin(name, mod) ⇒ Object
Register the given plugin with Store, 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 StoreError if it exists but it does not register itself correctly.
37 38 39 40 41 42 43 44 |
# File 'lib/s3browser/store.rb', line 37 def self.load_plugin(name) h = @plugins unless plugin = h[name] require "s3browser/plugins/#{name}" raise StoreError, "Plugin #{name} did not register itself correctly in S3Browser::Store::StorePlugins" unless plugin = h[name] end plugin end |
.register_plugin(name, mod) ⇒ Object
Register the given plugin with Store, so that it can be loaded using #plugin with a symbol. Should be used by plugin files. Example:
S3Browser::Store::StorePlugins.register_plugin(:plugin_name, PluginModule)
50 51 52 |
# File 'lib/s3browser/store.rb', line 50 def self.register_plugin(name, mod) @plugins[name] = mod end |