Class: ResqueDelayable::Serializer::MongoidSerializer
- Inherits:
-
Object
- Object
- ResqueDelayable::Serializer::MongoidSerializer
- Defined in:
- lib/resque-delayable/serializer/mongoid_serializer.rb
Constant Summary collapse
- PREFIX =
"Mongoid"
- MATCHER =
Regexp.new("^#{PREFIX}_([^_]+)_([^_]+)$")
Class Method Summary collapse
- .deserialize(object) ⇒ Object
- .deserialize_match(object) ⇒ Object
- .serialize(object) ⇒ Object
- .serialize_match(object) ⇒ Object
Class Method Details
.deserialize(object) ⇒ Object
20 21 22 23 |
# File 'lib/resque-delayable/serializer/mongoid_serializer.rb', line 20 def deserialize(object) match = MATCHER.match(object) match[1].constantize.find_by_id(id) end |
.deserialize_match(object) ⇒ Object
12 13 14 |
# File 'lib/resque-delayable/serializer/mongoid_serializer.rb', line 12 def deserialize_match(object) object.class == String && MATCHER.match(object) end |
.serialize(object) ⇒ Object
16 17 18 |
# File 'lib/resque-delayable/serializer/mongoid_serializer.rb', line 16 def serialize(object) "#{PREFIX}_#{object.class}_#{object.id}" end |
.serialize_match(object) ⇒ Object
8 9 10 |
# File 'lib/resque-delayable/serializer/mongoid_serializer.rb', line 8 def serialize_match(object) object.is_a?(Mongoid::Document) end |