1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/lib/puma/plugin.rb
2016-02-06 22:28:02 -08:00

30 lines
495 B
Ruby

require 'puma/plugin_loader'
module Puma
class Plugin
def self.extract_name(ary)
path = ary.first.split(":").first
m = %r!puma/plugin/([^/]*)\.rb$!.match(path)
return m[1]
end
def self.create(&blk)
name = extract_name(caller)
cls = Class.new(self)
cls.class_eval(&blk)
Plugins.register name, cls
end
def initialize(loader)
@loader = loader
end
def in_background(&blk)
Thread.new(&blk)
end
end
end