File Coverage

blib/lib/DBIx/Model/Column.pm
Criterion Covered Total %
statement 12 26 46.1
branch 0 4 0.0
condition n/a
subroutine 4 8 50.0
pod 0 4 0.0
total 16 42 38.1


line stmt bran cond sub pod time code
1             package DBIx::Model::Column;
2 1     1   3 use strict;
  1         1  
  1         22  
3 1     1   2 use warnings;
  1         1  
  1         20  
4 1     1   3 use Moo;
  1         0  
  1         4  
5 1     1   222 use Types::Standard qw/ArrayRef Bool Int Str Undef/;
  1         2  
  1         5  
6              
7             our $VERSION = '0.0.1_1';
8              
9             has chain => (
10             is => 'rw',
11             isa => Int,
12             );
13              
14             has table => (
15             is => 'ro',
16             required => 1,
17             weak_ref => 1,
18             );
19              
20             has name => (
21             is => 'ro',
22             isa => Str,
23             required => 1,
24             );
25              
26             has primary => (
27             is => 'ro',
28             isa => Bool,
29             default => sub { 0 },
30             );
31              
32             has ref_count => (
33             is => 'rw',
34             isa => Int,
35             default => 0,
36             );
37              
38             has size => (
39             is => 'ro',
40             isa => Int | Undef,
41             );
42              
43             has target_count => (
44             is => 'rw',
45             isa => Int,
46             default => 0,
47             );
48              
49             has type => (
50             is => 'ro',
51             isa => Str,
52             required => 1,
53             );
54              
55             has nullable => (
56             is => 'ro',
57             isa => Bool,
58             required => 1,
59             );
60              
61             sub as_string {
62 0     0 0   my $self = shift;
63 0           my $prefix = shift;
64 0           my $str = $prefix . $self->name . ' ' . $self->type;
65 0 0         $str .= '(' . $self->size . ')' if $self->size;
66 0 0         $str .= ' NOT NULL' unless $self->nullable;
67 0           return $str;
68             }
69              
70             sub bump_ref_count {
71 0     0 0   my $self = shift;
72 0           $self->ref_count( $self->ref_count + 1 );
73 0           $self->table->bump_ref_count;
74             }
75              
76             sub bump_target_count {
77 0     0 0   my $self = shift;
78 0           $self->target_count( $self->target_count + 1 );
79 0           $self->table->bump_target_count;
80             }
81              
82             sub full_name {
83 0     0 0   my $self = shift;
84 0           return $self->table->name . '.' . $self->name;
85             }
86              
87             1;