> -----Original Message-----
> From: Gennady Bystritsky [mailto:Gennady.Bystritsky / quest.com]=20
> Sent: Thursday, January 29, 2009 9:32 PM
> To: ruby-talk ML
> Subject: YAML to anchor same strings in dumps
>=20
> Hi, there
>=20
> Is there any way to make YAML alias same strings in dumps?=20
> The following code fragment:
>=20
> require 'yaml'
> s =3D 'a' * 10
> puts [ s, s ].to_yaml
>=20
> Produces this:
> ---
> - aaaaaaaaaa
> - aaaaaaaaaa
>=20
> While I need:
> ---
> - &id001 aaaaaaaaaa
> - *id001

Found a solution:

module ComplexYamlObject
  def is_complex_yaml?
    true
  end
end

s =3D 'a' * 10
s.extend ComplexYamlObject
puts [ s, s ].to_yaml

Then the output will be just as I originally wanted:

---
- &id001 aaaaaaaaaa
- *id001

Thought somebody might find it useful,
Gennady.