Module: Roda::RodaPlugins

Defined in:
lib/roda.rb,
lib/roda/plugins/h.rb,
lib/roda/plugins/csrf.rb,
lib/roda/plugins/halt.rb,
lib/roda/plugins/head.rb,
lib/roda/plugins/json.rb,
lib/roda/plugins/pass.rb,
lib/roda/plugins/path.rb,
lib/roda/plugins/flash.rb,
lib/roda/plugins/hooks.rb,
lib/roda/plugins/assets.rb,
lib/roda/plugins/mailer.rb,
lib/roda/plugins/render.rb,
lib/roda/plugins/static.rb,
lib/roda/plugins/caching.rb,
lib/roda/plugins/chunked.rb,
lib/roda/plugins/cookies.rb,
lib/roda/plugins/delegate.rb,
lib/roda/plugins/partials.rb,
lib/roda/plugins/all_verbs.rb,
lib/roda/plugins/drop_body.rb,
lib/roda/plugins/heartbeat.rb,
lib/roda/plugins/multi_run.rb,
lib/roda/plugins/not_found.rb,
lib/roda/plugins/streaming.rb,
lib/roda/plugins/empty_root.rb,
lib/roda/plugins/middleware.rb,
lib/roda/plugins/multi_view.rb,
lib/roda/plugins/websockets.rb,
lib/roda/plugins/content_for.rb,
lib/roda/plugins/delay_build.rb,
lib/roda/plugins/error_email.rb,
lib/roda/plugins/json_parser.rb,
lib/roda/plugins/match_affix.rb,
lib/roda/plugins/multi_route.rb,
lib/roda/plugins/not_allowed.rb,
lib/roda/plugins/render_each.rb,
lib/roda/plugins/run_handler.rb,
lib/roda/plugins/shared_vars.rb,
lib/roda/plugins/environments.rb,
lib/roda/plugins/hash_matcher.rb,
lib/roda/plugins/symbol_views.rb,
lib/roda/plugins/view_options.rb,
lib/roda/plugins/error_handler.rb,
lib/roda/plugins/path_matchers.rb,
lib/roda/plugins/path_rewriter.rb,
lib/roda/plugins/default_status.rb,
lib/roda/plugins/module_include.rb,
lib/roda/plugins/padrino_render.rb,
lib/roda/plugins/param_matchers.rb,
lib/roda/plugins/status_handler.rb,
lib/roda/plugins/default_headers.rb,
lib/roda/plugins/header_matchers.rb,
lib/roda/plugins/named_templates.rb,
lib/roda/plugins/sinatra_helpers.rb,
lib/roda/plugins/symbol_matchers.rb,
lib/roda/plugins/_erubis_escaping.rb,
lib/roda/plugins/params_capturing.rb,
lib/roda/plugins/response_request.rb,
lib/roda/plugins/slash_path_empty.rb,
lib/roda/plugins/static_path_info.rb,
lib/roda/plugins/backtracking_array.rb,
lib/roda/plugins/indifferent_params.rb,
lib/roda/plugins/per_thread_caching.rb,
lib/roda/plugins/class_level_routing.rb,
lib/roda/plugins/delete_empty_headers.rb,
lib/roda/plugins/precompile_templates.rb,
lib/roda/plugins/optimized_string_matchers.rb

Overview

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

Defined Under Namespace

Modules: AllVerbs, Assets, BacktrackingArray, Base, Caching, Chunked, ClassLevelRouting, ContentFor, Cookies, Csrf, DefaultHeaders, DefaultStatus, DelayBuild, Delegate, DeleteEmptyHeaders, DropBody, EmptyRoot, Environments, ErrorEmail, ErrorHandler, ErubisEscaping, Flash, H, Halt, HashMatcher, Head, HeaderMatchers, Heartbeat, Hooks, IndifferentParams, Json, JsonParser, Mailer, MatchAffix, Middleware, ModuleInclude, MultiRoute, MultiRun, MultiView, NamedTemplates, NotAllowed, NotFound, OptimizedStringMatchers, PadrinoRender, ParamMatchers, ParamsCapturing, Partials, Pass, Path, PathMatchers, PathRewriter, PerThreadCaching, PrecompileTemplates, Render, RenderEach, ResponseRequest, RunHandler, SharedVars, SinatraHelpers, SlashPathEmpty, Static, StaticPathInfo, StatusHandler, Streaming, SymbolMatchers, SymbolViews, ViewOptions, Websockets

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.



65
66
67
68
69
70
71
72
# File 'lib/roda.rb', line 65

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) ⇒ Object

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)


78
79
80
# File 'lib/roda.rb', line 78

def self.register_plugin(name, mod)
  @plugins[name] = mod
end