Class::Serializer - Serializes the in-memory state of a class into code
Version 0.04
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.
$target_class
require
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.
$file_name
$overwrite
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.
Class::Serializer
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.04. This feature wasn't tested extensively, though (it just relies on Data::Dump::Streamer for that).
Nilson Santos Figueiredo Junior, <nilsonsfj at cpan.org>
<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:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Class-Serializer
CPAN Ratings
http://cpanratings.perl.org/d/Class-Serializer
Search CPAN
http://search.cpan.org/dist/Class-Serializer
Data::Dump::Streamer, B::Deparse
Copyright 2008 Nilson Santos Figueiredo Junior, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Class::Serializer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Serializer
CPAN shell
perl -MCPAN -e shell install Class::Serializer
For more information on module installation, please visit the detailed CPAN module installation guide.