
Class::Serializer - Serializes the in-memory state of a class into code

Version 0.03

This module does its best efforts to serialize the in-memory state of a class into runable code. For this to actually happen successfully it relies heavily on Data::Dump::Streamer which, in turn, relies on B::Deparse for CODEREF deparsing and other similar tasks.
Please, keep in mind that this module is experimental. There are no guarantees whatsoever about the generated code.
With that said, it should work just fine.
Here's a little a code snippet:
use Class::Serializer;
# Class::Serializer is Class::Serializer safe
my $class_code = Class::Serializer->as_string('Class::Serializer');
# writes directly to ClassSerializer.pm
Class::Serializer->as_file(Class::Serializer => 'ClassSerializer.pm');

Serializes $target_class in-memory state (actually, symbol table entries) into perl code and returns it as a string. It will also try to detect possible dependencies and try to honor them through require statements in the generated code.
Serializes $target_class in-memory state into perl code and saves it into $file_name, overwriting the file if $overwrite is set to a true value.
If $file_name is not defined, it will be constructed based on the target class name, relative do the current path. So Class::Serializer would be saved in Class/Serializer.pm.
If $file_name exists and $overwrite is not set, an exception is thrown. An exception is also thrown if the file is not writable.

The dependency detecting code is pretty simple and may be not very reliable.
Closures should work just fine as of version 0.03. This feature wasn't tested extensively, though (it just relies on Data::Dump::Streamer for that).

Nilson Santos Figueiredo Júnior, <nilsonsfj at cpan.org>

Please report any bugs or feature requests directly to the author. If you ask nicely it will probably get fixed or implemented.

You can also look for information at:

Data::Dump::Streamer, B::Deparse

Copyright 2008 Nilson Santos Figueiredo Júnior, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.