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