line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin::Role::UserConfig; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
8491
|
use strict; # make critic happy |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
314
|
|
4
|
11
|
|
|
11
|
|
7753
|
use MooseX::Role::Parameterized; |
|
11
|
|
|
|
|
596588
|
|
|
11
|
|
|
|
|
64
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.23'; # VERSION |
7
|
|
|
|
|
|
|
# ABSTRACT: role for plugins using per user/request configuration |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
parameter uc_attributes => ( |
10
|
|
|
|
|
|
|
isa => 'ArrayRef', |
11
|
|
|
|
|
|
|
required => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
role { |
15
|
|
|
|
|
|
|
my $p = shift; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
foreach my $attribute ( @{$p->uc_attributes} ) { |
18
|
|
|
|
|
|
|
has 'uc_'.$attribute => ( |
19
|
|
|
|
|
|
|
is => 'rw', |
20
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub get_uc { |
26
|
89
|
|
|
89
|
0
|
224
|
my ($self, $session, $attr) = @_; |
27
|
89
|
|
|
|
|
201
|
my $uc_attr = 'uc_'.$attr; |
28
|
|
|
|
|
|
|
|
29
|
89
|
50
|
|
|
|
531
|
if( ! $self->can($uc_attr) ) { |
30
|
0
|
|
|
|
|
0
|
die('there is no user config attribute '.$uc_attr.'!'); |
31
|
|
|
|
|
|
|
} |
32
|
89
|
100
|
|
|
|
4146
|
if( ! defined $self->$uc_attr ) { |
33
|
77
|
|
|
|
|
3443
|
return $self->$attr; |
34
|
|
|
|
|
|
|
} |
35
|
12
|
|
|
|
|
547
|
my $session_value = $session->{$self->$uc_attr}; |
36
|
12
|
100
|
|
|
|
41
|
if( ! defined $session_value ) { |
37
|
6
|
|
|
|
|
289
|
return $self->$attr; |
38
|
|
|
|
|
|
|
} |
39
|
6
|
|
|
|
|
23
|
return $session_value; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=encoding UTF-8 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Mail::MtPolicyd::Plugin::Role::UserConfig - role for plugins using per user/request configuration |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 VERSION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
version 1.23 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 AUTHOR |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This is free software, licensed under: |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |