Class: OptimusPrime::Wait

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Wait

Returns a new instance of Wait.



37
38
39
# File 'lib/optimus_prime.rb', line 37

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/optimus_prime.rb', line 41

def call(env)

  if match = env["PATH_INFO"].match(/\/wait\/(\d+)/)
    ttw = match.string.split("/").last.to_i
    sleep(ttw)
    return [200, {}, ["Inactive for: #{ttw}"]]
  end

  @app.call(env)
end