views:

80

answers:

1

I use MooseX::Storage for serialization of Moose objects. Can I use it for serialization of multiple Moose objects to the same file, or more specifically, an array or a hash of Moose objects?

I guess I can define another Moose objects ('array_of_myobj') but this isn't very elegant.

So, how would you recommend to serialize an array (or a hash) of Moose objects?

+4  A: 

You don't have to let MooseX::Storage manage your file IO just because it's available. You could use it to pack your objects into hashrefs and then dump them with YAML or Storable or whatever yourself. This is why MooseX::Storage distinguishes between three levels of serialization.

That said, I disagree that it is inelegant to make a single top-level object that contains all the other objects you want to serialize in a given context.

hdp
I think it's particularly elegant since what the poster wants to serialize is *specifically* the collection not the individual items.
perigrin