I was usually using Storable with nstore, but now I have a module that has CODE and apparently Storable doesn't like that.
I found YAML (and YAML::XS which I can't really get to work).
I also experimented a bit with MooseX::Storage without much success.
Are there other alternatives? What would you recommend?
You can dump a coderef with Data::Dumper after setting
$Data::Dumper::Deparseto a true value, but this is only intended for debugging purposes, not for serialization.I would suggest you go back to looking at why MooseX::Storage isn't working out for you, as the authors tried really hard to present a well-abstracted and robust solution for Moose object serialization.
Update: it looks like you are running into issues serializing the
_offset_subattribute, as described in this question. Since that attribute has a builder, and its construction is fairly trivial (it just looks at the current value of another attribute), you shouldn't need to serialize it at all -- when you deserialize your object and want to use it again, the builder will be invoked the first time you call$this->offset. Consequently, you should just be able to mark it as "do not serialize":Lastly, this is somewhat orthogonal, but you can fold the
offsetand_offset_subattributes together by using the native attribute 'Code' trait: