module PipeRpc class Server < BasicInterface TRANSPORT_PREFIX = "__rpc_server__" include Kernel.dup_including :object_id, class: :__class__ private :__class__ def __rpc_server_class_name__ __class__.to_s end def __rpc_server_instance_id__ __id__.to_s end def __rpc_server_id__ @__rpc_server_id__ ||= [__rpc_server_class_name__, *__rpc_server_instance_id__].join('#').to_sym end def inspect __rpc_server_id__ end alias to_s inspect def to_rpc_transport(gateway) gateway.servers.add(self) unless gateway.servers.registered? __rpc_server_id__ "#{TRANSPORT_PREFIX}#{__rpc_server_id__}" end end class << Server def from_rpc_transport(gateway, transport) server = gateway.servers[transport.sub(Client::TRANSPORT_PREFIX, '').to_sym] SubjectServer.from_rpc_transport(gateway, server) end end end