From: Luke Saunders Date: Thu, 7 Aug 2008 15:24:40 +0000 (+0000) Subject: reverted back to previous compose_namespace method with minor change X-Git-Tag: v0.08240~382 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=5b0b4df82267d761f34c606a1f97b6950a2eed4a reverted back to previous compose_namespace method with minor change --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index ea6f599..3e9d93e 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -616,20 +616,50 @@ will produce the output =cut # this might be oversimplified +# sub compose_namespace { +# my ($self, $target, $base) = @_; + +# my $schema = $self->clone; +# foreach my $moniker ($schema->sources) { +# my $source = $schema->source($moniker); +# my $target_class = "${target}::${moniker}"; +# $self->inject_base( +# $target_class => $source->result_class, ($base ? $base : ()) +# ); +# $source->result_class($target_class); +# $target_class->result_source_instance($source) +# if $target_class->can('result_source_instance'); +# $schema->register_source($moniker, $source); +# } +# return $schema; +# } + sub compose_namespace { my ($self, $target, $base) = @_; - my $schema = $self->clone; - foreach my $moniker ($schema->sources) { - my $source = $schema->source($moniker); - my $target_class = "${target}::${moniker}"; - $self->inject_base( - $target_class => $source->result_class, ($base ? $base : ()) - ); - $source->result_class($target_class); - $target_class->result_source_instance($source) - if $target_class->can('result_source_instance'); - $schema->register_source($moniker, $source); + { + no warnings qw/redefine/; +# local *Class::C3::reinitialize = sub { }; + foreach my $moniker ($schema->sources) { + my $source = $schema->source($moniker); + my $target_class = "${target}::${moniker}"; + $self->inject_base( + $target_class => $source->result_class, ($base ? $base : ()) + ); + $source->result_class($target_class); + $target_class->result_source_instance($source) + if $target_class->can('result_source_instance'); + $schema->register_source($moniker, $source); + } + } +# Class::C3->reinitialize(); + { + no strict 'refs'; + no warnings 'redefine'; + foreach my $meth (qw/class source resultset/) { + *{"${target}::${meth}"} = + sub { shift->schema->$meth(@_) }; + } } return $schema; }