Re: MooseX::Storage -- what should pack() look like for Class::DBI?
[email protected] (Bill Moseley)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <CAKhN_m5MezKepw6n91gXsqd37PFw8DA2yaR=YOouVQoCLx1SAA@mail.gmail.com> |
On Mon, Feb 13, 2012 at 5:48 AM, Chris Prather <[email protected]> wrote: > > What should that pack method look like? > > With the provision that I don't use Class::DBI ... and haven't in > anger in some time ... > Yes, it's all coming back to me now. :) > > It would I think look an awful lot like: sub pack { shift->_data_hash() } > That works if the CDBI object doesn't have any relationships. But, I don't think it works recursively. So, putting that in the CDBI base class results in JSON complaining: "...neither allow_blessed nor convert_blessed settings are enabled" because the "sub-objects" are not also converted to a hash. I guess another option is to use sub pack { shift->id } and then use coercion to re-inflate later by refetching from the database. Thanks, -- Bill Moseley [email protected]