Permalink
Browse files

Merge pull request #535 from yeban/stream_closed

add closed? method on Stream object to inspect the object's open/close state
  • Loading branch information...
2 parents c40fc9f + cc8502f commit d2e8563f8b96c237ec8d6e2fdace09a6738e4e8c @rkh rkh committed Dec 13, 2012
Showing with 11 additions and 0 deletions.
  1. +4 −0 lib/sinatra/base.rb
  2. +7 −0 test/streaming_test.rb
View
@@ -332,6 +332,10 @@ def callback(&block)
end
alias errback callback
+
+ def closed?
+ @closed
+ end
end
# Allows to start sending data to the client even though later parts of
View
@@ -139,4 +139,11 @@ def close.errback; end
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

0 comments on commit d2e8563

Please sign in to comment.