| 1 | package DBIO::Moo; | ||||||||||
| 2 | # ABSTRACT: Enable Moo attributes in DBIO result classes | ||||||||||
| 3 | |||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 7 | our $VERSION = '0.900007'; | |||||||||
| 8 | |||||||||||
| 9 | 7 | ▶ | use DBIO::Util (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 17 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=5 SCAR=16.2
| |||||||||||
| 12 | 17 | my ($class) = @_; | |||||||||
| 13 | 17 | my $caller = caller; | |||||||||
| 14 | |||||||||||
| 15 | # Enable strict and warnings in caller | ||||||||||
| 16 | 17 | strict->import; | |||||||||
| 17 | 17 | warnings->import; | |||||||||
| 18 | |||||||||||
| 19 | # Activate Moo in the caller package | ||||||||||
| 20 | 7 | ▶ | eval "package $caller; use Moo; 1" or die $@; ## no critic | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||
| 21 | |||||||||||
| 22 | # Set up DBIO::Core as the base class via Moo's extends | ||||||||||
| 23 | 17 | require DBIO::Core; | |||||||||
| 24 | 17 | ▶ | unless ( $caller->isa('DBIO::Core') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 17 | ▶ | eval "package $caller; extends 'DBIO::Core'; 1" or die $@; ## no critic | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | # Install FOREIGNBUILDARGS to bridge Moo's new() and DBIO's new() | ||||||||||
| 29 | # Without this, Moo does not call the non-Moo parent constructor at all. | ||||||||||
| 30 | 7 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 17 | ▶ | *{"${caller}::FOREIGNBUILDARGS"} = \&DBIO::Util::foreignbuildargs | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | unless $caller->can('FOREIGNBUILDARGS'); | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | 7 | 1; | |||||||||
| 37 | |||||||||||
| 38 | __END__ | ||||||||||