Commit | Line | Data |
f6595170 |
1 | package SQL::Translator::Producer::Storable; |
2 | |
4fc11ff6 |
3 | # ------------------------------------------------------------------- |
478f608d |
4 | # Copyright (C) 2002-2009 SQLFairy Authors |
4fc11ff6 |
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 | # ------------------------------------------------------------------- |
f6595170 |
20 | =head1 NAME |
21 | |
4fc11ff6 |
22 | SQL::Translator::Producer::Storable - serializes the SQL::Translator::Schema |
23 | object via the Storable module |
f6595170 |
24 | |
25 | =head1 SYNOPSIS |
26 | |
27 | use SQL::Translator; |
f6595170 |
28 | |
29 | my $translator = SQL::Translator->new; |
4fc11ff6 |
30 | $translator->producer('Storable'); |
f6595170 |
31 | |
32 | =head1 DESCRIPTION |
33 | |
4fc11ff6 |
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. |
f6595170 |
38 | |
39 | =cut |
40 | |
41 | use strict; |
da06ac74 |
42 | use vars qw($DEBUG $VERSION @EXPORT_OK); |
f6595170 |
43 | $DEBUG = 0 unless defined $DEBUG; |
11ad2df9 |
44 | $VERSION = '1.59'; |
f6595170 |
45 | |
46 | use Storable; |
47 | use Exporter; |
f6595170 |
48 | use base qw(Exporter); |
49 | |
50 | @EXPORT_OK = qw(produce); |
51 | |
52 | sub produce { |
53 | my $t = shift; |
f6595170 |
54 | my $args = $t->producer_args; |
55 | my $schema = $t->schema; |
349af114 |
56 | my $serialized = Storable::nfreeze($schema); |
f6595170 |
57 | |
58 | return $serialized; |
59 | } |
60 | |
61 | 1; |
62 | |
4fc11ff6 |
63 | # ------------------------------------------------------------------- |
64 | |
f6595170 |
65 | =pod |
66 | |
4fc11ff6 |
67 | =head1 AUTHOR |
f6595170 |
68 | |
4fc11ff6 |
69 | Paul Harrington E<lt>harringp@deshaw.comE<gt>. |
f6595170 |
70 | |
71 | =head1 SEE ALSO |
72 | |
4fc11ff6 |
73 | SQL::Translator, SQL::Translator::Schema, Storable. |
f6595170 |
74 | |
75 | =cut |