123456789_123456789_123456789_123456789_123456789_

Class: Puma::PluginRegistry

Relationships & Source Files
Inherits: Object
Defined in: lib/puma/plugin.rb

Class Method Summary

Instance Method Summary

Constructor Details

.newPluginRegistry

[ GitHub ]

  
# File 'lib/puma/plugin.rb', line 31

def initialize
  @plugins = {}
  @background = []
end

Instance Method Details

#add_background(blk)

[ GitHub ]

  
# File 'lib/puma/plugin.rb', line 60

def add_background(blk)
  @background << blk
end

#find(name)

Raises:

[ GitHub ]

  
# File 'lib/puma/plugin.rb', line 40

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

[ GitHub ]

  
# File 'lib/puma/plugin.rb', line 64

def fire_background
  @background.each_with_index do |b, i|
    Thread.new do
      Puma.set_thread_name "plgn bg #{i}"
      b.call
    end
  end
end

#register(name, cls)

[ GitHub ]

  
# File 'lib/puma/plugin.rb', line 36

def register(name, cls)
  @plugins[name] = cls
end