From: jmay Date: 2007-03-21T06:40:07+09:00 Subject: Re: Defining my own class of unique objects On Mar 20, 12:44 pm, ara.t.how...@noaa.gov wrote: > On Wed, 21 Mar 2007, jmay wrote: > > Hi- > > > I'm trying to define a class with semantics similar to Fixnum, where every > > object is unique. Each object has some internal state, more complex that a > > single numeric value. Also, I want this to work across marshalling and > > YAML.load. Semantics like this: > > > Foo.new("stuff").object_id == Foo.new("stuff").object_id > > you can do this using > > http://raa.ruby-lang.org/project/multiton/ > Multiton is exactly what I want. Thanks Ara! To get it to work with YAML I needed to add a yaml_as declaration and define self#yaml_new in my class, and that seems to have worked. I'm not entirely satisfied with this solution, since it might break on subclasses, but it's good for now. Cheers, -Jason