| 1 | package DBIO::Candy; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Sugar syntax for defining DBIO result classes | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 8 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use DBIO::Candy::Exports (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use DBIO::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use MRO::Compat; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Sub::Exporter 'build_exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 8 | my %aliases = ( | |||||||||||||||||||||||||||
| 17 | column => 'add_columns', | ||||||||||||||||||||||||||||
| 18 | primary_key => 'set_primary_key', | ||||||||||||||||||||||||||||
| 19 | unique_constraint => 'add_unique_constraint', | ||||||||||||||||||||||||||||
| 20 | relationship => 'add_relationship', | ||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 8 | my @methods = qw( | |||||||||||||||||||||||||||
| 24 | resultset_class | ||||||||||||||||||||||||||||
| 25 | resultset_attributes | ||||||||||||||||||||||||||||
| 26 | remove_columns | ||||||||||||||||||||||||||||
| 27 | remove_column | ||||||||||||||||||||||||||||
| 28 | table | ||||||||||||||||||||||||||||
| 29 | source_name | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | inflate_column | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | belongs_to | ||||||||||||||||||||||||||||
| 34 | has_many | ||||||||||||||||||||||||||||
| 35 | might_have | ||||||||||||||||||||||||||||
| 36 | has_one | ||||||||||||||||||||||||||||
| 37 | many_to_many | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | sequence | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | col_created | ||||||||||||||||||||||||||||
| 42 | col_updated | ||||||||||||||||||||||||||||
| 43 | cols_updated_created | ||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 20 | ▶ | sub base { return $_[1] || 'DBIO::Core' } | ||||||||||||||||||||||||||
|
Subroutine
base: called CC=2 SCAR=7.6
Pod
documented
Condition50%1/2
$_[1] || 'DBIO::Core'
MC/DC0%0/1
$_[1] || 'DBIO::Core'
$_[1]
Truth table50%1/2
A
A= $_[1]
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 10 | ▶ | sub perl_version { return $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
perl_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 10 | ▶ | sub autotable { $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
autotable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 10 | ▶ | sub experimental { $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
experimental: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub _extract_part { | ||||||||||||||||||||||||||
|
Subroutine
_extract_part: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 59 | 0 | my ($self, $class) = @_; | |||||||||||||||||||||||||||
| 60 | 0 | ▶ | if (my ( $part ) = $class =~ /(?:::Schema)?::Result::(.+)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | return $part | |||||||||||||||||||||||||||
| 62 | } else { | ||||||||||||||||||||||||||||
| 63 | 0 | croak 'unrecognized naming scheme!' | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my $decamelize = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 68 | 0 | my $s = shift; | |||||||||||||||||||||||||||
| 69 | 0 | $s =~ s{([^a-zA-Z]?)([A-Z]*)([A-Z])([a-z]?)}{ | |||||||||||||||||||||||||||
| 70 | 0 | my $fc = pos($s)==0; | |||||||||||||||||||||||||||
| 71 | 0 | my ($p0,$p1,$p2,$p3) = ($1,lc$2,lc$3,$4); | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | my $t = $p0 || $fc ? $p0 : '_'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$p0 or $fc
MC/DC0%0/2
$p0 or $fc
$p0
$fc
Truth table0%0/3
A or B
A= $p0B= $fc
| |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $t .= $p3 ? $p1 ? "${p1}_$p2$p3" : "$p2$p3" : "$p1$p2"; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 74 | 0 | $t; | |||||||||||||||||||||||||||
| 75 | }ge; | ||||||||||||||||||||||||||||
| 76 | 0 | $s; | |||||||||||||||||||||||||||
| 77 | 8 | }; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub gen_table { | ||||||||||||||||||||||||||
|
Subroutine
gen_table: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 0 | my ( $self, $class, $version ) = @_; | |||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($version eq 'singular') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 83 | 0 | my $part = $self->_extract_part($class); | |||||||||||||||||||||||||||
| 84 | 0 | $part =~ s/:://g; | |||||||||||||||||||||||||||
| 85 | 0 | return $decamelize->($part); | |||||||||||||||||||||||||||
| 86 | } elsif ($version == 1) { | ||||||||||||||||||||||||||||
| 87 | 0 | my $part = $self->_extract_part($class); | |||||||||||||||||||||||||||
| 88 | 0 | require Lingua::EN::Inflect; | |||||||||||||||||||||||||||
| 89 | 0 | $part =~ s/:://g; | |||||||||||||||||||||||||||
| 90 | 0 | $part = $decamelize->($part); | |||||||||||||||||||||||||||
| 91 | 0 | return join q{_}, split /\s+/, Lingua::EN::Inflect::PL(join q{ }, split /_/, $part); | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 10 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 96 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 10 | my $inheritor = caller(0); | |||||||||||||||||||||||||||
| 99 | 10 | my $args = $self->parse_arguments(\@_); | |||||||||||||||||||||||||||
| 100 | 10 | my $perl_version = $self->perl_version($args->{perl_version}); | |||||||||||||||||||||||||||
| 101 | 10 | my $experimental = $self->experimental($args->{experimental}); | |||||||||||||||||||||||||||
| 102 | 10 | my @rest = @{$args->{rest}}; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 10 | $self->set_base($inheritor, $args->{base}); | |||||||||||||||||||||||||||
| 105 | # Always load Timestamp for col_created/col_updated/cols_updated_created | ||||||||||||||||||||||||||||
| 106 | 10 | $inheritor->load_components('Timestamp', @{$args->{components}}); | |||||||||||||||||||||||||||
| 107 | 10 | my @custom_methods; | |||||||||||||||||||||||||||
| 108 | my %custom_aliases; | ||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||
| 110 | 10 | my @custom = $self->gen_custom_imports($inheritor); | |||||||||||||||||||||||||||
| 111 | 10 | @custom_methods = @{$custom[0]}; | |||||||||||||||||||||||||||
| 112 | 10 | %custom_aliases = %{$custom[1]}; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 10 | ▶ | my $set_table = sub {}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 116 | 10 | ▶ | if (my $v = $self->autotable($args->{autotable})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | my $table_name = $self->gen_table($inheritor, $v); | |||||||||||||||||||||||||||
| 118 | 0 | my $ran = 0; | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | $set_table = sub { $inheritor->table($table_name) unless $ran++ } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | } | |||||||||||||||||||||||||||
| 121 | 10 | @_ = ($self, @rest); | |||||||||||||||||||||||||||
| 122 | my $import = build_exporter({ | ||||||||||||||||||||||||||||
| 123 | exports => [ | ||||||||||||||||||||||||||||
| 124 | has_column => $self->gen_has_column($inheritor, $set_table), | ||||||||||||||||||||||||||||
| 125 | primary_column => $self->gen_primary_column($inheritor, $set_table), | ||||||||||||||||||||||||||||
| 126 | unique_column => $self->gen_unique_column($inheritor, $set_table), | ||||||||||||||||||||||||||||
| 127 | indices => $self->gen_indices($inheritor, $set_table), | ||||||||||||||||||||||||||||
| 128 | 161 | (map { $_ => $self->gen_proxy($inheritor, $set_table) } @methods, @custom_methods), | |||||||||||||||||||||||||||
| 129 | 10 | (map { $_ => $self->gen_rename_proxy($inheritor, $set_table, %aliases, %custom_aliases) } | |||||||||||||||||||||||||||
| 130 | keys %aliases, keys %custom_aliases), | ||||||||||||||||||||||||||||
| 131 | ], | ||||||||||||||||||||||||||||
| 132 | groups => { | ||||||||||||||||||||||||||||
| 133 | default => [ | ||||||||||||||||||||||||||||
| 134 | qw(has_column primary_column unique_column indices), @methods, @custom_methods, keys %aliases, keys %custom_aliases | ||||||||||||||||||||||||||||
| 135 | ], | ||||||||||||||||||||||||||||
| 136 | }, | ||||||||||||||||||||||||||||
| 137 | installer => $self->installer, | ||||||||||||||||||||||||||||
| 138 | collectors => [ | ||||||||||||||||||||||||||||
| 139 | INIT => $self->gen_INIT($perl_version, \%custom_aliases, \@custom_methods, $inheritor, $experimental), | ||||||||||||||||||||||||||||
| 140 | ], | ||||||||||||||||||||||||||||
| 141 | }); | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 10 | goto $import | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 10 | ▶ | sub gen_custom_imports { | ||||||||||||||||||||||||||
|
Subroutine
gen_custom_imports: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | 10 | my ($self, $inheritor) = @_; | |||||||||||||||||||||||||||
| 149 | 10 | my @methods; | |||||||||||||||||||||||||||
| 150 | my %aliases; | ||||||||||||||||||||||||||||
| 151 | 10 | for (@{mro::get_linear_isa($inheritor)}) { | |||||||||||||||||||||||||||
| 152 | 202 | ▶ | if (my $a = DBIO::Candy::Exports::get_aliases_for($_)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 1 | %aliases = (%aliases, %$a) | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | 202 | ▶ | if (my $m = DBIO::Candy::Exports::get_methods_for($_)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 1 | @methods = (@methods, @$m) | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | 10 | return(\@methods, \%aliases) | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 10 | ▶ | sub parse_arguments { | ||||||||||||||||||||||||||
|
Subroutine
parse_arguments: called CC=10 SCAR=28.0
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 165 | 10 | my @args = @{shift @_}; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 10 | my $skipnext; | |||||||||||||||||||||||||||
| 168 | my $base; | ||||||||||||||||||||||||||||
| 169 | 10 | my @rest; | |||||||||||||||||||||||||||
| 170 | 10 | my $perl_version = undef; | |||||||||||||||||||||||||||
| 171 | 10 | my $components = []; | |||||||||||||||||||||||||||
| 172 | 10 | my $autotable = 0; | |||||||||||||||||||||||||||
| 173 | 10 | my $experimental; | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 10 | for my $idx ( 0 .. $#args ) { | |||||||||||||||||||||||||||
| 176 | 4 | my $val = $args[$idx]; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 4 | ▶ | next unless defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 4 | ▶ | if ($skipnext) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 2 | $skipnext--; | |||||||||||||||||||||||||||
| 181 | 2 | next; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 2 | ▶ | if ( $val eq '-base' ) { | ||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 185 | 0 | $base = $args[$idx + 1]; | |||||||||||||||||||||||||||
| 186 | 0 | $skipnext = 1; | |||||||||||||||||||||||||||
| 187 | } elsif ( $val eq '-autotable' ) { | ||||||||||||||||||||||||||||
| 188 | 0 | $autotable = $args[$idx + 1]; | |||||||||||||||||||||||||||
| 189 | 0 | ▶ | $autotable = ord $autotable if length $autotable == 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | $skipnext = 1; | |||||||||||||||||||||||||||
| 191 | } elsif ( $val eq '-perl5' ) { | ||||||||||||||||||||||||||||
| 192 | 0 | $perl_version = ord $args[$idx + 1]; | |||||||||||||||||||||||||||
| 193 | 0 | $skipnext = 1; | |||||||||||||||||||||||||||
| 194 | } elsif ( $val eq '-experimental' ) { | ||||||||||||||||||||||||||||
| 195 | 0 | $experimental = $args[$idx + 1]; | |||||||||||||||||||||||||||
| 196 | 0 | $skipnext = 1; | |||||||||||||||||||||||||||
| 197 | } elsif ( $val eq '-components' ) { | ||||||||||||||||||||||||||||
| 198 | 2 | $components = $args[$idx + 1]; | |||||||||||||||||||||||||||
| 199 | 2 | $skipnext = 1; | |||||||||||||||||||||||||||
| 200 | } else { | ||||||||||||||||||||||||||||
| 201 | 0 | push @rest, $val; | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | return { | ||||||||||||||||||||||||||||
| 206 | 10 | autotable => $autotable, | |||||||||||||||||||||||||||
| 207 | base => $base, | ||||||||||||||||||||||||||||
| 208 | perl_version => $perl_version, | ||||||||||||||||||||||||||||
| 209 | components => $components, | ||||||||||||||||||||||||||||
| 210 | rest => \@rest, | ||||||||||||||||||||||||||||
| 211 | experimental => $experimental, | ||||||||||||||||||||||||||||
| 212 | }; | ||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 10 | ▶ | sub gen_primary_column { | ||||||||||||||||||||||||||
|
Subroutine
gen_primary_column: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 217 | 10 | my ($self, $inheritor, $set_table) = @_; | |||||||||||||||||||||||||||
| 218 | 10 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 219 | 10 | my $i = $inheritor; | |||||||||||||||||||||||||||
| 220 | 6 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 221 | 6 | my $column = shift; | |||||||||||||||||||||||||||
| 222 | 6 | my $info = shift; | |||||||||||||||||||||||||||
| 223 | 6 | $set_table->(); | |||||||||||||||||||||||||||
| 224 | 6 | $i->add_columns($column => $info); | |||||||||||||||||||||||||||
| 225 | 6 | $i->set_primary_key($i->primary_columns, $column); | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | 10 | } | |||||||||||||||||||||||||||
| 228 | 10 | } | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 10 | ▶ | sub gen_unique_column { | ||||||||||||||||||||||||||
|
Subroutine
gen_unique_column: called CC=1 SCAR=1.6
Pod
documented
| |||||||||||||||||||||||||||||
| 231 | 10 | my ($self, $inheritor, $set_table) = @_; | |||||||||||||||||||||||||||
| 232 | 10 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=3.1
| |||||||||||||||||||||||||||||
| 233 | 10 | my $i = $inheritor; | |||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 235 | 0 | my $column = shift; | |||||||||||||||||||||||||||
| 236 | 0 | my $info = shift; | |||||||||||||||||||||||||||
| 237 | 0 | $set_table->(); | |||||||||||||||||||||||||||
| 238 | 0 | $i->add_columns($column => $info); | |||||||||||||||||||||||||||
| 239 | 0 | $i->add_unique_constraint([ $column ]); | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | 10 | } | |||||||||||||||||||||||||||
| 242 | 10 | } | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 10 | ▶ | sub gen_has_column { | ||||||||||||||||||||||||||
|
Subroutine
gen_has_column: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 245 | 10 | my ($self, $inheritor, $set_table) = @_; | |||||||||||||||||||||||||||
| 246 | 10 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 247 | 10 | my $i = $inheritor; | |||||||||||||||||||||||||||
| 248 | 8 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 249 | 8 | my $column = shift; | |||||||||||||||||||||||||||
| 250 | 8 | $set_table->(); | |||||||||||||||||||||||||||
| 251 | 8 | $i->add_columns($column => { @_ }) | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | 10 | } | |||||||||||||||||||||||||||
| 254 | 10 | } | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | # Sugar wrapper around the indices() class method installed by | ||||||||||||||||||||||||||||
| 257 | # DBIO::ResultSourceProxy — available to both vanilla and Candy. | ||||||||||||||||||||||||||||
| 258 | 10 | ▶ | sub gen_indices { | ||||||||||||||||||||||||||
|
Subroutine
gen_indices: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 259 | 10 | my ($self, $inheritor, $set_table) = @_; | |||||||||||||||||||||||||||
| 260 | 10 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 261 | 10 | my $i = $inheritor; | |||||||||||||||||||||||||||
| 262 | 4 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 263 | 4 | $set_table->(); | |||||||||||||||||||||||||||
| 264 | 4 | $i->indices(@_); | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | 10 | } | |||||||||||||||||||||||||||
| 267 | 10 | } | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 41 | ▶ | sub gen_rename_proxy { | ||||||||||||||||||||||||||
|
Subroutine
gen_rename_proxy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 270 | 41 | my ($self, $inheritor, $set_table, %aliases) = @_; | |||||||||||||||||||||||||||
| 271 | 41 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 272 | 41 | my ($class, $name) = @_; | |||||||||||||||||||||||||||
| 273 | 41 | my $meth = $aliases{$name}; | |||||||||||||||||||||||||||
| 274 | 41 | my $i = $inheritor; | |||||||||||||||||||||||||||
| 275 | 14 | ▶ | sub { $set_table->(); $i->$meth(@_) } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 276 | 41 | } | |||||||||||||||||||||||||||
| 277 | 41 | } | |||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 161 | ▶ | sub gen_proxy { | ||||||||||||||||||||||||||
|
Subroutine
gen_proxy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 280 | 161 | my ($self, $inheritor, $set_table) = @_; | |||||||||||||||||||||||||||
| 281 | 161 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 282 | 161 | my ($class, $name) = @_; | |||||||||||||||||||||||||||
| 283 | 161 | my $i = $inheritor; | |||||||||||||||||||||||||||
| 284 | 13 | ▶ | sub { $set_table->(); $i->$name(@_) } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 285 | 161 | } | |||||||||||||||||||||||||||
| 286 | 161 | } | |||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 10 | ▶ | sub installer { | ||||||||||||||||||||||||||
|
Subroutine
installer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 290 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||
| 291 | 10 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 292 | 10 | Sub::Exporter::default_installer @_; | |||||||||||||||||||||||||||
| 293 | 10 | my %subs = @{ $_[1] }; | |||||||||||||||||||||||||||
| 294 | 10 | namespace::clean->import( -cleanee => $_[0]{into}, keys %subs ) | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | 10 | } | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 10 | ▶ | sub set_base { | ||||||||||||||||||||||||||
|
Subroutine
set_base: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 300 | 10 | my ($self, $inheritor, $base) = @_; | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | # inlined from parent.pm | ||||||||||||||||||||||||||||
| 303 | 10 | for ( my @useless = $self->base($base) ) { | |||||||||||||||||||||||||||
| 304 | 10 | DBIO::Util::assert_class_name($_); | |||||||||||||||||||||||||||
| 305 | 10 | s{::|'}{/}g; | |||||||||||||||||||||||||||
| 306 | 10 | require "$_.pm"; # dies if the file is not found | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||
| 310 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 311 | # Idempotent: skip if already in @ISA (needed for Loader reload) | ||||||||||||||||||||||||||||
| 312 | 10 | my @base = $self->base($base); | |||||||||||||||||||||||||||
| 313 | 0 | my %seen = map { $_ => 1 } @{"$inheritor\::ISA"}; | |||||||||||||||||||||||||||
| 314 | 10 | my @new = grep { !$seen{$_} } @base; | |||||||||||||||||||||||||||
| 315 | 10 | ▶ | @{"$inheritor\::ISA"} = (@{"$inheritor\::ISA"}, @new) if @new; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 10 | ▶ | sub gen_INIT { | ||||||||||||||||||||||||||
|
Subroutine
gen_INIT: called CC=1 SCAR=0.9
Pod
documented
| |||||||||||||||||||||||||||||
| 321 | 10 | my ($self, $perl_version, $custom_aliases, $custom_methods, $inheritor, $experimental) = @_; | |||||||||||||||||||||||||||
| 322 | 10 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=20.9
| |||||||||||||||||||||||||||||
| 323 | 10 | my $orig = $_[1]->{import_args}; | |||||||||||||||||||||||||||
| 324 | 10 | $_[1]->{import_args} = []; | |||||||||||||||||||||||||||
| 325 | 10 | %$custom_aliases = (); | |||||||||||||||||||||||||||
| 326 | 10 | @$custom_methods = (); | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 10 | strict->import; | |||||||||||||||||||||||||||
| 329 | 10 | warnings->import; | |||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 10 | ▶ | if ($perl_version) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | 0 | require feature; | |||||||||||||||||||||||||||
| 333 | 0 | feature->import(":5.$perl_version") | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 10 | ▶ | if ($experimental) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 0 | require experimental; | |||||||||||||||||||||||||||
| 338 | 0 | ▶ | die 'experimental arg must be an arrayref!' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $experimental and ref $experimental eq "ARRAY"
MC/DC0%0/2
ref $experimental and ref $experimental eq "ARRAY"
ref $experimental
ref $experimental eq "ARRAY"
Truth table0%0/3
A and B
A= ref $experimentalB= ref $experimental eq "ARRAY"
| |||||||||||||||||||||||||||||
| 339 | unless ref $experimental && ref $experimental eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 340 | # to avoid experimental referring to the method | ||||||||||||||||||||||||||||
| 341 | 0 | experimental::->import(@$experimental) | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | 10 | mro::set_mro($inheritor, 'c3'); | |||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 10 | 1; | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | 10 | } | |||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 8 | 1; | |||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | __END__ | ||||||||||||||||||||||||||||