| 1 | |||||||||||||||
| 2 | package Data::Decode::Chain; | ||||||||||||||
| 3 | 4 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 4 | ▶ | use MooseX::AttributeHelpers; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 4 | ▶ | use namespace::clean -except => qw(meta); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 4 | ▶ | use Data::Decode::Exception; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 4 | ▶ | use Data::Decode::Types; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | 4 | has decoders => ( | |||||||||||||
| 10 | metaclass => 'Collection::Array', | ||||||||||||||
| 11 | is => 'ro', | ||||||||||||||
| 12 | isa => 'Data::Decode::DecoderList', | ||||||||||||||
| 13 | required => 1, | ||||||||||||||
| 14 | coerce => 1, | ||||||||||||||
| 15 | provides => { | ||||||||||||||
| 16 | elements => 'all_decoders', | ||||||||||||||
| 17 | } | ||||||||||||||
| 18 | ); | ||||||||||||||
| 19 | |||||||||||||||
| 20 | 5 | ▶ | sub decode { | ||||||||||||
|
Subroutine
decode: called CC=5 SCAR=17.1
Pod
documented
| |||||||||||||||
| 21 | 5 | my ($self, $decoder, $string, $hints) = @_; | |||||||||||||
| 22 | |||||||||||||||
| 23 | 5 | my $ret; | |||||||||||||
| 24 | 5 | foreach my $decoder ($self->all_decoders) { | |||||||||||||
| 25 | 8 | $ret = eval { | |||||||||||||
| 26 | 8 | $decoder->decode($decoder, $string, $hints); | |||||||||||||
| 27 | }; | ||||||||||||||
| 28 | 8 | my $e; | |||||||||||||
| 29 | 8 | ▶ | if ($e = Data::Decode::Exception::Deferred->caught() ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 30 | # Decoding was deffered, we don't do anything about this | ||||||||||||||
| 31 | # error, and simply let the next decoder attempt to handle | ||||||||||||||
| 32 | # this particular set of inputs. | ||||||||||||||
| 33 | 3 | next; | |||||||||||||
| 34 | } elsif ( $e = Exception::Class->caught() ) { | ||||||||||||||
| 35 | # This is a generic error, just propagate it | ||||||||||||||
| 36 | 0 | ▶ | eval { $e->isa('Data::Decode::Exception') } ? | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 37 | $e->rethrow : die $e; | ||||||||||||||
| 38 | } | ||||||||||||||
| 39 | 5 | last; | |||||||||||||
| 40 | } | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 5 | return $ret; | |||||||||||||
| 43 | } | ||||||||||||||
| 44 | |||||||||||||||
| 45 | 4 | 1; | |||||||||||||
| 46 | |||||||||||||||
| 47 | __END__ | ||||||||||||||