From: David Kamholz Date: Fri, 3 Feb 2006 18:30:10 +0000 (+0000) Subject: - move attribute recording to DBIx::Class X-Git-Tag: v0.05005~54 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f0750722cda0ea1e7a6588075c6518642d1e48fc;p=dbsrgits%2FDBIx-Class.git - move attribute recording to DBIx::Class - clean up ResultSetManager and tests --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 7765f9a..12fe447 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -15,6 +15,17 @@ sub component_base_class { 'DBIx::Class' } $VERSION = '0.05000'; +sub MODIFY_CODE_ATTRIBUTES { + my ($class,$code,@attrs) = @_; + unless ($class->can('_attr_cache')) { + $class->mk_classdata('_attr_cache'); + $class->_attr_cache({}); + } + my $cache = $class->_attr_cache; + $class->_attr_cache->{$code} = [@attrs]; + return (); +} + 1; =head1 NAME diff --git a/lib/DBIx/Class/ResultSetManager.pm b/lib/DBIx/Class/ResultSetManager.pm index 89076a1..8bfe4ed 100644 --- a/lib/DBIx/Class/ResultSetManager.pm +++ b/lib/DBIx/Class/ResultSetManager.pm @@ -3,10 +3,9 @@ use strict; use base 'DBIx::Class'; use Class::Inspector; -__PACKAGE__->mk_classdata($_) for qw/ _attr_cache base_resultset_class custom_resultset_class_suffix /; -__PACKAGE__->_attr_cache({}); +__PACKAGE__->mk_classdata($_) for qw/ base_resultset_class table_resultset_class_suffix /; __PACKAGE__->base_resultset_class('DBIx::Class::ResultSet'); -__PACKAGE__->custom_resultset_class_suffix('::_resultset'); +__PACKAGE__->table_resultset_class_suffix('::_resultset'); sub table { my ($self,@rest) = @_; @@ -21,12 +20,6 @@ sub load_resultset_components { $resultset_class->load_components(@comp); } -sub MODIFY_CODE_ATTRIBUTES { - my ($class,$code,@attrs) = @_; - $class->_attr_cache({ %{$class->_attr_cache}, $code => [@attrs] }); - return (); -} - sub _register_attributes { my $self = shift; my $cache = $self->_attr_cache; @@ -40,12 +33,11 @@ sub _register_attributes { undef *{"$self\::$meth"}; } } - $self->_attr_cache(undef); } sub _setup_resultset_class { my $self = shift; - my $resultset_class = $self . $self->custom_resultset_class_suffix; + my $resultset_class = $self . $self->table_resultset_class_suffix; no strict 'refs'; unless (@{"$resultset_class\::ISA"}) { @{"$resultset_class\::ISA"} = ($self->base_resultset_class); @@ -55,7 +47,7 @@ sub _setup_resultset_class { sub _register_resultset_class { my $self = shift; - my $resultset_class = $self . $self->custom_resultset_class_suffix; + my $resultset_class = $self . $self->table_resultset_class_suffix; no strict 'refs'; if (@{"$resultset_class\::ISA"}) { $self->result_source_instance->resultset_class($resultset_class); diff --git a/t/lib/DBICTest/Extra.pm b/t/lib/DBICTest/Extra.pm index 7e07bc0..3046752 100644 --- a/t/lib/DBICTest/Extra.pm +++ b/t/lib/DBICTest/Extra.pm @@ -1,8 +1,3 @@ -package DBICTest::Extra::Base; -use base 'DBIx::Class'; - -__PACKAGE__->load_components(qw/ ResultSetManager Core /); - package DBICTest::Extra; use base 'DBIx::Class::Schema'; diff --git a/t/lib/DBICTest/Extra/Foo.pm b/t/lib/DBICTest/Extra/Foo.pm index c43739f..cee710e 100644 --- a/t/lib/DBICTest/Extra/Foo.pm +++ b/t/lib/DBICTest/Extra/Foo.pm @@ -1,6 +1,7 @@ package DBICTest::Extra::Foo; -use base 'DBICTest::Extra::Base'; +use base 'DBIx::Class'; +__PACKAGE__->load_components(qw/ ResultSetManager Core /); __PACKAGE__->table('foo'); sub bar : resultset { 'good' }