我需要定义自定义方法来序列化/反序列化对象.我想做类似以下的事情.
class Person
def to_yaml_type
"!example.com,2010-11-30/Person"
end
def to_yaml
"string representing person"
end
def from_yaml(yaml)
Person.load_from(yaml)
end
end
Run Code Online (Sandbox Code Playgroud)
声明序列化/反序列化的正确方法是什么?