Sha256: 60f96c1e46e39a5f89b55b536d0c2506385da13ac7f7835d52835bd7e462fd2e

Contents?: true

Size: 726 Bytes

Versions: 11

Compression:

Stored size: 726 Bytes

Contents

require 'asir/transport/delegation'

module ASIR
  class Transport
    # !SLIDE
    # Select a Transport based on a Proc.
    class Demux < self
      include Delegation

      # Proc returning actual transport to use.
      # transport_proc.call(transport, message)
      attr_accessor :transport_proc

      # Only active during #send_message.
      attr_accessor_thread :transport

      # Support for Delegation mixin.
      def transports; [ transport ]; end

      def send_message message
        with_attr! :transport, transport_proc.call(self, message) do
          super
        end
      end

      def _send_message state
        transport.send_message(state.message)
      end
    end
    # !SLIDE END
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
asir-1.2.11 lib/asir/transport/demux.rb
asir-1.2.10 lib/asir/transport/demux.rb
asir-1.2.9 lib/asir/transport/demux.rb
asir-1.2.8 lib/asir/transport/demux.rb
asir-1.2.7 lib/asir/transport/demux.rb
asir-1.2.6 lib/asir/transport/demux.rb
asir-1.2.5 lib/asir/transport/demux.rb
asir-1.2.3 lib/asir/transport/demux.rb
asir-1.2.2 lib/asir/transport/demux.rb
asir-1.2.1 lib/asir/transport/demux.rb
asir-1.2.0 lib/asir/transport/demux.rb