dhh (owner)

Revisions

  • b332a6 Wed Dec 17 10:21:36 -0800 2008
gist: 37152 Download_button fork
public
Public Clone URL: git://gist.github.com/37152.git
Embed All Files: show embed
Ruby #
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
26
27
28
29
30
class Poller < Rails::Metal
  def process(env)
    if env["PATH_INFO"] =~ /^\/poller_rack/
      return [200, {"Content-Type" => "text/html"}, ["Hello, World!"]]
    end
  end
end
 
 
# Implementation:
 
module Rails
  class Metal
    def initialize(app, *args)
      @app = app; @args = args
    end
        
    def call(env)
      if result = process(env)
        result
      else
        @app.call(env)
      end
    end
    
    def process(env)
      false
    end
  end
end