File Coverage

blib/lib/Class/ReluctantORM/Monitor/ColumnCount.pm
Criterion Covered Total %
statement 9 14 64.2
branch n/a
condition n/a
subroutine 3 7 42.8
pod 4 4 100.0
total 16 25 64.0


line stmt bran cond sub pod time code
1             package Class::ReluctantORM::Monitor::ColumnCount;
2              
3             =head1 NAME
4              
5             Class::ReluctantORM::Monitor::ColumnCount
6              
7             =head1 SYNOPSIS
8              
9             use aliased 'Class::ReluctantORM::Monitor::ColumnCount';
10             my $mon = ColumnCounter->new(highwater_count => N, fatal_threshold => X);
11             Class::ReluctantORM->install_global_monitor($mon);
12             Pirate->install_class_monitor($mon);
13              
14             # Do a query.... logging and highwater scorekeeping happens
15             Pirate->fetch(...);
16              
17             # Read from the monitor
18             my $count = $mon->last_measured_value();
19              
20             =head1 DESCRIPTION
21              
22             Tracks the number of OutputColumns in the last query executed.
23              
24             This is a Measuring Monitor.
25              
26             =cut
27              
28 1     1   5 use strict;
  1         3  
  1         33  
29 1     1   9 use warnings;
  1         1  
  1         27  
30 1     1   5 use base 'Class::ReluctantORM::Monitor::Measuring';
  1         2  
  1         691  
31              
32 0     0 1   sub permitted_events { return qw(execute_begin); }
33 0     0 1   sub default_events { return qw(execute_begin); }
34 0     0 1   sub measurement_label { return 'Column Count'; }
35             sub take_measurement {
36 0     0 1   my ($mon, %event) = @_;
37 0           return scalar($event{sql_obj}->output_columns);
38             }
39              
40             1;