summaryrefslogtreecommitdiff
path: root/lib/net/ssh/multi/channel_proxy.rb
blob: 99f7986efcd063435ee1e4ab55d796e204790699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Net; module SSH; module Multi
  class ChannelProxy
    attr_reader :on_confirm

    def initialize(&on_confirm)
      @on_confirm = on_confirm
      @recordings = []
      @channel = nil
    end

    def delegate_to(channel)
      @channel = channel
      @recordings.each do |sym, args, block|
        @channel.__send__(sym, *args, &block)
      end
    end

    def method_missing(sym, *args, &block)
      if @channel
        @channel.__send__(sym, *args, &block)
      else
        @recordings << [sym, args, block]
      end
    end
  end
end; end; end