module Roda::RodaPlugins
Module in which all Roda
plugins should be stored. Also contains logic for registering and loading plugins.
Public Class Methods
load_plugin(name)
click to toggle source
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 RodaError
if it exists but it does not register itself correctly.
# File lib/roda.rb, line 69 def self.load_plugin(name) h = @plugins unless plugin = h[name] require "roda/plugins/#{name}" raise RodaError, "Plugin #{name} did not register itself correctly in Roda::RodaPlugins" unless plugin = h[name] end plugin end
register_plugin(name, mod)
click to toggle source
Register the given plugin with Roda
, so that it can be loaded using plugin with a symbol. Should be used by plugin files. Example:
Roda::RodaPlugins.register_plugin(:plugin_name, PluginModule)
# File lib/roda.rb, line 82 def self.register_plugin(name, mod) @plugins[name] = mod end