module Tanker::Stream

Public Class Methods

do_stream_action(stream) { |read_method).get| ... } click to toggle source
# File lib/tanker/core/stream.rb, line 41
def self.do_stream_action(stream)
  in_wrapper = IoToTankerStreamWrapper.new(stream)
  tanker_stream = (yield in_wrapper.read_method).get
  out_wrapper = TankerStreamToIoWrapper.new(tanker_stream, in_wrapper)

  out_io = out_wrapper.init_io

  # The chain of possession is
  # returned IO -> out_wrapper -> in_wrapper
  # This allows us to close all the chain when the returned IO is closed
  out_io.instance_eval do
    @tanker_out_wrapper = out_wrapper

    extend IoMixin
  end

  out_io
end