File Coverage

blib/lib/DBIx/Class/CDBICompat/Constructor.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package # hide from PAUSE
2             DBIx::Class::CDBICompat::Constructor;
3              
4 2     2   1021 use strict;
  2         5  
  2         47  
5 2     2   9 use warnings;
  2         4  
  2         54  
6              
7 2     2   9 use base 'DBIx::Class::CDBICompat::ImaDBI';
  2         3  
  2         527  
8              
9             use Carp;
10             use DBIx::Class::_Util qw(quote_sub perlstring);
11              
12             __PACKAGE__->set_sql(Retrieve => <<'');
13             SELECT __ESSENTIAL__
14             FROM __TABLE__
15             WHERE %s
16              
17             sub add_constructor {
18             my ($class, $method, $fragment) = @_;
19              
20             croak("constructors needs a name") unless $method;
21              
22             carp("$method already exists in $class") && return
23             if $class->can($method);
24              
25             quote_sub "${class}::${method}" => sprintf( <<'EOC', perlstring $fragment );
26             my $self = shift;
27             $self->sth_to_objects($self->sql_Retrieve(%s), \@_);
28             EOC
29             }
30              
31             1;