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_id__ "#{__rpc_server_class_name__}##{__id__}".to_sym end def to_rpc_transport(hub) hub.servers.add(self) unless hub.servers.registered? __rpc_server_id__ "#{TRANSPORT_PREFIX}#{__rpc_server_id__}" end end class << Server def instance_eval_for(server, *args, &block) Object.instance_method(:instance_eval).bind(server).call(*args, &block) end end end