Class: Async::HTTP::Body::Streamable
- Defined in:
- lib/async/http/body/streamable.rb
Overview
Invokes a callback once the body has finished reading.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(body, callback) ⇒ Streamable
constructor
A new instance of Streamable.
- #read ⇒ Object
- #stop ⇒ Object
Methods inherited from Wrapper
#close, #empty?, #inspect, #length
Methods inherited from Readable
#close, #each, #empty?, #join, #length
Constructor Details
#initialize(body, callback) ⇒ Streamable
Returns a new instance of Streamable.
36 37 38 39 40 |
# File 'lib/async/http/body/streamable.rb', line 36 def initialize(body, callback) super(body) @callback = callback end |
Class Method Details
.wrap(message, &block) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/async/http/body/streamable.rb', line 28 def self.wrap(, &block) if and .body .body = self.new(.body, block) else yield end end |
Instance Method Details
#read ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/async/http/body/streamable.rb', line 48 def read unless chunk = super @callback.call end return chunk end |
#stop ⇒ Object
42 43 44 45 46 |
# File 'lib/async/http/body/streamable.rb', line 42 def stop(*) super @callback.call end |