line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin::Role::UserConfig; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
5643
|
use strict; # make critic happy |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
284
|
|
4
|
11
|
|
|
11
|
|
4177
|
use MooseX::Role::Parameterized; |
|
11
|
|
|
|
|
389210
|
|
|
11
|
|
|
|
|
52
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.02'; # 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
|
95
|
|
|
95
|
0
|
155
|
my ($self, $session, $attr) = @_; |
27
|
95
|
|
|
|
|
169
|
my $uc_attr = 'uc_'.$attr; |
28
|
|
|
|
|
|
|
|
29
|
95
|
50
|
|
|
|
494
|
if( ! $self->can($uc_attr) ) { |
30
|
0
|
|
|
|
|
0
|
die('there is no user config attribute '.$uc_attr.'!'); |
31
|
|
|
|
|
|
|
} |
32
|
95
|
100
|
|
|
|
3086
|
if( ! defined $self->$uc_attr ) { |
33
|
83
|
|
|
|
|
2641
|
return $self->$attr; |
34
|
|
|
|
|
|
|
} |
35
|
12
|
|
|
|
|
339
|
my $session_value = $session->{$self->$uc_attr}; |
36
|
12
|
100
|
|
|
|
47
|
if( ! defined $session_value ) { |
37
|
6
|
|
|
|
|
181
|
return $self->$attr; |
38
|
|
|
|
|
|
|
} |
39
|
6
|
|
|
|
|
16
|
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 2.02 |
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 |