| 1 | 5 | ▶ | use 5.008; # utf8 | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | package IO::Async::XMLStream::SAXReader::DuckHandler; | ||||||||||
| 7 | 5 | $IO::Async::XMLStream::SAXReader::DuckHandler::VERSION = '0.001000'; | |||||||||
| 8 | # ABSTRACT: Deferred Handler proxy for IO::Async constructor-driven interface | ||||||||||
| 9 | |||||||||||
| 10 | 5 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||
| 11 | |||||||||||
| 12 | 5 | ▶ | use Scalar::Util qw(weaken); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 5 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | sub new { | ||||||||||
| 25 | 2 | ▶ | my ( $self, $opts ) = @_; | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 26 | 2 | ▶ | croak('SAXReader option is mandatory') unless exists $opts->{SAXReader}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 2 | weaken $opts->{SAXReader}; | |||||||||
| 28 | 2 | return bless $opts, $self; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | sub _dyn_method { | ||||||||||
| 32 | 3674 | ▶ | my ( $self, $method ) = @_; | ||||||||
|
Subroutine
_dyn_method: called CC=2 SCAR=6.9
| |||||||||||
| 33 | 3674 | my $sax = $self->{SAXReader}; | |||||||||
| 34 | 3674 | my $event = 'on_' . $method; | |||||||||
| 35 | 3674 | my $callback = $sax->can_event($event); | |||||||||
| 36 | 3674 | ▶ | return unless $callback; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | return sub { | ||||||||||
| 38 | 3744 | ▶ | my ( undef, @args ) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 3744 | return $callback->( $sax, @args ); | |||||||||
| 40 | 8 | }; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | sub can { | ||||||||||
| 44 | 38 | ▶ | my ( $self, $method ) = @_; | ||||||||
|
Subroutine
can: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | 38 | my $orig = $self->SUPER::can($method); | |||||||||
| 46 | 38 | ▶ | return $orig if $orig; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 18 | return $self->_dyn_method($method); | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | ## no critic (ClassHierarchies::ProhibitAutoloading) | ||||||||||
| 51 | sub AUTOLOAD { | ||||||||||
| 52 | 3656 | ▶ | my ( $self, @args ) = @_; | ||||||||
|
Subroutine
AUTOLOAD: called CC=3 SCAR=12.0
| |||||||||||
| 53 | 3656 | ( my $methname = our $AUTOLOAD ) =~ s/.+:://msx; | |||||||||
| 54 | 3656 | ▶ | return if 'DESTROY' eq $methname; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 3656 | ▶ | return unless my $meth = $self->_dyn_method($methname); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 0 | return $meth->( $self, @args ); | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 5 | 1; | |||||||||
| 60 | |||||||||||
| 61 | __END__ | ||||||||||