类:Mongoid::Railties::ActiveJobSerializers::BsonObjectIdSerializer

继承:
ActiveJob::Serializers::ObjectSerializer
  • 对象
显示全部
定义于:
lib/mongoid/railties/bson_object_id_serializer.rb

Overview

此类为 ActiveJob 提供BSON::ObjectId 的序列化和反序列化。

重要的是,此类仅在 Rails 可用时才加载,因为它依赖于 Rails 的 ActiveJob::Serializers::ObjectSerializer。

实例方法摘要折叠

实例方法详细信息

# deserialize (string) ⇒ BSON::ObjectId

将参数反序列化回BSON::ObjectId。

参数:

  • 字符串 ( string )

    要反序列化的string 。

返回:

  • ( BSON::ObjectId )

    反序列化的对象。



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

def 反序列化(字符串)
  BSON::ObjectId.from_string(字符串)
end

#serialize (对象) ⇒对象

序列化要传递给作业的参数。

参数:

  • 对象 ( BSON::ObjectId )

    要序列化的对象。



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

def 序列化(对象)
  对象.to_s
end

#serialize?(argument) ⇒ Boolean

返回此序列化器是否可以序列化该参数。

@param [ Object ] argument The argument to check.

@return [ true | false ] Whether the argument can be serialized.

返回:



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

def 序列化?(参数)
  参数.is_a?(BSON::ObjectId)
end