module PipeRpc class Mapper; end class Hub::TransportMapper < Mapper def initialize(hub) @hub = hub end def to_transport(object) map(object) do |value| if value.respond_to? :to_rpc_transport value.to_rpc_transport(@hub) 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) @hub.servers[value.sub(Client::TRANSPORT_PREFIX, '').to_sym] elsif (value.is_a? String) and (value.start_with? Server::TRANSPORT_PREFIX) @hub.clients[value.sub(Server::TRANSPORT_PREFIX, '').to_sym] else value end end end end end