Class: Faraday::Adapter::NetHttpStream::BodyStream
- Inherits:
-
Object
- Object
- Faraday::Adapter::NetHttpStream::BodyStream
- Defined in:
- lib/tent-client/faraday/chunked_adapter.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(env, &stream_body) ⇒ BodyStream
constructor
A new instance of BodyStream.
- #read ⇒ Object
Constructor Details
#initialize(env, &stream_body) ⇒ BodyStream
Returns a new instance of BodyStream.
9 10 11 12 |
# File 'lib/tent-client/faraday/chunked_adapter.rb', line 9 def initialize(env, &stream_body) @env, @stream_body = env, stream_body @read_body = false end |
Instance Method Details
#each(&block) ⇒ Object
14 15 16 17 18 |
# File 'lib/tent-client/faraday/chunked_adapter.rb', line 14 def each(&block) return if @read_body @stream_body.call(block) @read_body = true end |
#read ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/tent-client/faraday/chunked_adapter.rb', line 20 def read return @body if @body @body = "" each do |chunk| @body << chunk end @body end |