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:
parent
c2366764b9
commit
962d3f549e
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue