Module: PumaPlus::AppLoader::MiniBuilder
- Defined in:
- lib/puma_plus/app_loader.rb
Overview
A stand-in for Rack::Builder supporting just run and use, so an example
config.ru works with no gems installed. Not a Rack::Builder replacement --
real apps should install rack.
Class Method Summary collapse
Class Method Details
.build(source, path) ⇒ Object
41 42 43 44 45 |
# File 'lib/puma_plus/app_loader.rb', line 41 def self.build(source, path) builder = new_builder builder.instance_eval(source, path, 1) builder.to_app end |
.new_builder ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/puma_plus/app_loader.rb', line 47 def self.new_builder Object.new.tap do |o| o.instance_variable_set(:@run, nil) o.instance_variable_set(:@use, []) def o.run(app) = @run = app def o.use(middleware, *args, &blk) = @use << [middleware, args, blk] def o.map(*) = raise(NotImplementedError, "map requires the rack gem") def o.to_app raise "config.ru never called run()" unless @run @use.reverse.inject(@run) do |app, (mw, args, blk)| mw.new(app, *args, &blk) end end end end |