#use Exporter;
use Carp qw(confess);
use DBI;
-use FreezeThaw qw(freeze thaw cmpStr);
+use Storable;
use DBIx::DBSchema::Table;
use DBIx::DBSchema::Column;
use DBIx::DBSchema::ColGroup::Unique;
#@ISA = qw(Exporter);
@ISA = ();
-$VERSION = "0.23";
+$VERSION = "0.24";
=head1 NAME
sub load {
my($proto,$file)=@_; #use $proto ?
- open(FILE,"<$file") or die "Can't open $file: $!";
- my($string)=join('',<FILE>); #can $string have newlines? pry not?
- close FILE or die "Can't close $file: $!";
- my($self)=thaw $string;
- #no bless needed?
+
+ my $self;
+
+ #first try Storable
+ eval { $self = Storable::retrieve($file); };
+
+ if ( $@ && $@ =~ /not.*storable/i ) { #then try FreezeThaw
+ eval "use FreezeThaw;";
+ die $@ if $@;
+ open(FILE,"<$file") or die "Can't open $file: $!";
+ my $string = join('',<FILE>);
+ close FILE or die "Can't close $file: $!";
+ ($self) = FreezeThaw::thaw($string);
+ }
+
$self;
+
}
=item save FILENAME
=cut
sub save {
- my($self,$file)=@_;
- my($string)=freeze $self;
- open(FILE,">$file") or die "Can't open $file: $!";
- print FILE $string;
- close FILE or die "Can't close file: $!";
- my($check_self)=thaw $string;
- die "Verify error: Can't freeze and thaw dbdef $self"
- if (cmpStr($self,$check_self));
+ #my($self, $file) = @_;
+ Storable::nstore(@_);
}
=item addtable TABLE_OBJECT
). " ],\n"
#" 'index' => [ ". " ],\n"
} $self->tables
- ), "}\n";
+ ). "}\n";
}
=cut
=head1 COPYRIGHT
-Copyright (c) 2000 Ivan Kohler
+Copyright (c) 2000-2005 Ivan Kohler
Copyright (c) 2000 Mail Abuse Prevention System LLC
All rights reserved.
This program is free software; you can redistribute it and/or modify it under