timocratic (owner)

Revisions

gist: 97296 Download_button fork
public
Public Clone URL: git://gist.github.com/97296.git
Embed All Files: show embed
middleware_builder_access.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Rack
  class Builder
    def use(middleware, *args, &block)
      middleware.instance_variable_set "@rack_builder", self
      def middleware.rack_builder
        @rack_builder
      end
      @ins << lambda { |app| middleware.new(app, *args, &block) }
    end
    
    def leaf_app
      @ins.last
    end
  end
 
  class Flash
    def initialize(app, opts={})
      rack_app = self.class.rack_builder.leaf_app
      def rack_app.flash
        env['rack-flash']
      end
      @app, @opts = app, opts
    end
  end
end