B
Brian Buckley
Hello all,
I have an immutable class Foo (once a foo object is created its state
is fixed). Foo objects have a bunch of attributes so their yaml
strings are fairly long.
There is a small set of standard, frequently used foo objects and I
have defined these as constants right in the class (newed and set
each attribute for Foo::FOO1, Foo::FOO2, ... etc.).
When I YAML one of these standard foos to the database and back, it
seems inefficient to create and send a big long yaml string describing
each attribute and then on retrieval to create a whole new Foo object
when all I really want is to look up an already-made constant.
Is there a good solution to making the yaml-ing of constants efficient?
Thanks!
--Brian Buckley
foo =3D Foo:FOO1
data =3D foo.to_yaml # the yaml string here is unnecessarily long
foo =3D YAML::load(data) # and now after retrieval we have an
additional foo object when we really only need the one original
constant
-
I have an immutable class Foo (once a foo object is created its state
is fixed). Foo objects have a bunch of attributes so their yaml
strings are fairly long.
There is a small set of standard, frequently used foo objects and I
have defined these as constants right in the class (newed and set
each attribute for Foo::FOO1, Foo::FOO2, ... etc.).
When I YAML one of these standard foos to the database and back, it
seems inefficient to create and send a big long yaml string describing
each attribute and then on retrieval to create a whole new Foo object
when all I really want is to look up an already-made constant.
Is there a good solution to making the yaml-ing of constants efficient?
Thanks!
--Brian Buckley
foo =3D Foo:FOO1
data =3D foo.to_yaml # the yaml string here is unnecessarily long
foo =3D YAML::load(data) # and now after retrieval we have an
additional foo object when we really only need the one original
constant
-