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 {
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