OpenInteract2/Action/CommonDisplay.pm

filter: Statementstmt 34.5% 19 / 55 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 62.5% 5 / 8 Podpod 0.0% 0 / 1 totaltotal 28.9% 24 / 83 CC 9 SCAR 36.2
CC
9
Cov
26%
display
72.0
_display_init_param
6.0
_display_customize
2.0
CRAP 37.2
« OpenInteract2/ActionResolver/NameAndTask.pm ↑ Summary OpenInteract2/Repository.pm »
1 package OpenInteract2::Action::CommonDisplay;
2  
3 # $Id: CommonDisplay.pm,v 1.17 2005/03/18 04:09:49 lachoy Exp $
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base qw( OpenInteract2::Action::Common );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Log::Log4perl qw( get_logger );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use OpenInteract2::Constants qw( :log );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use OpenInteract2::Context qw( CTX );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 $OpenInteract2::Action::CommonDisplay::VERSION = sprintf("%d.%02d", q$Revision: 1.17 $ =~ /(\d+)\.(\d+)/);
12  
13 1 my ( $log );
14  
15 0 ▶sub display {
Subroutine display: not called CC=8 SCAR=42.8
Pod undocumented
16 0 my ( $self ) = @_;
17 0 $self->param( c_task => 'display' );
18 0 $self->_display_init_param;
19  
20 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
21  
22 0 my $fail_task = $self->param( 'c_display_fail_task' );
23 0 my $object = eval { $self->_common_fetch_object };
24 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
25 0 return $self->execute({ task => $fail_task });
26 }
27 0 ▶ unless ( $object->is_saved ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($object->is_saved) 0 0 0
28 0 my $id = $self->param( 'c_id' );
29 0 $self->add_error_key( 'action.error.not_found', $id );
30 0 return $self->execute({ task => $fail_task });
31 }
32  
33 # TODO: It would be nice to replace this with a '$object->is_active' ...
34  
35 0 ▶ if ( my $active_field = $self->param( 'c_display_active_field' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $active_field = $self->param("c_display_active_field")) 0 0 0
36 0 my $status = $object->$active_field();
37 0 ▶ unless ( $status =~ /^\s*(y|yes|1|true)\s*$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($status =~ /^\s*(y|yes|1|true)\s*$/i) 0 0 0
38 0 my $object_class = $self->param( 'c_object_class' );
39 0 my $id = $self->param( 'c_id' );
40 0 ▶ $log->is_info &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_info and $log->info("Object [$object_class] [$id] failed ", "'active' check [Status: $status]") 0 0 0
41 $log->info( "Object [$object_class] [$id] failed ",
42 "'active' check [Status: $status]" );
43 0 $self->add_error_key( 'action.error.inactive' );
44 0 return $self->execute({ task => $fail_task });
45 }
46 0 ▶ $log->is_debug && $log->debug( "Object passed 'active' check" );
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Object passed 'active' check") 0 0 0
47 }
48  
49 # Set both 'object' and the object type equal to the object so the
50 # template can use either.
51  
52 0 my $object_type = $self->param( 'c_object_type' );
53 0 my %params = ( object => $object,
54 $object_type => $object );
55  
56 0 $self->_display_customize( \%params );
57  
58 0 my $display_template = $self->param( 'c_display_template' );
59 0 return $self->generate_content(
60 \%params, { name => $display_template } );
61 }
62  
63 1 my %DEFAULTS = (
64 c_display_fail_task => 'common_error',
65 );
66  
67 0 ▶sub _display_init_param {
Subroutine _display_init_param: not called CC=2 SCAR=17.9
68 0 my ( $self ) = @_;
69 0 $self->_common_set_defaults( \%DEFAULTS );
70  
71 0 my $has_error = $self->_common_check_object_class;
72 0 $has_error += $self->_common_check_id_field;
73 0 $has_error += $self->_common_check_id;
74 0 $has_error +=
75 $self->_common_check_template_specified( 'c_display_template' );
76 0 ▶ if ( $has_error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($has_error) 0 0 0
77 0 die $self->execute({ task => 'common_error' }), "\n";
78 }
79 }
80  
81 ########################################
82 # OVERRIDABLE
83  
84 0 ▶sub _display_customize { return undef }
Subroutine _display_customize: not called CC=1 SCAR=6.9
85  
86 1 1;
87  
88 __END__
« OpenInteract2/ActionResolver/NameAndTask.pm ↑ Summary OpenInteract2/Repository.pm »