File Coverage

blib/lib/Catalyst/ComponentRole/StoreToSession.pm
Criterion Covered Total %
statement 15 15 100.0
branch 3 4 75.0
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 21 23 91.3


line stmt bran cond sub pod time code
1             package Catalyst::ComponentRole::StoreToSession;
2              
3 1     1   3723 use Moose::Role;
  1         3  
  1         12  
4              
5             requires 'freeze', 'thaw';
6              
7             has [qw/__key __stash __session/] => (is=>'rw', weak_ref=>1);
8              
9             sub discard {
10 1     1 0 3 my $self = shift;
11 1         3 my $class = ref $self;
12 1         3 $self->{__donotsavetosession} = 1;
13 1 50       13 $self->cleanup if $self->can('cleanup');
14 1         37 delete $self->__stash->{$self->__key};
15 1         35 delete $self->__session->{$class};
16 1         4 $self = undef;
17 1         2 return undef;
18             }
19              
20             sub DESTROY {
21 8     8   27439 my $self = shift;
22 8         22 my $class = ref $self;
23              
24 8 100       42 return if $self->{__donotsavetosession};
25              
26 7         43 $self->__session->{$class} = $self->freeze;
27             }
28              
29             =head1 NAME
30              
31             Catalyst::ComponentRole::StoreToSession - components that can store to session
32              
33             =head1 DESCRIPTION
34              
35             No user servicable bits for now, you should see
36             L<Catalyst::Model::InjectionHelpers::PerSession>
37              
38             =head1 AUTHOR
39              
40             John Napiorkowski L<email:jjnapiork@cpan.org>
41            
42             =head1 SEE ALSO
43            
44             L<Catalyst::Plugin::InjectionHelpers>
45             L<Catalyst>, L<Catalyst::Model::InjectionHelpers::Application>,
46             L<Catalyst::Model::InjectionHelpers::Factory>, L<Catalyst::Model::InjectionHelpers::PerRequest>
47             L<Catalyst::Model::InjectionHelpers::PerSession>, L<Catalyst::ModelRole::InjectionHelpers>
48              
49             =head1 COPYRIGHT & LICENSE
50            
51             Copyright 2016, John Napiorkowski L<email:jjnapiork@cpan.org>
52            
53             This library is free software; you can redistribute it and/or modify it under
54             the same terms as Perl itself.
55            
56             =cut
57              
58             1;