X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema.pm;h=d704d824556b06c887ece64f4ea0bc2f2592ccd9;hb=fab31d8c753ec27ee5b5a16d1568cc337a245858;hp=bdd157b11a82e9cd93165acf6f91290339312be1;hpb=41a6f8c01f2bd184402b815db45ec5cc4ef18c25;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index bdd157b..d704d82 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -6,7 +6,7 @@ use warnings; use base qw/Class::Data::Inheritable/; use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/Exception/); +__PACKAGE__->load_components(qw/Exception Componentised/); __PACKAGE__->mk_classdata('class_registrations' => {}); =head1 NAME @@ -81,12 +81,26 @@ sub load_classes { sub compose_connection { my ($class, $target, @info) = @_; - $class->setup_connection_class($target, @info); + my $conn_class = "${target}::_db"; + $class->setup_connection_class($conn_class, @info); my %reg = %{ $class->class_registrations }; + my %target; + my %map; while (my ($comp, $comp_class) = each %reg) { my $target_class = "${target}::${comp}"; - $class->inject_base($target_class, $comp_class, $target); + $class->inject_base($target_class, $conn_class, $comp_class); + $target_class->table($comp_class->table); + @map{$comp, $comp_class} = ($target_class, $target_class); } + { + no strict 'refs'; + *{"${target}::class"} = + sub { + my ($class, $to_map) = @_; + return $map{$to_map}; + }; + } + $conn_class->class_resolver($target); } sub setup_connection_class { @@ -96,21 +110,13 @@ sub setup_connection_class { $target->connection(@info); } -sub inject_base { - my ($class, $target, @to_inject) = @_; - { - no strict 'refs'; - unshift(@{"${target}::ISA"}, @to_inject); - } -} - 1; =back =head1 AUTHORS -Matt S. Trout +Matt S. Trout =head1 LICENSE