跳至内容 跳至搜索

一个使用 MessagePackMessages 进行序列化的消息序列化器。

消息将被转换为以下结构的哈希表:

{
  p: <payload>,
  h: {
    header1: value1,
    header2: value2,
    ...
  }
}

然后它将被转换为 MessagePack 格式。

方法
B
D
L

实例公共方法

binary?()

# File activerecord/lib/active_record/encryption/message_pack_message_serializer.rb, line 34
def binary?
  true
end

dump(message)

# File activerecord/lib/active_record/encryption/message_pack_message_serializer.rb, line 22
def dump(message)
  raise Errors::ForbiddenClass unless message.is_a?(Message)
  ActiveSupport::MessagePack.dump(message_to_hash(message))
end

load(serialized_content)

# File activerecord/lib/active_record/encryption/message_pack_message_serializer.rb, line 27
def load(serialized_content)
  data = ActiveSupport::MessagePack.load(serialized_content)
  hash_to_message(data, 1)
rescue RuntimeError
  raise Errors::Decryption
end