# -*- encoding : utf-8 -*- module RecordMarshal class << self # dump ActiveRecord instace with only attributes. # ["User", # {"id"=>30, # "email"=>"dddssddd@gmail.com", # "created_at"=>2012-07-25 18:25:57 UTC # } # ] def dump(record) [ record.class.name, record.attributes ] end # load a cached record def load(serialized) return unless serialized serialized[0].constantize.instantiate(serialized[1]) end def load_multi(serializeds) serializeds.map{|serialized| load(serialized)} end end end