X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSetManager.pm;h=2a77f2a0d3632014d57eda2a70255cf68ba5f6fa;hb=5ef3e508fa20d477b62406146cdca0ae658c10dd;hp=9989b2e64e57efc76abf37d8bea083ba787cdf04;hpb=1934596800201c16279d6d1b639507daec050447;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSetManager.pm b/lib/DBIx/Class/ResultSetManager.pm index 9989b2e..2a77f2a 100644 --- a/lib/DBIx/Class/ResultSetManager.pm +++ b/lib/DBIx/Class/ResultSetManager.pm @@ -9,9 +9,12 @@ __PACKAGE__->table_resultset_class_suffix('::_resultset'); sub table { my ($self,@rest) = @_; - $self->next::method(@rest); - $self->_register_attributes; - $self->_register_resultset_class; + my $ret = $self->next::method(@rest); + if (@rest) { + $self->_register_attributes; + $self->_register_resultset_class; + } + return $ret; } sub load_resultset_components { @@ -28,10 +31,10 @@ sub _register_attributes { foreach my $meth (@{Class::Inspector->methods($self) || []}) { my $attrs = $cache->{$self->can($meth)}; next unless $attrs; - if ($attrs->[0] eq 'resultset') { + if ($attrs->[0] eq 'ResultSet') { no strict 'refs'; my $resultset_class = $self->_setup_resultset_class; - *{"$resultset_class\::$meth"} = *{"$self\::$meth"}; + *{"$resultset_class\::$meth"} = $self->can($meth); undef *{"$self\::$meth"}; } } @@ -73,13 +76,13 @@ __END__ __PACKAGE__->load_resultset_components(qw/AlwaysRS/); # will be removed from the table class and inserted into a table-specific resultset class - sub foo : resultset { ... } + sub foo : ResultSet { ... } =head1 DESCRIPTION This package implements two useful features for customizing resultset classes. C loads components in addition to C -(or whatever you set as C). Any methods tagged with the C +(or whatever you set as C). Any methods tagged with the C attribute will be moved into a table-specific resultset class (by default called C).