Tangram::Type::Dump3pm
Handy functions for pixie-like dumping of data
Usage
use Tangram::Type::Dump qw(flatten unflatten UNflatten nuke);use YAML qw(freeze thaw); # for instancemy $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 awaymy $reconstituted = unflatten($storage, thaw $frozen);# restore, loading objects immediatelymy $original = UNflatten($storage, $frozen);# Alternative, quickly marshall a structure for savingmy $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);
Overview
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.
Functions
- 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 :).
Releases
9 releases since Debian 5.0 (Lenny); the text changed 5 times.