| 1 | package EO::NotAttributes; | ||||||||||
| 2 | |||||||||||
| 3 | # this isn't an EO object, but it needs the EO::Error::* stuff | ||||||||||
| 4 | # declared in there. | ||||||||||
| 5 | 18 | ▶ | use EO; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 18 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 18 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 18 | ▶ | use Scalar::Util qw(blessed); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 18 | our $VERSION = 0.96; | |||||||||
| 13 | |||||||||||
| 14 | =begin notused | ||||||||||
| 15 | |||||||||||
| 16 | At some point we should implement Private. We haven't yet. | ||||||||||
| 17 | |||||||||||
| 18 | sub UNIVERSAL::Private : ATTR(CODE) { | ||||||||||
| 19 | my ($package, $symbol, $referent, $attr, $data) = @_; | ||||||||||
| 20 | no strict 'refs'; | ||||||||||
| 21 | no warnings 'redefine'; | ||||||||||
| 22 | my $thing = *{$symbol}; | ||||||||||
| 23 | my $meth = substr($thing, rindex($thing,':')+1); | ||||||||||
| 24 | *{$symbol} = sub { | ||||||||||
| 25 | my $self = shift; | ||||||||||
| 26 | my $class = ref($self); | ||||||||||
| 27 | my ($callpkg, $callfile, $callline) = caller(); | ||||||||||
| 28 | if ($package ne $callpkg) { | ||||||||||
| 29 | my $text = "Can't private method \"$meth\" from package $package"; | ||||||||||
| 30 | throw EO::Error::Method::Private | ||||||||||
| 31 | text => $text, | ||||||||||
| 32 | file => $callfile; | ||||||||||
| 33 | } | ||||||||||
| 34 | $referent->( $self, @_ ); | ||||||||||
| 35 | }; | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | =end notused | ||||||||||
| 39 | |||||||||||
| 40 | =cut | ||||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | sub sub::Abstract($) { | ||||||||
|
Subroutine
Abstract: called CC=1 SCAR=0.7
| |||||||||||
| 43 | 1 | my $meth = shift; | |||||||||
| 44 | 1 | my ($package, $filename, $line) = caller; | |||||||||
| 45 | 18 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 46 | 18 | ▶ | no warnings 'redefine'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 47 | 1 | ▶ | *{"${package}::${meth}"} = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=15.4
| |||||||||||
| 48 | 0 | my $self = shift; | |||||||||
| 49 | 0 | ▶ | my $class = blessed($self) ? ref($self) : $self; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | my ($package, $filename, $line) = caller(); | |||||||||
| 51 | 0 | my $text = "Can't call abstract method \"$meth\" on object of type \"$class\""; | |||||||||
| 52 | 0 | throw EO::Error::Method::Abstract | |||||||||
| 53 | text => $text, | ||||||||||
| 54 | file => $filename; | ||||||||||
| 55 | 1 | }; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub sub::abstract($) { sub::Abstract(@_) } | ||||||||
|
Subroutine
abstract: not called CC=1 SCAR=6.9
| |||||||||||
| 59 | |||||||||||
| 60 | 18 | 1; | |||||||||
| 61 | |||||||||||
| 62 | __END__ | ||||||||||