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