Sha256: 6982c4d3ad1e6f47f3b009a3dbfb58e33b5f560950df674c807b6d859370bdf5
Contents?: true
Size: 1.07 KB
Versions: 30
Compression:
Stored size: 1.07 KB
Contents
module Mobility =begin Plugins allow modular customization of backends independent of the backend itself. They are enabled through {Mobility::Translations.plugins} (delegated to from {Mobility.configure}), which takes a block within which plugins can be declared in any order (dependencies will be resolved). =end module Plugins @plugins = {} @names = {} class << self # @param [Symbol] name Name of plugin to load. def load_plugin(name) return name if Module === name || name.nil? unless (plugin = @plugins[name]) require "mobility/plugins/#{name}" raise LoadError, "plugin #{name} did not register itself correctly in Mobility::Plugins" unless (plugin = @plugins[name]) end plugin end # @param [Module] plugin Plugin module to lookup. Plugin must already be loaded. def lookup_name(plugin) @names.fetch(plugin) end def register_plugin(name, plugin) @plugins[name] = plugin @names[plugin] = name end class LoadError < Error; end end end end
Version data entries
30 entries across 30 versions & 1 rubygems