Permalink
Browse files

add closed? method on Stream object to inspect the object's open/clos…

…e state

Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
  • Loading branch information...
1 parent 8adecc0 commit cc8502f62be0c3f531f52bdd44f26d2601c6dd6c @yeban yeban committed Jun 24, 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 cc8502f

Please sign in to comment.