line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::PerlWatcher::Memory; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$App::PerlWatcher::Memory::VERSION = '0.20'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Represents memory, which can be persisted (detached) for it's owner |
6
|
|
|
|
|
|
|
|
7
|
12
|
|
|
12
|
|
226
|
use 5.12.0; |
|
12
|
|
|
|
|
43
|
|
|
12
|
|
|
|
|
471
|
|
8
|
12
|
|
|
12
|
|
59
|
use strict; |
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
371
|
|
9
|
12
|
|
|
12
|
|
61
|
use warnings; |
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
305
|
|
10
|
|
|
|
|
|
|
|
11
|
12
|
|
|
12
|
|
56
|
use Carp; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
719
|
|
12
|
12
|
|
|
12
|
|
68
|
use Moo; |
|
12
|
|
|
|
|
30
|
|
|
12
|
|
|
|
|
93
|
|
13
|
|
|
|
|
|
|
|
14
|
12
|
|
|
12
|
|
3715
|
use parent qw/Exporter/; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
91
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw/memory_patch/; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'data' => (is => 'rw', default => sub { {}; }); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _monkey_patch { |
23
|
45
|
|
|
45
|
|
115
|
my ($class, %patch) = @_; |
24
|
12
|
|
|
12
|
|
1582
|
no strict 'refs'; |
|
12
|
|
|
|
|
44
|
|
|
12
|
|
|
|
|
358
|
|
25
|
12
|
|
|
12
|
|
58
|
no warnings 'redefine'; |
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
2741
|
|
26
|
45
|
|
|
|
|
234
|
*{"${class}::$_"} = $patch{$_} for keys %patch; |
|
45
|
|
|
|
|
415
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub memory_patch { |
31
|
45
|
|
|
45
|
1
|
107
|
my ($class, @attributes) = @_; |
32
|
45
|
|
|
|
|
65
|
my %patch; |
33
|
45
|
|
|
|
|
81
|
for my $a (@attributes) { |
34
|
|
|
|
|
|
|
$patch{$a} = sub { |
35
|
311
|
|
|
311
|
|
6771
|
my ($self, $value) = @_; |
36
|
311
|
|
|
|
|
636
|
my $memory = $self->memory; |
37
|
311
|
100
|
|
|
|
1017
|
$memory->data->{$a} = $value |
38
|
|
|
|
|
|
|
if(defined $value); |
39
|
311
|
|
|
|
|
3250
|
$memory->data->{$a}; |
40
|
|
|
|
|
|
|
} |
41
|
45
|
|
|
|
|
351
|
} |
42
|
45
|
|
|
|
|
163
|
_monkey_patch $class, %patch; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |