Teeny/Stash.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 44 CC 2 SCAR 11.5
CC
2
Cov
0%
add_section
6.0
BUILDARGS
2.0
sections
2.0
CRAP 3.1
1 package Template::Teeny::Stash;
2  
3 use Moose;
4 use Moose::Util::TypeConstraints;
5  
6 has vars => (is => 'rw', isa => 'HashRef', default => sub { {} });
7 has _sections => (is => 'rw', isa => 'HashRef[ArrayRef]', default => sub { {} });
8  
9 sub BUILDARGS { return { vars => ($_[1]||{}) }; }
10  
11 sub sections { @{ $_[0]->_sections->{$_[1]} || [] }; }
12 sub add_section {
13 my ($self,$sec,@stashes) = @_;
14 $self->_sections->{$sec} ||= [];
15 push @{ $self->_sections->{$sec} }, (@stashes ? @stashes : undef);
16 }
17  
18 # XXX - add ability to deal with filters here
19 sub get {
20 # All values return are always strings
21 "" . ( $_[0]->vars->{$_[1]} || '' );
22 }
23  
24 __PACKAGE__->meta->make_immutable();
25 1;
26  
27 __END__