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:
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:
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.
Smells like you want the (name under some discussion) Multiton
pattern: http://rubyurl.com/qqw
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.