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

Merge pull request #535 from yeban/stream_closed

add closed? method on Stream object to inspect the object's open/close state
This commit is contained in:
Konstantin Haase 2012-12-13 05:28:46 -08:00
commit d2e8563f8b
2 changed files with 11 additions and 0 deletions

View file

@ -332,6 +332,10 @@ module Sinatra
end
alias errback callback
def closed?
@closed
end
end
# Allows to start sending data to the client even though later parts of

View file

@ -139,4 +139,11 @@ class StreamingTest < Test::Unit::TestCase
get '/'
assert ran
end
it 'has a public interface to inspect its open/closed state' do
stream = Stream.new(Stream) { |out| out << :foo }
assert !stream.closed?
stream.close
assert stream.closed?
end
end