blib/lib/SQL/Translator/Schema/IndexField.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 100% 4 / 4 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 80.0% 4 / 5 Podpod n/a totaltotal 85.0% 34 / 40 CC 5 SCAR 12.1
CC
5
Cov
91%
__ANON__
5.0
__ANON__
2.0
BEGIN
1.0
CRAP 3.3
« blib/lib/SQL/Translator/Filter/Names.pm ↑ Summary blib/lib/SQL/Translator/Producer/Latex.pm »
1 package SQL::Translator::Schema::IndexField;
2  
3 =pod
4  
5 =head1 NAME
6  
7 SQL::Translator::Schema::IndexField - SQL::Translator index field object
8  
9 =head1 DESCRIPTION
10  
11 C<SQL::Translator::Schema::IndexField> is the index field object.
12  
13 Different databases allow for different options on index fields. Those are supported through here
14  
15 =head1 METHODS
16  
17 =cut
18  
19 76 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 76 extends 'SQL::Translator::Schema::Object';
22  
23 76 ▶use overload '""' => sub { shift->name };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
24  
25 =head2 new
26  
27 Object constructor.
28  
29 my $schema = SQL::Translator::Schema::IndexField->new;
30  
31 =head2 name
32  
33 The name of the index. The object stringifies to this. In addition, you can simply pass
34 a string to the constructor to only set this attribute.
35  
36 =head2 extra
37  
38 All options for the field are stored under the extra hash. The constructor will collect
39 them for you if passed in straight. In addition, an accessor is provided for all supported options
40  
41 Currently supported options:
42  
43 =over 4
44  
45 =item prefix_length
46  
47 Supported by MySQL. Indicates that only N characters of the column are indexed.
48  
49 =back
50  
51 =cut
52  
53 175 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=5 SCAR=16.2
54 175 my ($orig, $self, @args) = @_;
55 175 ▶ if (@args == 1 && !ref $args[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args == 1 and not ref $args[0]) 163 12 175
Condition66%2/3
@args == 1 and not ref $args[0]
!ll&&!rl&&r
012163
MC/DC50%1/2
@args == 1 and not ref $args[0]
@args == 1 not ref $args[0]
Truth table66%2/3
A and not(B)
A= @args == 1B= not ref $args[0]
ABresult
0X0
100
111
56 163 @args = (name => $args[0]);
57 }
58  
59 # there are some weird pathological cases where we get an object passed in rather than a
60 # hashref. We'll just clone it
61 175 ▶ if (ref $args[0] eq $self) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args[0] eq $self) 1 174 175
62 1 return { %{ $args[0] } };
63 }
64 174 my $args = $self->$orig(@args);
65 174 ▶ my $extra = delete $args->{extra} || {};
Condition50%1/2
delete $args->{'extra'} || {}
l!l
0174
MC/DC0%0/1
delete $args->{'extra'} || {}
delete $args->{'extra'}
Truth table50%1/2
A
A= delete $args->{'extra'}
Aresult
11
00
66 174 my $name = delete $args->{name};
67 return {
68 174 name => $name,
69 extra => { %$extra, %$args }
70 };
71 76 };
72  
73 76 has name => (
74 is => 'rw',
75 required => 1,
76 );
77  
78 has extra => (
79 is => 'rw',
80 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
81 76 );
82  
83 =pod
84  
85 =head1 AUTHOR
86  
87 Veesh Goldman E<lt>veesh@cpan.orgE<gt>.
88  
89 =cut
90  
91 76 9007
« blib/lib/SQL/Translator/Filter/Names.pm ↑ Summary blib/lib/SQL/Translator/Producer/Latex.pm »