From: David Kamholz Date: Fri, 3 Feb 2006 15:28:53 +0000 (+0000) Subject: changes to ResultSetManager X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=570783b1e6693bd3b93f5b57bd5d4cc118f406c9;p=dbsrgits%2FDBIx-Class-Historic.git changes to ResultSetManager --- diff --git a/lib/DBIx/Class/ResultSetManager.pm b/lib/DBIx/Class/ResultSetManager.pm index 754bce2..89076a1 100644 --- a/lib/DBIx/Class/ResultSetManager.pm +++ b/lib/DBIx/Class/ResultSetManager.pm @@ -3,19 +3,16 @@ use strict; use base 'DBIx::Class'; use Class::Inspector; -__PACKAGE__->mk_classdata($_) for qw/ _attr_cache custom_resultset_class_suffix /; +__PACKAGE__->mk_classdata($_) for qw/ _attr_cache base_resultset_class custom_resultset_class_suffix /; __PACKAGE__->_attr_cache({}); -__PACKAGE__->custom_resultset_class_suffix('::_rs'); - -sub base_resultset_class { - my ($self,$class) = @_; - $self->result_source_instance->resultset_class($class); -} +__PACKAGE__->base_resultset_class('DBIx::Class::ResultSet'); +__PACKAGE__->custom_resultset_class_suffix('::_resultset'); sub table { my ($self,@rest) = @_; $self->next::method(@rest); $self->_register_attributes; + $self->_register_resultset_class; } sub load_resultset_components { @@ -51,10 +48,20 @@ sub _setup_resultset_class { my $resultset_class = $self . $self->custom_resultset_class_suffix; no strict 'refs'; unless (@{"$resultset_class\::ISA"}) { - @{"$resultset_class\::ISA"} = ($self->result_source_instance->resultset_class); - $self->result_source_instance->resultset_class($resultset_class); + @{"$resultset_class\::ISA"} = ($self->base_resultset_class); } return $resultset_class; } +sub _register_resultset_class { + my $self = shift; + my $resultset_class = $self . $self->custom_resultset_class_suffix; + no strict 'refs'; + if (@{"$resultset_class\::ISA"}) { + $self->result_source_instance->resultset_class($resultset_class); + } else { + $self->result_source_instance->resultset_class($self->base_resultset_class); + } +} + 1; \ No newline at end of file