From: Travis Smith Date: 2005-03-22T11:23:15+09:00 Subject: Re: YAML Parsing, ignoring objects? I missed that last part on that page and it turns out that's exactly what I want. Thanks for pointing that out. Minimal maintenance with leaving most of the work to YAML parser. On Tue, 22 Mar 2005 05:22:23 +0900, why the lucky stiff wrote: > Travis Smith wrote: > > >I have a class which when YAMLized produces... > > > >--- !ruby/object:Player > >name: dude > >password: dude > >session: !ruby/object:TCPSocket {} > >thread: !ruby/object:Thread {} > > > >I'd like to figure out a way for it to just ignore the Thread and/or > >TCPSocket type. It won't choke on the socket, but it will loading up > >the Thread. Can I add a domain type that will just produce nil not > >matter what happens? > > > > > Hey, Travis. You can define to_yaml_properties for any object, which is > simply an method which returns an array of properties you want in your > YAML doc, in the order you like. > > class Player > def to_yaml_properties; ['@name', '@password']; end > end > > You can read more in the docs[1]. See the section "Type Families". > > _why > > [1] http://yaml4r.sf.net/doc/ > > -- ~Travis