123456789_123456789_123456789_123456789_123456789_

Class: Mongoid::Railties::ActiveJobSerializers::BsonObjectIdSerializer

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveJob::Serializers::ObjectSerializer
Instance Chain:
self, ActiveJob::Serializers::ObjectSerializer
Inherits: ActiveJob::Serializers::ObjectSerializer
  • Object
Defined in: lib/mongoid/railties/bson_object_id_serializer.rb

Overview

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.

Instance Method Summary

Instance Method Details

#deserialize(string) ⇒ BSON::ObjectId

Deserializes the argument back into a ::BSON::ObjectId.

Parameters:

  • string (String)

    The string to deserialize.

Returns:

[ GitHub ]

  
# File 'lib/mongoid/railties/bson_object_id_serializer.rb', line 33

def deserialize(string)
  BSON::ObjectId.from_string(string)
end

#serialize(object)

Serializes the argument to be passed to the job.

Parameters:

[ GitHub ]

  
# File 'lib/mongoid/railties/bson_object_id_serializer.rb', line 24

def serialize(object)
  object.to_s
end

#serialize?(argument) ⇒ Boolean

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.
[ GitHub ]

  
# File 'lib/mongoid/railties/bson_object_id_serializer.rb', line 17

def serialize?(argument)
  argument.is_a?(BSON::ObjectId)
end