reverting r1413 and r1414 in favor of passing a scalar ref to parser which the produc...
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / Storable.pm
CommitLineData
f6595170 1package SQL::Translator::Producer::Storable;
2
4fc11ff6 3# -------------------------------------------------------------------
977651a5 4# $Id: Storable.pm,v 1.5 2004-02-09 23:02:17 kycl4rk Exp $
4fc11ff6 5# -------------------------------------------------------------------
977651a5 6# Copyright (C) 2002-4 SQLFairy Authors
4fc11ff6 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# -------------------------------------------------------------------
f6595170 22=head1 NAME
23
4fc11ff6 24SQL::Translator::Producer::Storable - serializes the SQL::Translator::Schema
25 object via the Storable module
f6595170 26
27=head1 SYNOPSIS
28
29 use SQL::Translator;
f6595170 30
31 my $translator = SQL::Translator->new;
4fc11ff6 32 $translator->producer('Storable');
f6595170 33
34=head1 DESCRIPTION
35
4fc11ff6 36This module uses Storable to serialize a schema to a string so that it
37can be saved to disk. Serializing a schema and then calling producers
38on the stored can realize significant performance gains when parsing
39takes a long time.
f6595170 40
41=cut
42
43use strict;
44use vars qw($DEBUG $VERSION @EXPORT_OK);
45$DEBUG = 0 unless defined $DEBUG;
977651a5 46$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/;
f6595170 47
48use Storable;
49use Exporter;
f6595170 50use base qw(Exporter);
51
52@EXPORT_OK = qw(produce);
53
54sub produce {
55 my $t = shift;
f6595170 56 my $args = $t->producer_args;
57 my $schema = $t->schema;
349af114 58 my $serialized = Storable::nfreeze($schema);
f6595170 59
60 return $serialized;
61}
62
631;
64
4fc11ff6 65# -------------------------------------------------------------------
66
f6595170 67=pod
68
4fc11ff6 69=head1 AUTHOR
f6595170 70
4fc11ff6 71Paul Harrington E<lt>harringp@deshaw.comE<gt>.
f6595170 72
73=head1 SEE ALSO
74
4fc11ff6 75SQL::Translator, SQL::Translator::Schema, Storable.
f6595170 76
77=cut