Class: Rack::EvilRobot

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/evil_robot.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ EvilRobot

Returns a new instance of EvilRobot.



3
4
5
6
# File 'lib/rack/evil_robot.rb', line 3

def initialize(app, options = {})
  @app = app
  @redirect_path = options[:redirect_path] || 'http://www.example.com/'
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rack/evil_robot.rb', line 8

def call(env)
  if evil_robot?(env)
    goodbye
  else
    if env['PATH_INFO'] =~ /honey_pot/
      [200, {'Content-Type' => 'text/html'}, ['Mmmm Honey...']]
    else
      @app.call(env)
    end
  end
end