File Coverage

blib/lib/DBIx/DataModel/Meta/Type.pm
Criterion Covered Total %
statement 37 37 100.0
branch 1 2 50.0
condition n/a
subroutine 11 11 100.0
pod 0 1 0.0
total 49 51 96.0


line stmt bran cond sub pod time code
1             package DBIx::DataModel::Meta::Type;
2 5     5   4496 use strict;
  5         14  
  5         154  
3 5     5   36 use warnings;
  5         12  
  5         145  
4 5     5   40 use parent "DBIx::DataModel::Meta";
  5         10  
  5         32  
5 5     5   322 use DBIx::DataModel;
  5         10  
  5         29  
6 5     5   30 use DBIx::DataModel::Meta::Utils qw/define_readonly_accessors does/;
  5         11  
  5         298  
7              
8 5     5   35 use Scalar::Util qw/weaken/;
  5         12  
  5         283  
9 5     5   33 use Params::Validate qw/validate_with OBJECT SCALAR HASHREF/;
  5         21  
  5         336  
10 5     5   37 use Carp::Clan qw[^(DBIx::DataModel::|SQL::Abstract)];
  5         10  
  5         59  
11 5     5   495 use namespace::clean;
  5         10  
  5         70  
12              
13 5     5   1656 {no strict 'refs'; *CARP_NOT = \@DBIx::DataModel::CARP_NOT;}
  5         10  
  5         1295  
14              
15             sub new {
16 6     6 0 14 my $class = shift;
17              
18             # parse arguments and create $self
19 6         143 my $self = validate_with(
20             params => \@_,
21             spec => {
22             schema => {type => OBJECT, isa => "DBIx::DataModel::Meta::Schema"},
23             name => {type => SCALAR},
24             handlers => {type => HASHREF},
25             },
26             allow_extra => 0,
27             );
28              
29 6         36 while (my ($name, $body) = each %{$self->{handlers}}) {
  19         163  
30 13 50       39 does($body, 'CODE')
31             or croak "handler body for $name is not a code reference";
32             }
33              
34             # avoid circular references
35 6         45 weaken $self->{schema};
36              
37 6         18 bless $self, $class;
38             }
39              
40              
41             # accessor methods
42             define_readonly_accessors(__PACKAGE__, qw/schema name handlers/);
43              
44              
45             1;
46              
47             __END__