aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Catalyst/Authentication/Store/FixMyStreetUser.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-05-09 09:44:08 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-05-09 09:44:08 +0100
commitc25332f3c0a6201726882c9d5b69bf314b5d061d (patch)
tree71a047bf42a22fab0ea3dd076490ef45510605c3 /perllib/Catalyst/Authentication/Store/FixMyStreetUser.pm
parent47b754d7a8dd1114eb745efcaf1495fb27f0c1d8 (diff)
parent332c92ead825503c0540f805a0fdb39c64212c15 (diff)
Merge branch 'photo-caching'
Diffstat (limited to 'perllib/Catalyst/Authentication/Store/FixMyStreetUser.pm')
-rw-r--r--perllib/Catalyst/Authentication/Store/FixMyStreetUser.pm54
1 files changed, 54 insertions, 0 deletions
diff --git a/perllib/Catalyst/Authentication/Store/FixMyStreetUser.pm b/perllib/Catalyst/Authentication/Store/FixMyStreetUser.pm
new file mode 100644
index 000000000..240f4b1de
--- /dev/null
+++ b/perllib/Catalyst/Authentication/Store/FixMyStreetUser.pm
@@ -0,0 +1,54 @@
+package Catalyst::Authentication::Store::FixMyStreetUser;
+
+use Moose;
+use namespace::autoclean;
+extends 'Catalyst::Authentication::Store::DBIx::Class::User';
+
+use Carp;
+use Try::Tiny;
+
+sub AUTOLOAD {
+ my $self = shift;
+ (my $method) = (our $AUTOLOAD =~ /([^:]+)$/);
+ return if $method eq "DESTROY";
+
+ if (my $code = $self->_user->can($method)) {
+ return $self->_user->$code(@_);
+ }
+ elsif (my $accessor =
+ try { $self->_user->result_source->column_info($method)->{accessor} }) {
+ return $self->_user->$accessor(@_);
+ } else {
+ croak sprintf("Can't locate object method '%s'", $method);
+ }
+}
+
+__PACKAGE__->meta->make_immutable(inline_constructor => 0);
+
+1;
+__END__
+
+=head1 NAME
+
+Catalyst::Authentication::Store::FixMyStreetUser - The backing user
+class for the Catalyst::Authentication::Store::DBIx::Class storage
+module, adjusted to die on unknown lookups.
+
+=head1 DESCRIPTION
+
+The Catalyst::Authentication::Store::FixMyStreetUser class implements user
+storage connected to an underlying DBIx::Class schema object.
+
+=head1 SUBROUTINES / METHODS
+
+=head2 AUTOLOAD
+
+Delegates method calls to the underlying user row.
+Unlike the default, dies if an unknown method is called.
+
+=head1 LICENSE
+
+Copyright (c) 2007-2019. All rights reserved. This program is free software;
+you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut