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   4034 use strict;
  5         10  
  5         131  
3 5     5   23 use warnings;
  5         24  
  5         134  
4 5     5   23 use parent "DBIx::DataModel::Meta";
  5         20  
  5         26  
5 5     5   285 use DBIx::DataModel;
  5         9  
  5         24  
6 5     5   25 use DBIx::DataModel::Meta::Utils qw/define_readonly_accessors does/;
  5         8  
  5         294  
7              
8 5     5   30 use Scalar::Util qw/weaken/;
  5         7  
  5         241  
9 5     5   29 use Params::Validate qw/validate_with OBJECT SCALAR HASHREF/;
  5         15  
  5         293  
10 5     5   28 use Carp::Clan qw[^(DBIx::DataModel::|SQL::Abstract)];
  5         10  
  5         35  
11 5     5   412 use namespace::clean;
  5         9  
  5         53  
12              
13 5     5   1351 {no strict 'refs'; *CARP_NOT = \@DBIx::DataModel::CARP_NOT;}
  5         11  
  5         1008  
14              
15             sub new {
16 6     6 0 11 my $class = shift;
17              
18             # parse arguments and create $self
19 6         116 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         28 while (my ($name, $body) = each %{$self->{handlers}}) {
  19         142  
30 13 50       30 does($body, 'CODE')
31             or croak "handler body for $name is not a code reference";
32             }
33              
34             # avoid circular references
35 6         33 weaken $self->{schema};
36              
37 6         17 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__