Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
15 lines (12 sloc) 394 Bytes
require_relative './message_pack_serializer/version'
require 'active_record'
require 'msgpack'
class ActiveRecord::Serializers::MessagePackSerializer
def self.load(binary)
return nil if binary.nil? || binary.match(/\A[[:space:]]*\z/)
MessagePack.unpack(binary.force_encoding("ASCII-8BIT"))
end
def self.dump(obj)
MessagePack.pack(obj).force_encoding("ASCII-8BIT")
end
end