Provided by: libtangram-perl_2.10-1.1_all
Tangram::Type::Dump - Handy functions for Pixie-like dumping of data
use Tangram::Type::Dump qw(flatten unflatten UNflatten nuke); use YAML qw(freeze thaw); # for instance my $frozen = freeze flatten($storage, $structure); # optional - remove circular references from flattened # structure so that it is freed up properly. nuke $frozen; # save frozen somewhere... # restore, but don't load objects straight away my $reconstituted = unflatten($storage, thaw $frozen); # restore, loading objects immediately my $original = UNflatten($storage, $frozen); # Alternative, quickly marshall a structure for saving my $structure; flatten($storage, $structure); # ... do something with it ... # restore to former glory; note that Tangram's cache will # prevent unnecessary DB access. unflatten($storage, $structure);
This module contains functions for traversing data structures which are not Tangram- registered objects, and replacing all the Tangram objects found with `Mementos'. When a similar data structure is fed back into the reversal function, the mementos are filled with on-demand references to the real objects. All these functions operate in place for maximum efficiency.
flatten($storage, $structure) Traverses the structure $structure, and replaces all the known (ie, already inserted) Tangram objects with references to them unflatten($storage, $structure) Performs the logical opposite of flatten, but only insofar as a `normal' user is concerned. `Normal' users, of course, don't care that the data structure is being loaded from the database as they use it :).
Should this module just be an extension to Tangram::Storage ?
Sam Vilain, firstname.lastname@example.org. All rights reserved. This code is free software; you can use and/or modify it under the same terms as Perl itself.