Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit cc8502f62be0c3f531f52bdd44f26d2601c6dd6c 1 parent 8adecc0
Anurag Priyam authored

Showing 2 changed files with 11 additions and 0 deletions. Show diff stats Hide diff stats

  1. +4 0 lib/sinatra/base.rb
  2. +7 0 test/streaming_test.rb
4 lib/sinatra/base.rb
@@ -332,6 +332,10 @@ def callback(&block)
332 332 end
333 333
334 334 alias errback callback
  335 +
  336 + def closed?
  337 + @closed
  338 + end
335 339 end
336 340
337 341 # Allows to start sending data to the client even though later parts of
7 test/streaming_test.rb
@@ -139,4 +139,11 @@ def close.errback; end
139 139 get '/'
140 140 assert ran
141 141 end
  142 +
  143 + it 'has a public interface to inspect its open/closed state' do
  144 + stream = Stream.new(Stream) { |out| out << :foo }
  145 + assert !stream.closed?
  146 + stream.close
  147 + assert stream.closed?
  148 + end
142 149 end

0 comments on commit cc8502f

Please sign in to comment.
Something went wrong with that request. Please try again.