123456789_123456789_123456789_123456789_123456789_

Class: Puma::Plugin

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

Constant Summary

  • 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
    
    # File 'lib/puma/plugin.rb', line 78
    /
      \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

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(loader) ⇒ Plugin

[ GitHub ]

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

def initialize(loader)
  @loader = loader
end

Class Method Details

.create(&blk)

[ GitHub ]

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

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

  cls = Class.new(self)

  cls.class_eval(&blk)

  Plugins.register name, cls
end

.extract_name(ary)

[ GitHub ]

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

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

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

Instance Attribute Details

#workers_supported?Boolean (readonly)

[ GitHub ]

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

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

Instance Method Details

#in_background(&blk)

[ GitHub ]

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

def in_background(&blk)
  Plugins.add_background blk
end