File Coverage

blib/lib/Form/Factory/Stasher/Memory.pm
Criterion Covered Total %
statement 3 7 42.8
branch n/a
condition n/a
subroutine 1 3 33.3
pod 2 2 100.0
total 6 12 50.0


line stmt bran cond sub pod time code
1             package Form::Factory::Stasher::Memory;
2             $Form::Factory::Stasher::Memory::VERSION = '0.022';
3 1     1   4 use Moose;
  1         1  
  1         13  
4              
5             with qw( Form::Factory::Stasher );
6              
7             # ABSTRACT: Remember things in a Perl hash
8              
9              
10             has stash_hash => (
11             is => 'rw',
12             isa => 'HashRef',
13             required => 1,
14             default => sub { {} },
15             );
16              
17              
18             sub stash {
19 0     0 1   my ($self, $moniker, $stash) = @_;
20 0           $self->stash_hash->{ $moniker } = $stash;
21             }
22              
23              
24             sub unstash {
25 0     0 1   my ($self, $moniker) = @_;
26 0           delete $self->stash_hash->{ $moniker };
27             }
28              
29             __PACKAGE__->meta->make_immutable;
30              
31             __END__
32              
33             =pod
34              
35             =encoding UTF-8
36              
37             =head1 NAME
38              
39             Form::Factory::Stasher::Memory - Remember things in a Perl hash
40              
41             =head1 VERSION
42              
43             version 0.022
44              
45             =head1 SYNOPSIS
46              
47             $c->session->{stash_stuff} ||= {};
48             my $stasher = Form::Factory::Stasher::Memory->new(
49             stash_hash => $c->session->{stash_stuff},
50             );
51              
52             $stasher->stash(foo => { blah => 1 });
53             my $bar = $stasher->unstash('bar');
54              
55             =head1 DESCRIPTION
56              
57             Stashes things into a plain memory hash. This is useful if you already have a mechanism for remember things that can be reused via a hash.
58              
59             =head1 ATTRIBUTES
60              
61             =head2 stash_hash
62              
63             The hash reference to stash stuff into. Defaults to an empty anonymous hash.
64              
65             =head1 METHODS
66              
67             =head2 stash
68              
69             Stash the stuff given.
70              
71             =head2 unstash
72              
73             Unstash the stuff requested.
74              
75             =head1 AUTHOR
76              
77             Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
78              
79             =head1 COPYRIGHT AND LICENSE
80              
81             This software is copyright (c) 2015 by Qubling Software LLC.
82              
83             This is free software; you can redistribute it and/or modify it under
84             the same terms as the Perl 5 programming language system itself.
85              
86             =cut