From: why the lucky stiff Date: 2005-09-24T01:07:39+09:00 Subject: Re: Outputting custom YAML types in 1.8.3 Aaron Schrab wrote: > require 'yaml' > class Foo > def to_yaml_type; "!example.com,2005/Foo"; end > def to_yaml( opts={} ) > YAML::quick_emit( object_id, opts ) do |out| > out.map( to_yaml_type ) do |map| > map.add :foo, 'bar' > map.add :one, 2 > end > end > end > end > puts( { 'a' => Foo.new }.to_yaml ) > The out.map now takes YAML taguris. Try: YAML::quick_emit( YAML.tagurize( to_yaml_type[1..-1] ) ) Or I would recommend switching to taguris completely in your code. > def to_yaml_type; "tag:example.com,2005:Foo"; end > The YAML syntax "!example.com,2005/Foo" is just a shortcut for a taguri. > So there are a couple changes. First it's no longer outputting a line > of dashes at the beginning. Second, and more importantly, it's no > longer including the type information. > The long string of dashes at the beginning isn't required in YAML 1.0, so I've decided to default to headless. _why