Module: Moneta::Net Private

Included in:
Adapters::Client, Server
Defined in:
lib/moneta/net.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Error

Constant Summary collapse

DEFAULT_PORT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

9000

Instance Method Summary collapse

Instance Method Details

#pack(o) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
# File 'lib/moneta/net.rb', line 8

def pack(o)
  s = Marshal.dump(o)
  [s.bytesize].pack('N') << s
end

#read(io) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
16
# File 'lib/moneta/net.rb', line 13

def read(io)
  size = io.read(4).unpack('N').first
  Marshal.load(io.read(size))
end

#write(io, o) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
# File 'lib/moneta/net.rb', line 18

def write(io, o)
  io.write(pack(o))
end