line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mixin::Historian::Driver::Array 0.102001; |
2
|
1
|
|
|
1
|
|
685
|
use base 'Mixin::Historian::Driver'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
475
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: a driver that stores history in an in-memory array (for testing) |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
181
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod This driver, meant primarily for testing, logs history events as hashrefs in an |
11
|
|
|
|
|
|
|
#pod in-memory arrayref stored in the driver. |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod The events may accessed by the driver's C method, and are returned as |
14
|
|
|
|
|
|
|
#pod a list of hashrefs in the form: |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod { |
17
|
|
|
|
|
|
|
#pod time => $epoch_seconds, |
18
|
|
|
|
|
|
|
#pod record => $hashref_passed_to_add_history, |
19
|
|
|
|
|
|
|
#pod } |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod =cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
1
|
|
|
1
|
0
|
47
|
my ($class, $arg) = @_; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
52
|
return bless { |
27
|
|
|
|
|
|
|
array => [], |
28
|
|
|
|
|
|
|
} => $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _array { |
32
|
3
|
|
|
3
|
|
37
|
$_[0]{array}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub entries { |
36
|
1
|
|
|
1
|
0
|
7
|
my ($self) = @_; |
37
|
1
|
|
|
|
|
1
|
return @{ $self->_array }; |
|
1
|
|
|
|
|
3
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub add_history { |
41
|
2
|
|
|
2
|
0
|
6
|
my ($self, $arg) = @_; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
4
|
my $record = $arg->{args}[0]; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
4
|
push @{ $self->_array }, { |
|
2
|
|
|
|
|
5
|
|
46
|
|
|
|
|
|
|
time => time, |
47
|
|
|
|
|
|
|
record => $record, |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |