Module: Roda::RodaPlugins

Defined in:
lib/roda.rb,
lib/roda/plugins/h.rb,
lib/roda/plugins/halt.rb,
lib/roda/plugins/pass.rb,
lib/roda/plugins/flash.rb,
lib/roda/plugins/hooks.rb,
lib/roda/plugins/render.rb,
lib/roda/plugins/all_verbs.rb,
lib/roda/plugins/not_found.rb,
lib/roda/plugins/streaming.rb,
lib/roda/plugins/middleware.rb,
lib/roda/plugins/multi_route.rb,
lib/roda/plugins/error_handler.rb,
lib/roda/plugins/default_headers.rb,
lib/roda/plugins/header_matchers.rb,
lib/roda/plugins/indifferent_params.rb

Overview

Module in which all Roda plugins should be stored. Also contains logic for registering and loading plugins.

Defined Under Namespace

Modules: AllVerbs, Base, DefaultHeaders, ErrorHandler, Flash, H, Halt, HeaderMatchers, Hooks, IndifferentParams, Middleware, MultiRoute, NotFound, Pass, Render, Streaming

Class Method Summary collapse

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 RodaError if it exists but it does not register itself correctly.



69
70
71
72
73
74
75
76
# File 'lib/roda.rb', line 69

def self.load_plugin(name)
  h = @plugins
  unless plugin = @mutex.synchronize{h[name]}
    require "roda/plugins/#{name}"
    raise RodaError, "Plugin #{name} did not register itself correctly in Roda::RodaPlugins" unless plugin = @mutex.synchronize{h[name]}
  end
  plugin
end

.register_plugin(name, mod) ⇒ Object

Register the given plugin with Roda, so that it can be loaded using #plugin with a symbol. Should be used by plugin files.



80
81
82
# File 'lib/roda.rb', line 80

def self.register_plugin(name, mod)
  @mutex.synchronize{@plugins[name] = mod}
end