class Mongoid::Railties::ActiveJobSerializers::BsonObjectIdSerializer
This class provides serialization and deserialization of BSON::ObjectId for ActiveJob.
It is important that this class is loaded only when Rails
is available since it depends on Rails’ ActiveJob::Serializers::ObjectSerializer.
Public Instance Methods
deserialize(string)
click to toggle source
Deserializes the argument back into a BSON::ObjectId.
@param [ String ] string The string to deserialize.
@return [ BSON::ObjectId ] The deserialized object.
# File lib/mongoid/railties/bson_object_id_serializer.rb, line 33 def deserialize(string) BSON::ObjectId.from_string(string) end
serialize(object)
click to toggle source
Serializes the argument to be passed to the job.
@param [ BSON::ObjectId ] object The object to serialize.
# File lib/mongoid/railties/bson_object_id_serializer.rb, line 24 def serialize(object) object.to_s end
serialize?(argument)
click to toggle source
Returns whether the argument can be serialized by this serializer.
@param [ Object
] argument The argument to check.
@return [ true | false ] Whether the argument can be serialized.
# File lib/mongoid/railties/bson_object_id_serializer.rb, line 17 def serialize?(argument) argument.is_a?(BSON::ObjectId) end