Class: Thrift::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/thrift/serializer/serializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(protocol_factory = BinaryProtocolFactory.new) ⇒ Serializer

Returns a new instance of Serializer.



22
23
24
25
# File 'lib/thrift/serializer/serializer.rb', line 22

def initialize(protocol_factory = BinaryProtocolFactory.new)
  @transport = MemoryBufferTransport.new
  @protocol = protocol_factory.get_protocol(@transport)
end

Instance Method Details

#serialize(base) ⇒ Object



27
28
29
30
31
# File 'lib/thrift/serializer/serializer.rb', line 27

def serialize(base)
  @transport.reset_buffer
  base.write(@protocol)
  @transport.read(@transport.available)
end