Sha256: 43577f8724fd719a3519931ba4a7f8c6573f992b916515afec2388b1a2afbc5e
Contents?: true
Size: 771 Bytes
Versions: 2
Compression:
Stored size: 771 Bytes
Contents
module Rlyeh module DeepOnes class Builder def initialize(app = nil, &block) @stack = [] @runner = app instance_eval(&block) if block_given? end def self.app(app = nil, &block) self.new(app, &block).to_app end def use(middleware, *args, &block) @stack << proc { |app| middleware.new(app, *args, &block) } end def use!(middleware, *args, &block) @stack.unshift lambda { |app| middleware.new(app, *args, &block) } end def run(app) @runner = app end def to_app @stack.reverse.inject(@runner) do |inner, outer| outer.call inner end end def call(env) to_app.call(env) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rlyeh-0.1.1 | lib/rlyeh/deep_ones/builder.rb |
rlyeh-0.0.2 | lib/rlyeh/deep_ones/builder.rb |