line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Role::Alt; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
267060
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
7511
|
|
4
|
2
|
|
|
2
|
|
44
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
154
|
|
5
|
2
|
|
|
2
|
|
65
|
use 5.008001; |
|
2
|
|
|
|
|
12
|
|
6
|
2
|
|
|
2
|
|
1120
|
use Role::Tiny; |
|
2
|
|
|
|
|
8526
|
|
|
2
|
|
|
|
|
16
|
|
7
|
2
|
|
|
2
|
|
1664
|
use Storable (); |
|
2
|
|
|
|
|
5755
|
|
|
2
|
|
|
|
|
64
|
|
8
|
2
|
|
|
2
|
|
18
|
use Carp (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
638
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Alien::Base role that supports alternates |
11
|
|
|
|
|
|
|
our $VERSION = '0.03'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub alt |
15
|
|
|
|
|
|
|
{ |
16
|
6
|
|
|
6
|
1
|
6436
|
my($old, $name) = @_; |
17
|
6
|
100
|
|
|
|
35
|
my $new = ref $old ? (ref $old)->new : $old->new; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
32
|
my $orig; |
20
|
|
|
|
|
|
|
|
21
|
6
|
100
|
66
|
|
|
41
|
if(ref($old) && defined $old->{_alt}) |
22
|
1
|
|
|
|
|
4
|
{ $orig = $old->{_alt}->{orig} } |
23
|
|
|
|
|
|
|
else |
24
|
5
|
|
|
|
|
187
|
{ $orig = $old->runtime_prop } |
25
|
|
|
|
|
|
|
|
26
|
6
|
|
|
|
|
510
|
my $runtime_prop = Storable::dclone($orig); |
27
|
|
|
|
|
|
|
|
28
|
6
|
100
|
|
|
|
61
|
if($runtime_prop->{alt}->{$name}) |
29
|
|
|
|
|
|
|
{ |
30
|
5
|
|
|
|
|
12
|
foreach my $key (keys %{ $runtime_prop->{alt}->{$name} }) |
|
5
|
|
|
|
|
30
|
|
31
|
|
|
|
|
|
|
{ |
32
|
23
|
|
|
|
|
56
|
$runtime_prop->{$key} = $runtime_prop->{alt}->{$name}->{$key}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else |
36
|
|
|
|
|
|
|
{ |
37
|
1
|
|
|
|
|
237
|
Carp::croak("no such alt: $name"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$new->{_alt} = { |
41
|
5
|
|
|
|
|
31
|
runtime_prop => $runtime_prop, |
42
|
|
|
|
|
|
|
orig => $orig, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
18
|
$new; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
around runtime_prop => sub { |
49
|
|
|
|
|
|
|
my $orig = shift; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my($self) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
if(ref($self) && defined $self->{_alt}) |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
return $self->{_alt}->{runtime_prop}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
return $orig->($self); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |