1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

make extending Stream with mixins easier

This commit is contained in:
Konstantin Haase 2011-08-17 14:06:05 +02:00
parent c2366764b9
commit 962d3f549e

View file

@ -243,9 +243,11 @@ module Sinatra
def initialize(scheduler = self.class, close = true, &back)
@back, @scheduler, @callback, @close = back.to_proc, scheduler, nil, close
super()
end
def close
return super if defined? super
@scheduler.schedule { @callback.call if @callback }
end
@ -267,10 +269,13 @@ module Sinatra
end
def callback(&block)
return super if defined? super
@callback = block
end
alias errback callback
def errback
super if defined? super
end
end
# Allows to start sending data to the client even though later parts of