aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Catalyst/Authentication/Store/FixMyStreetUser.pm
blob: 240f4b1de49a2616e0baad996cc7aa16051dc5af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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