Class: Puma::Plugin

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

Constant Summary collapse

CALLER_FILE =

Matches

"C:/Ruby22/lib/ruby/gems/2.2.0/gems/puma-3.0.1/lib/puma/plugin/tmp_restart.rb:3:in `<top (required)>'"
AS
C:/Ruby22/lib/ruby/gems/2.2.0/gems/puma-3.0.1/lib/puma/plugin/tmp_restart.rb
/
  \A       # start of string
  .+       # file path (one or more characters)
  (?=      # stop previous match when
    :\d+     # a colon is followed by one or more digits
    :in      # followed by a colon followed by in
  )
/x

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(loader) ⇒ Plugin

Returns a new instance of Plugin.



91
92
93
# File 'lib/puma/plugin.rb', line 91

def initialize(loader)
  @loader = loader
end

Class Method Details

.create(&blk) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/puma/plugin.rb', line 81

def self.create(&blk)
  name = extract_name(caller)

  cls = Class.new(self)

  cls.class_eval(&blk)

  Plugins.register name, cls
end

.extract_name(ary) ⇒ Object



74
75
76
77
78
79
# File 'lib/puma/plugin.rb', line 74

def self.extract_name(ary)
  path = ary.first[CALLER_FILE]

  m = %r!puma/plugin/([^/]*)\.rb$!.match(path)
  return m[1]
end

Instance Method Details

#in_background(&blk) ⇒ Object



95
96
97
# File 'lib/puma/plugin.rb', line 95

def in_background(&blk)
  Thread.new(&blk)
end

#workers_supported?Boolean

Returns:

  • (Boolean)


99
100
101
102
# File 'lib/puma/plugin.rb', line 99

def workers_supported?
  return false if Puma.jruby? || Puma.windows?
  true
end