mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Remove toplevel rack interspection, require rack on load instead
This commit is contained in:
parent
457a070382
commit
6bffcf75ab
1 changed files with 9 additions and 14 deletions
|
|
@ -1,16 +1,3 @@
|
|||
module PumaRackCompat
|
||||
BINDING = binding
|
||||
|
||||
def self.const_missing(cm)
|
||||
if cm == :Rack
|
||||
require 'rack'
|
||||
Rack
|
||||
else
|
||||
raise NameError, "constant undefined: #{cm}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Puma::Rack
|
||||
class Options
|
||||
def parse!(args)
|
||||
|
|
@ -181,11 +168,19 @@ module Puma::Rack
|
|||
|
||||
def self.new_from_string(builder_script, file="(rackup)")
|
||||
eval "Puma::Rack::Builder.new {\n" + builder_script + "\n}.to_app",
|
||||
PumaRackCompat::BINDING, file, 0
|
||||
TOPLEVEL_BINDING, file, 0
|
||||
end
|
||||
|
||||
def initialize(default_app = nil,&block)
|
||||
@use, @map, @run, @warmup = [], nil, default_app, nil
|
||||
|
||||
# Conditionally load rack now, so that any rack middlewares,
|
||||
# etc are available.
|
||||
begin
|
||||
require 'rack'
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
instance_eval(&block) if block_given?
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue