line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin::Role::UserConfig; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
5668
|
use strict; # make critic happy |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
295
|
|
4
|
11
|
|
|
11
|
|
4388
|
use MooseX::Role::Parameterized; |
|
11
|
|
|
|
|
398310
|
|
|
11
|
|
|
|
|
50
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.01'; # 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
|
202
|
my ($self, $session, $attr) = @_; |
27
|
95
|
|
|
|
|
168
|
my $uc_attr = 'uc_'.$attr; |
28
|
|
|
|
|
|
|
|
29
|
95
|
50
|
|
|
|
423
|
if( ! $self->can($uc_attr) ) { |
30
|
0
|
|
|
|
|
0
|
die('there is no user config attribute '.$uc_attr.'!'); |
31
|
|
|
|
|
|
|
} |
32
|
95
|
100
|
|
|
|
2916
|
if( ! defined $self->$uc_attr ) { |
33
|
83
|
|
|
|
|
2372
|
return $self->$attr; |
34
|
|
|
|
|
|
|
} |
35
|
12
|
|
|
|
|
458
|
my $session_value = $session->{$self->$uc_attr}; |
36
|
12
|
100
|
|
|
|
34
|
if( ! defined $session_value ) { |
37
|
6
|
|
|
|
|
217
|
return $self->$attr; |
38
|
|
|
|
|
|
|
} |
39
|
6
|
|
|
|
|
17
|
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.01 |
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 |