From: Matt S Trout Date: Wed, 1 Sep 2010 19:17:04 +0000 (+0000) Subject: fix the delegation code in User.pm X-Git-Tag: v0.1400~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Authentication-Store-DBIx-Class.git;a=commitdiff_plain;h=28db23cf5c198d4b5c1db40acc54bc50e5102d8b fix the delegation code in User.pm --- diff --git a/Changes b/Changes index 990eef8..2cdbbb2 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Catalyst-Plugin-Authentication-Store-DBIx-Class + * Make can() work as well as AUTOLOADing. + 0.1300 2010-06-16 * Support columns with accessors that aren't the column name. * Fix some documentation typos. diff --git a/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm b/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm index 3b05c19..231d1cd 100644 --- a/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm +++ b/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm @@ -238,6 +238,21 @@ sub auto_update { $self->_user->auto_update( @_ ); } +sub can { + my $self = shift; + return $self->SUPER::can(@_) || do { + my ($method) = @_; warn $method; + if (my $code = $self->_user->can($method)) { + sub { shift->_user->$code(@_) } + } elsif (my $accessor = + try { $self->_user->result_source->column_info($method)->{accessor} }) { + sub { shift->_user->$accessor } + } else { + undef; + } + }; +} + sub AUTOLOAD { my $self = shift; (my $method) = (our $AUTOLOAD =~ /([^:]+)$/); @@ -354,9 +369,13 @@ None known currently, please email the author if you find any. Jason Kuri (jayk@cpan.org) +=head1 CONTRIBUTORS + +Matt S Trout (mst) + =head1 LICENSE -Copyright (c) 2007 the aforementioned authors. All rights +Copyright (c) 2007-2010 the aforementioned authors. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.