| 1 | package Object::Sub; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | our $VERSION = '0.102'; | |||||||||
| 6 | |||||||||||
| 7 | 1 | our $AUTOLOAD; | |||||||||
| 8 | |||||||||||
| 9 | use overload fallback => 1, | ||||||||||
| 10 | '&{}' => sub { | ||||||||||
| 11 | 3 | ▶ | my $self_ref = \$_[0]; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | return sub { | ||||||||||
| 14 | 3 | ▶ | return $$self_ref->{cb}->($$self_ref, undef, @_); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 3 | }; | |||||||||
| 16 | 1 | ▶ | }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | sub AUTOLOAD { | ||||||||||
| 19 | 3 | ▶ | die "$_[0] is not an object" if !ref $_[0]; | ||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||
| 20 | |||||||||||
| 21 | 3 | my $name = $AUTOLOAD; | |||||||||
| 22 | 3 | $name =~ s/.*://; | |||||||||
| 23 | |||||||||||
| 24 | 3 | return $_[0]->{cb}->($_[0], $name, @_[1 .. $#_]); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | sub new { | ||||||||||
| 28 | 5 | ▶ | my ($class, $cb) = @_; | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 29 | |||||||||||
| 30 | 5 | ▶ | die "need a callback" if ref $cb ne 'CODE'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | 5 | my $self = { cb => $cb, }; | |||||||||
| 33 | 5 | bless $self, $class; | |||||||||
| 34 | |||||||||||
| 35 | 5 | return $self; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | ## Prevent DESTROY method from being handled by AUTOLOAD | ||||||||||
| 39 | |||||||||||
| 40 | ▶ | sub DESTROY { | |||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | 1 | 1; | |||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | __END__ | ||||||||||