| 1 | package Class::MakeMethods::Attribute; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | require 5.006; | |||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Attribute::Handlers; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Class::MakeMethods; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Class::MakeMethods::Utility::Inheritable 'get_vvalue'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = 1.005; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | our %DefaultMaker; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=4 SCAR=15.9
| |||||||||||||||||||||||||||||
| 16 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | if ( scalar @_ and $_[0] =~ m/^\d/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
scalar @_ and $_[0] =~ /^\d/
MC/DC0%0/2
scalar @_ and $_[0] =~ /^\d/
scalar @_
$_[0] =~ /^\d/
Truth table33%1/3
A and B
A= scalar @_B= $_[0] =~ /^\d/
| |||||||||||||||||||||||||||||
| 19 | 0 | Class::MakeMethods::_import_version( $class, shift ); | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | if ( scalar @_ == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 1 | my $target_class = ( caller(0) )[0]; | |||||||||||||||||||||||||||
| 24 | 1 | $DefaultMaker{ $target_class } = shift; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 4 | ▶ | sub UNIVERSAL::MakeMethod :ATTR(CODE) { | ||||||||||||||||||||||||||
|
Subroutine
MakeMethod: called CC=8 SCAR=22.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 4 | my ($package, $symbol, $referent, $attr, $data) = @_; | |||||||||||||||||||||||||||
| 30 | 4 | ▶ | if ( $symbol eq 'ANON' or $symbol eq 'LEXICAL' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$symbol eq "ANON" or $symbol eq "LEXICAL"
MC/DC0%0/2
$symbol eq "ANON" or $symbol eq "LEXICAL"
$symbol eq "ANON"
$symbol eq "LEXICAL"
Truth table33%1/3
A or B
A= $symbol eq "ANON"B= $symbol eq "LEXICAL"
| |||||||||||||||||||||||||||||
| 31 | 0 | croak "Can't apply MakeMethod attribute to $symbol declaration." | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 4 | ▶ | if ( ! $data ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 0 | croak "No method type provided for MakeMethod attribute." | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 4 | my $symname = *{$symbol}{NAME}; | |||||||||||||||||||||||||||
| 37 | 4 | ▶ | if ( ref $data eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 4 | local $_ = shift @$data; | |||||||||||||||||||||||||||
| 39 | 4 | $symname = [ @$data, $symname ]; | |||||||||||||||||||||||||||
| 40 | 4 | $data = $_; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 4 | ▶ | unless ( $DefaultMaker{$package} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 1 | local $_ = get_vvalue( \%DefaultMaker, $package ); | |||||||||||||||||||||||||||
| 44 | 1 | ▶ | $DefaultMaker{$package} = $_ if ( $_ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | Class::MakeMethods->make( | ||||||||||||||||||||||||||||
| 47 | -TargetClass => $package, | ||||||||||||||||||||||||||||
| 48 | -ForceInstall => 1, | ||||||||||||||||||||||||||||
| 49 | 4 | ▶ | ( $DefaultMaker{$package} ? ('-MakerClass'=>$DefaultMaker{$package}) : () ), | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | $data => $symname | ||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||
| 52 | 1 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 1 | 1; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||||||||||