Module: RecordMarshal
- Defined in:
- lib/second_level_cache/record_marshal.rb
Class Method Summary collapse
-
.dump(record) ⇒ Object
dump ActiveRecord instance with only attributes before type cast.
-
.load(serialized, &block) ⇒ Object
load a cached record.
-
.load_multi(serializeds, &block) ⇒ Object
load multi cached records.
Class Method Details
.dump(record) ⇒ Object
dump ActiveRecord instance with only attributes before type cast.
6 7 8 |
# File 'lib/second_level_cache/record_marshal.rb', line 6 def dump(record) [record.class.name, record.attributes_before_type_cast] end |
.load(serialized, &block) ⇒ Object
load a cached record
11 12 13 14 15 |
# File 'lib/second_level_cache/record_marshal.rb', line 11 def load(serialized, &block) return unless serialized serialized[0].constantize.instantiate(serialized[1], &block) end |
.load_multi(serializeds, &block) ⇒ Object
load multi cached records
18 19 20 |
# File 'lib/second_level_cache/record_marshal.rb', line 18 def load_multi(serializeds, &block) serializeds.map { |serialized| load(serialized, &block) } end |