From: Florian Ragwitz Date: Mon, 4 Oct 2010 23:00:20 +0000 (+0000) Subject: Implement can() for attribute delegation X-Git-Tag: v1.012~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Authentication-Store-LDAP.git;a=commitdiff_plain;h=ec21cfdc5435c6b8685734801275802bcfe4d3f1 Implement can() for attribute delegation --- diff --git a/lib/Catalyst/Authentication/Store/LDAP/User.pm b/lib/Catalyst/Authentication/Store/LDAP/User.pm index 42e4417..82a24da 100644 --- a/lib/Catalyst/Authentication/Store/LDAP/User.pm +++ b/lib/Catalyst/Authentication/Store/LDAP/User.pm @@ -314,6 +314,15 @@ sub DESTROY { delete $_ldap_connection_passwords{refaddr($self)}; } +sub can { + my ($self, $method) = @_; + + return $self->SUPER::can($method) || do { + return unless $self->has_attribute($method); + return sub { $_[0]->has_attribute($method) }; + }; +} + sub AUTOLOAD { my $self = shift; diff --git a/t/pod-coverage.t b/t/pod-coverage.t index 703f91d..44f5d76 100644 --- a/t/pod-coverage.t +++ b/t/pod-coverage.t @@ -3,4 +3,4 @@ use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; -all_pod_coverage_ok(); +all_pod_coverage_ok({ also_private => ['can'] });