ОК, вот что я придумал
class Person
def to_yaml_type
"!example.com,2010-11-30/person"
end
def to_yaml(opts = {})
YAML.quick_emit( nil, opts ) { |out|
out.scalar( taguri, to_string_representation, :plain )
}
end
def to_string_representation
...
end
def Person.from_string_representation(string_representation)
... # returns a Person
end
end
YAML::add_domain_type("example.com,2010-11-30", "person") do |type, val|
Person.from_string_representation(val)
end