WebApp/Segment/User/Loader.pm

filter: Statementstmt 91.6% 22 / 24 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 3 / 3 totaltotal 88.8% 32 / 36 CC 2 SCAR 3.2
CC
2
Cov
88%
get_user
2.0
find_user_id
2.0
BEGIN
1.0
CRAP 1.4
« WebApp/Segment/Decline/UserInSession.pm ↑ Summary WebApp/Segment/Decline.pm »
1 =head1 NAME
2  
3 OpenFrame::WebApp::Segment::User::Loader - abstract segment to load users.
4  
5 =head1 SYNOPSIS
6  
7 # abstract class - cannot be used directly
8  
9 use Pipeline;
10 use OpenFrame::WebApp;
11  
12 my $pipe = new Pipeline;
13  
14 my $ufactory = new OpenFrame::WebApp::User::Factory()->type('webapp');
15 $pipe->store->set( $ufactory );
16  
17 # abstract - must use a sub-class:
18 my $uloader = new OpenFrame::WebApp::Segment::User::EnvLoader;
19 $pipe->add_segment( $uloader );
20  
21 ...
22  
23 $pipe->dispatch;
24  
25 =cut
26  
27 package OpenFrame::WebApp::Segment::User::Loader;
28  
29 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 3 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 3 ▶use OpenFrame::WebApp::Error::Abstract;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 3 our $VERSION = (split(/ /, '$Revision: 1.2 $'))[1];
35  
36 3 ▶use base qw( Pipeline::Segment );
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 3 ▶sub dispatch {
Subroutine dispatch: called CC=1 SCAR=0.0
Pod documented
39 3 my $self = shift;
40 3 return $self->get_user();
41 }
42  
43 2 ▶sub get_user {
Subroutine get_user: called CC=2 SCAR=7.0
Pod documented
44 2 my $self = shift;
45 2 my $user;
46  
47 2 ▶ if (my $id = $self->find_user_id) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $id = $self->find_user_id) 2 0 2
48 2 my $ufactory = $self->store->get('OpenFrame::WebApp::User::Factory');
49 2 $user = $ufactory->new_user()->id( $id );
50 }
51  
52 2 return $user;
53 }
54  
55 0 ▶sub find_user_id {
Subroutine find_user_id: not called CC=1 SCAR=6.9
Pod documented
56 0 my $self = shift;
57 0 throw OpenFrame::WebApp::Error::Abstract( class => ref($self) );
58 }
59  
60  
61 3 1;
62  
63 __END__
« WebApp/Segment/Decline/UserInSession.pm ↑ Summary WebApp/Segment/Decline.pm »