1
0
Fork 0
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:
Evan Phoenix 2015-08-03 21:54:55 -07:00
parent 457a070382
commit 6bffcf75ab

View file

@ -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