3c918c0074196d1880337d7082a1f7a4293d298d
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / Storable.pm
1 package SQL::Translator::Producer::Storable;
2
3 # -------------------------------------------------------------------
4 # Copyright (C) 2002-2009 SQLFairy Authors
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; version 2.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307  USA
19 # -------------------------------------------------------------------
20 =head1 NAME
21
22 SQL::Translator::Producer::Storable - serializes the SQL::Translator::Schema 
23     object via the Storable module
24
25 =head1 SYNOPSIS
26
27   use SQL::Translator;
28
29   my $translator = SQL::Translator->new;
30   $translator->producer('Storable');
31
32 =head1 DESCRIPTION
33
34 This module uses Storable to serialize a schema to a string so that it
35 can be saved to disk.  Serializing a schema and then calling producers
36 on the stored can realize significant performance gains when parsing
37 takes a long time.
38
39 =cut
40
41 use strict;
42 use vars qw($DEBUG $VERSION @EXPORT_OK);
43 $DEBUG = 0 unless defined $DEBUG;
44 $VERSION = '1.59';
45
46 use Storable;
47 use Exporter;
48 use base qw(Exporter);
49
50 @EXPORT_OK = qw(produce);
51
52 sub produce {
53     my $t           = shift;
54     my $args        = $t->producer_args;
55     my $schema      = $t->schema;
56     my $serialized  = Storable::nfreeze($schema);
57
58     return $serialized;
59 }
60
61 1;
62
63 # -------------------------------------------------------------------
64
65 =pod
66
67 =head1 AUTHOR
68
69 Paul Harrington E<lt>harringp@deshaw.comE<gt>.
70
71 =head1 SEE ALSO
72
73 SQL::Translator, SQL::Translator::Schema, Storable.
74
75 =cut