class SpeedGun::Store

Public Instance Methods

deserialize(key, msg) click to toggle source
# File lib/speed_gun/store.rb, line 9
def deserialize(key, msg)
  return nil if msg.nil? || msg.empty?
  hash = MessagePack.unpack(msg)
  klass, id = *key.split('/', 2)
  obj = Object.const_get(klass).from_hash(hash)
  obj.instance_variable_set(:@id, id)
  obj
end
serialize(obj) click to toggle source
# File lib/speed_gun/store.rb, line 5
def serialize(obj)
  ["#{obj.class.name}/#{obj.id}", MessagePack.pack(obj.to_hash)]
end