require 'msgpack' # Serialize objects to strings by default class Object def to_msgpack(packer) packer.pack(to_s) end def self.from_msgpack(packed) packed.unpack('A*').first end end # Support serialization of symbols MessagePack::DefaultFactory.register_type(0x01, Symbol) # For compatibility with the msgpack implementation in mruby MessagePack::Error = MessagePack::UnpackError # The msgpack implementation in mruby supports an ext type for classes class Class alias_method :to_msgpack_ext, :to_msgpack end class << Class alias_method :from_msgpack_ext, :from_msgpack end MessagePack::DefaultFactory.register_type(0x02, Class)