Commit | Line | Data |
---|---|---|
f6595170 | 1 | package SQL::Translator::Producer::Storable; |
2 | ||
f6595170 | 3 | =head1 NAME |
4 | ||
df399712 | 5 | SQL::Translator::Producer::Storable - serializes the SQL::Translator::Schema |
4fc11ff6 | 6 | object via the Storable module |
f6595170 | 7 | |
8 | =head1 SYNOPSIS | |
9 | ||
10 | use SQL::Translator; | |
f6595170 | 11 | |
12 | my $translator = SQL::Translator->new; | |
4fc11ff6 | 13 | $translator->producer('Storable'); |
f6595170 | 14 | |
15 | =head1 DESCRIPTION | |
16 | ||
4fc11ff6 | 17 | This module uses Storable to serialize a schema to a string so that it |
18 | can be saved to disk. Serializing a schema and then calling producers | |
19 | on the stored can realize significant performance gains when parsing | |
20 | takes a long time. | |
f6595170 | 21 | |
22 | =cut | |
23 | ||
24 | use strict; | |
f27f9229 | 25 | use warnings; |
0c04c5a2 | 26 | our ( $DEBUG, @EXPORT_OK ); |
f6595170 | 27 | $DEBUG = 0 unless defined $DEBUG; |
0c04c5a2 | 28 | our $VERSION = '1.59'; |
f6595170 | 29 | |
30 | use Storable; | |
31 | use Exporter; | |
f6595170 | 32 | use base qw(Exporter); |
33 | ||
34 | @EXPORT_OK = qw(produce); | |
35 | ||
36 | sub produce { | |
37 | my $t = shift; | |
f6595170 | 38 | my $args = $t->producer_args; |
39 | my $schema = $t->schema; | |
349af114 | 40 | my $serialized = Storable::nfreeze($schema); |
f6595170 | 41 | |
42 | return $serialized; | |
43 | } | |
44 | ||
45 | 1; | |
46 | ||
47 | =pod | |
48 | ||
4fc11ff6 | 49 | =head1 AUTHOR |
f6595170 | 50 | |
4fc11ff6 | 51 | Paul Harrington E<lt>harringp@deshaw.comE<gt>. |
f6595170 | 52 | |
53 | =head1 SEE ALSO | |
54 | ||
4fc11ff6 | 55 | SQL::Translator, SQL::Translator::Schema, Storable. |
f6595170 | 56 | |
57 | =cut |