Module: Sinatra::Synchrony

Defined in:
lib/sinatra/synchrony.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.overload_tcpsocket!Object



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

def overload_tcpsocket!
  require 'sinatra/synchrony/tcpsocket'
end

.patch_tests!Object



33
34
35
# File 'lib/sinatra/synchrony.rb', line 33

def patch_tests!
  require 'sinatra/synchrony/mock_session'
end

.registered(app) ⇒ Object



10
11
12
# File 'lib/sinatra/synchrony.rb', line 10

def self.registered(app)
  app.disable :threaded
end

Instance Method Details

#handle_exceptionObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sinatra/synchrony.rb', line 19

def handle_exception
  Proc.new do |env, e|
    if settings.show_exceptions?
      request = Sinatra::Request.new(env)
      printer = Sinatra::ShowExceptions.new(proc{ raise e })
      s, h, b = printer.call(env)
      [s, h, b]
    else
      [500, {}, ""]
    end
  end
end

#setup_sessions(builder) ⇒ Object



14
15
16
17
# File 'lib/sinatra/synchrony.rb', line 14

def setup_sessions(builder)
  builder.use Rack::FiberPool, {:rescue_exception => handle_exception } unless test?
  super
end