Class: Puma::PluginRegistry
- Inherits:
-
Object
- Object
- Puma::PluginRegistry
- Defined in:
- lib/puma/plugin.rb
Instance Method Summary collapse
- #add_background(blk) ⇒ Object
- #find(name) ⇒ Object
- #fire_background ⇒ Object
-
#initialize ⇒ PluginRegistry
constructor
A new instance of PluginRegistry.
- #register(name, cls) ⇒ Object
Constructor Details
#initialize ⇒ PluginRegistry
Returns a new instance of PluginRegistry.
29 30 31 32 |
# File 'lib/puma/plugin.rb', line 29 def initialize @plugins = {} @background = [] end |
Instance Method Details
#add_background(blk) ⇒ Object
58 59 60 |
# File 'lib/puma/plugin.rb', line 58 def add_background(blk) @background << blk end |
#find(name) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puma/plugin.rb', line 38 def find(name) name = name.to_s if cls = @plugins[name] return cls end begin require "puma/plugin/#{name}" rescue LoadError raise UnknownPlugin, "Unable to find plugin: #{name}" end if cls = @plugins[name] return cls end raise UnknownPlugin, "file failed to register a plugin" end |
#fire_background ⇒ Object
62 63 64 65 66 |
# File 'lib/puma/plugin.rb', line 62 def fire_background @background.each do |b| Thread.new(&b) end end |
#register(name, cls) ⇒ Object
34 35 36 |
# File 'lib/puma/plugin.rb', line 34 def register(name, cls) @plugins[name] = cls end |