| 1 | # $Id$ | ||||||||||
| 2 | |||||||||||
| 3 | package Mvalve::State::Memory; | ||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Digest::SHA1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Data::Dumper(); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | with 'Mvalve::State'; | |||||||||
| 9 | |||||||||||
| 10 | has 'data' => ( | ||||||||||
| 11 | is => 'rw', | ||||||||||
| 12 | isa => 'HashRef', | ||||||||||
| 13 | 0 | ▶ | default => sub { +{} } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 14 | 1 | ); | |||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | around qw(get set remove incr decr) => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 17 | 0 | my ($next, $self, $key, @args) = @_; | |||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | if (ref $key) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | local $Data::Dumper::Indent = 1; | |||||||||
| 21 | 0 | local $Data::Dumper::Terse = 1; | |||||||||
| 22 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||
| 23 | 0 | $key = Digest::SHA1::sha1_hex(Data::Dumper::Dumper($key)); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | $next->($self, $key, @args); | |||||||||
| 27 | 1 | }; | |||||||||
| 28 | |||||||||||
| 29 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | sub get { | ||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
| |||||||||||
| 32 | 0 | my $self = shift; | |||||||||
| 33 | 0 | $self->data->{$_[0]} | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub set { | ||||||||
|
Subroutine
set: not called CC=1 SCAR=6.9
| |||||||||||
| 37 | 0 | my $self = shift; | |||||||||
| 38 | 0 | $self->data->{$_[0]} = $_[1]; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub remove { | ||||||||
|
Subroutine
remove: not called CC=1 SCAR=6.9
| |||||||||||
| 42 | 0 | my $self = shift; | |||||||||
| 43 | 0 | delete $self->data->{$_[0]} | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub incr { | ||||||||
|
Subroutine
incr: not called CC=1 SCAR=6.9
| |||||||||||
| 47 | 0 | my $self = shift; | |||||||||
| 48 | 0 | $self->data->{$_[0]}++ | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | sub decr { | ||||||||
|
Subroutine
decr: not called CC=1 SCAR=6.9
| |||||||||||
| 52 | 0 | my $self = shift; | |||||||||
| 53 | 0 | $self->data->{$_[0]}-- | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 1 | 1; | |||||||||
| 57 | |||||||||||
| 58 | __END__ | ||||||||||