From: David Kamholz Date: Thu, 16 Mar 2006 18:29:11 +0000 (+0000) Subject: hopefully fix atsushi kobayahi's ResultSetManager issue X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da95b45ff00d6d11f7b6191bafdeae7177650110;p=dbsrgits%2FDBIx-Class-Historic.git hopefully fix atsushi kobayahi's ResultSetManager issue --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 45ec142..444dc59 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -17,15 +17,21 @@ $VERSION = '0.05999_04'; sub MODIFY_CODE_ATTRIBUTES { my ($class,$code,@attrs) = @_; - unless ($class->can('_attr_cache')) { - $class->mk_classdata('_attr_cache'); - $class->_attr_cache({}); + unless ($class->can('__attr_cache')) { + $class->mk_classdata('__attr_cache'); + $class->__attr_cache({}); } - my $cache = $class->_attr_cache; - $class->_attr_cache->{$code} = [@attrs]; + $class->__attr_cache->{$code} = [@attrs]; return (); } +sub _attr_cache { + my $self = shift; + my $cache = $self->can('__attr_cache') ? $self->__attr_cache : {}; + my $rest = eval { $self->next::method }; + return $@ ? $cache : { %$cache, %$rest }; +} + 1; =head1 NAME diff --git a/lib/DBIx/Class/ResultSetManager.pm b/lib/DBIx/Class/ResultSetManager.pm index 360f070..476e8e1 100644 --- a/lib/DBIx/Class/ResultSetManager.pm +++ b/lib/DBIx/Class/ResultSetManager.pm @@ -25,9 +25,9 @@ sub load_resultset_components { sub _register_attributes { my $self = shift; - return unless $self->can('_attr_cache'); - my $cache = $self->_attr_cache; + return if keys %$cache == 0; + foreach my $meth (@{Class::Inspector->methods($self) || []}) { my $attrs = $cache->{$self->can($meth)}; next unless $attrs;