| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Data::Keys::E::Store::Mem; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | =head1 NAME | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | Data::Keys::E::Store::Mem - in memory storage | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | my $dk = Data::Keys->new( | 
| 10 |  |  |  |  |  |  | 'extend_with' => 'Store::Mem', | 
| 11 |  |  |  |  |  |  | ); | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | Stores key/values in memory. | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | =cut | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 1 |  |  | 1 |  | 1126 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 33 |  | 
| 20 | 1 |  |  | 1 |  | 4 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 29 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | our $VERSION = '0.03'; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 1 |  |  | 1 |  | 445 | use Moose::Role; | 
|  | 1 |  |  |  |  | 3112 |  | 
|  | 1 |  |  |  |  | 3 |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | =head1 PROPERTIES | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =head2 mem_store | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | Hashref holding the key/values. | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | =cut | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | has 'mem_store' => ( isa => 'HashRef', is => 'ro', lazy => 1, default => sub {{}}); | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =head1 METHODS | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | =head2 get($key) | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | Return value of the C<$key> from the L</mem_store> hash. | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =cut | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | sub get { | 
| 45 | 3 |  |  | 3 | 1 | 3 | my $self  = shift; | 
| 46 | 3 |  |  |  |  | 3 | my $key   = shift; | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 3 |  |  |  |  | 91 | return $self->mem_store->{$key}; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =head2 set($key, $value) | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | Sets C<$value> to C<$key> of the L</mem_store> hash. | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | =cut | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub set { | 
| 58 | 3 |  |  | 3 | 1 | 6 | my $self  = shift; | 
| 59 | 3 |  |  |  |  | 3 | my $key   = shift; | 
| 60 | 3 |  |  |  |  | 2 | my $value = shift; | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 3 | 100 |  |  |  | 8 | if (not defined $value) { | 
| 63 | 1 |  |  |  |  | 31 | delete $self->mem_store->{$key}; | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  | else { | 
| 66 | 2 |  |  |  |  | 55 | $self->mem_store->{$key} = $value; | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 | 3 |  |  |  |  | 11 | return $key; | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | 1; | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | __END__ | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =head1 AUTHOR | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | Jozef Kutej | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | =cut |