From: Brandon Black Date: Wed, 28 Jun 2006 04:55:17 +0000 (+0000) Subject: make_schema_at made more efficient (email thread w/ Matt Lawrence) X-Git-Tag: 0.03004~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=483987b9e98a876bf0348c32e13aecbb58521afc;p=dbsrgits%2FDBIx-Class-Schema-Loader.git make_schema_at made more efficient (email thread w/ Matt Lawrence) small fix to debugging output --- diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index cb4c8bf..abbbf48 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -7,7 +7,6 @@ use base qw/Class::Data::Accessor/; use Carp; use UNIVERSAL::require; use Class::C3; -use Data::Dump qw/ dump /; use Scalar::Util qw/ weaken /; # Always remember to do all digits for the version even if they're 0 @@ -232,6 +231,8 @@ use this to generate a rough draft manual schema from a dsn without the intermediate step of creating a physical Loader-based schema class. +The return value is the input class name. + This function can be exported/imported by the normal means, as illustrated in these Examples: @@ -261,15 +262,13 @@ illustrated in these Examples: sub make_schema_at { my ($target, $opts, $connect_info) = @_; - my $opts_dumped = dump($opts); - my $cinfo_dumped = dump(@$connect_info); - eval qq| - package $target; - use base qw/DBIx::Class::Schema::Loader/; - __PACKAGE__->loader_options($opts_dumped); - __PACKAGE__->connection($cinfo_dumped); - |; - croak "make_schema_at failed: $@" if $@; + { + no strict 'refs'; + @{$target . '::ISA'} = qw/DBIx::Class::Schema::Loader/; + } + + $target->loader_options($opts); + $target->connection(@$connect_info); } =head1 EXAMPLE diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 16ce373..3e3ccec 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -391,7 +391,7 @@ sub _inject { my $blist = join(q{ }, @_); $self->_raw_stmt($target, "use base qw/ $blist /;") if @_; - warn "$target: use base qw/ $blist /" if $self->debug; + warn "$target: use base qw/ $blist /" if $self->debug && @_; foreach (@_) { $_->require or croak ($_ . "->require: $@"); $schema_class->inject_base($target, $_);