Sha256: eb355823d9cdaba9bd2c92deb387e3537da3cbbf88bc15da38c1e9dcaa441fe1

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

module PipeRpc
  class Mapper; end

  class Hub::TransportMapper < Mapper
    def initialize(gateway)
      @gateway = gateway
    end

    def to_transport(object)
      map(object) do |value|
        if value.respond_to? :to_rpc_transport
          value.to_rpc_transport(@gateway)
        else
          value
        end
      end
    end

    def from_transport(object)
      map(object) do |value|
        if (value.is_a? String) and (value.start_with? Client::TRANSPORT_PREFIX)
          Server.from_rpc_transport(@gateway, value)
        elsif (value.is_a? String) and (value.start_with? Server::TRANSPORT_PREFIX)
          Client.from_rpc_transport(@gateway, value)
        else
          value
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipe_rpc-2.5.0 lib/pipe_rpc/hub_transport_mapper.rb