From: Matt S Trout Date: Thu, 4 Aug 2005 17:43:52 +0000 (+0000) Subject: Refactored Schema.pm X-Git-Tag: v0.03001~70 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b795144302db2834acbac9551f787af38cd2ec49;p=dbsrgits%2FDBIx-Class.git Refactored Schema.pm --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index c402eff..3154555 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -69,19 +69,26 @@ sub load_classes { sub compose_connection { my ($class, $target, @info) = @_; - { - no strict 'refs'; - unshift(@{"${target}::ISA"}, 'DBIx::Class'); - } - $target->load_components('DB'); - $target->connection(@info); + $class->setup_connection_class($target, @info); my %reg = %{ $class->_class_registrations }; while (my ($comp, $comp_class) = each %reg) { my $target_class = "${target}::${comp}"; - { - no strict 'refs'; - unshift(@{"${target_class}::ISA"}, $comp_class, $target); - } + $class->inject_base($target_class, $comp_class, $target); + } +} + +sub setup_connection_class { + my ($class, $target, @info) = @_; + $class->inject_base($target => 'DBIx::Class'); + $target->load_components('DB'); + $target->connection(@info); +} + +sub inject_base { + my ($class, $target, @to_inject) = @_; + { + no strict 'refs'; + unshift(@{"${target}::ISA"}, @to_inject); } }