Module: RecordMarshal
- Defined in:
- lib/second_level_cache/record_marshal.rb
Class Method Summary collapse
-
.dump(record) ⇒ Object
dump ActiveRecord instace with only attributes.
-
.load(serialized) ⇒ Object
load a cached record.
- .load_multi(serializeds) ⇒ Object
Class Method Details
.dump(record) ⇒ Object
dump ActiveRecord instace with only attributes. [“User”,
{"id"=>30,
"email"=>"[email protected]",
"created_at"=>2012-07-25 18:25:57 UTC
}
]
12 13 14 15 16 17 |
# File 'lib/second_level_cache/record_marshal.rb', line 12 def dump(record) [ record.class.name, record.attributes ] end |
.load(serialized) ⇒ Object
load a cached record
20 21 22 23 24 25 |
# File 'lib/second_level_cache/record_marshal.rb', line 20 def load(serialized) return unless serialized record = serialized[0].constantize.allocate record.init_with('attributes' => serialized[1]) record end |
.load_multi(serializeds) ⇒ Object
27 28 29 |
# File 'lib/second_level_cache/record_marshal.rb', line 27 def load_multi(serializeds) serializeds.map{|serialized| load(serialized)} end |