Module: HTTPX::Plugins
- Defined in:
- lib/bnz_api/httpx.rb
Overview
All plugins should be stored under this module/namespace. Can register and load plugins.
Class Method Summary collapse
-
.load_plugin(name) ⇒ Object
Loads a plugin based on a name.
-
.register_plugin(name, mod) ⇒ Object
Registers a plugin (
mod
) in the central store indexed byname
.
Class Method Details
.load_plugin(name) ⇒ Object
Loads a plugin based on a name. If the plugin hasn’t been loaded, tries to load it from the load path under “httpx/plugins/” directory.
48 49 50 51 52 53 54 55 56 |
# File 'lib/bnz_api/httpx.rb', line 48 def self.load_plugin(name) h = @plugins m = @plugins_mutex unless (plugin = m.synchronize { h[name] }) require "httpx/plugins/#{name}" raise "Plugin #{name} hasn't been registered" unless (plugin = m.synchronize { h[name] }) end plugin end |
.register_plugin(name, mod) ⇒ Object
Registers a plugin (mod
) in the central store indexed by name
.
60 61 62 63 64 |
# File 'lib/bnz_api/httpx.rb', line 60 def self.register_plugin(name, mod) h = @plugins m = @plugins_mutex m.synchronize { h[name] = mod } end |