744a82dc9d8333f3f2f84c93af5f7dbb3725a07d
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / Storable.pm
1 package SQL::Translator::Producer::Storable;
2
3 =head1 NAME
4
5 SQL::Translator::Producer::Storable - serializes the SQL::Translator::Schema 
6     object via the Storable module
7
8 =head1 SYNOPSIS
9
10   use SQL::Translator;
11
12   my $translator = SQL::Translator->new;
13   $translator->producer('Storable');
14
15 =head1 DESCRIPTION
16
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.
21
22 =cut
23
24 use strict;
25 use vars qw($DEBUG $VERSION @EXPORT_OK);
26 $DEBUG = 0 unless defined $DEBUG;
27 $VERSION = '1.59';
28
29 use Storable;
30 use Exporter;
31 use base qw(Exporter);
32
33 @EXPORT_OK = qw(produce);
34
35 sub produce {
36     my $t           = shift;
37     my $args        = $t->producer_args;
38     my $schema      = $t->schema;
39     my $serialized  = Storable::nfreeze($schema);
40
41     return $serialized;
42 }
43
44 1;
45
46 # -------------------------------------------------------------------
47
48 =pod
49
50 =head1 AUTHOR
51
52 Paul Harrington E<lt>harringp@deshaw.comE<gt>.
53
54 =head1 SEE ALSO
55
56 SQL::Translator, SQL::Translator::Schema, Storable.
57
58 =cut