Class: Puma::PluginRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/plugin.rb

Instance Method Summary collapse

Constructor Details

#initializePluginRegistry

Returns a new instance of PluginRegistry.



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

def initialize
  @plugins = {}
end

Instance Method Details

#find(name) ⇒ Object

Raises:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/puma/plugin.rb', line 37

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

#register(name, cls) ⇒ Object



33
34
35
# File 'lib/puma/plugin.rb', line 33

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