| 1 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package XML::Rabbit::Trait::XPathObjectMap; | ||||||||||||||||||||||||||||
| 5 | 15 | $XML::Rabbit::Trait::XPathObjectMap::VERSION = '0.4.1'; | |||||||||||||||||||||||||||
| 6 | 15 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 15 | with 'XML::Rabbit::Trait::XPath'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # ABSTRACT: Multiple XML DOM object xpath extractor trait | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 8 | ▶ | around '_process_options' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 13 | 8 | my ($orig, $self, $name, $options, @rest) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 8 | $self->$orig($name, $options, @rest); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # This should really be: | ||||||||||||||||||||||||||||
| 18 | # has '+isa' => ( required => 1 ); | ||||||||||||||||||||||||||||
| 19 | # but for some unknown reason Moose doesn't allow that | ||||||||||||||||||||||||||||
| 20 | 8 | ▶ | confess("isa attribute is required") unless defined( $options->{'isa'} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 15 | }; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | has 'isa_map' => ( | ||||||||||||||||||||||||||||
| 26 | is => 'ro', | ||||||||||||||||||||||||||||
| 27 | isa => 'HashRef[Str]', | ||||||||||||||||||||||||||||
| 28 | lazy => 1, | ||||||||||||||||||||||||||||
| 29 | 4 | ▶ | default => sub { +{} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 15 | ); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 15 | has 'xpath_key' => ( | |||||||||||||||||||||||||||
| 34 | is => 'ro', | ||||||||||||||||||||||||||||
| 35 | isa => 'Str', | ||||||||||||||||||||||||||||
| 36 | required => 1, | ||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 6 | ▶ | sub _build_default { | ||||||||||||||||||||||||||
|
Subroutine
_build_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 42 | 6 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 43 | 6 | my ($parent) = @_; | |||||||||||||||||||||||||||
| 44 | 6 | my $xpath_query = $self->_resolve_xpath_query( $parent ); | |||||||||||||||||||||||||||
| 45 | 6 | $self->_convert_isa_map( $parent ); | |||||||||||||||||||||||||||
| 46 | 6 | my $class = $self->_resolve_class(); | |||||||||||||||||||||||||||
| 47 | 6 | my %node_map; | |||||||||||||||||||||||||||
| 48 | 6 | foreach my $node ( $self->_find_nodes($parent, $xpath_query ) ) { | |||||||||||||||||||||||||||
| 49 | 1460 | my $key = $parent->xpc->findvalue( $self->xpath_key, $node ); | |||||||||||||||||||||||||||
| 50 | 1460 | ▶ | if ( defined($key) and length $key > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $key and length $key > 0
MC/DC50%1/2
defined $key and length $key > 0
defined $key
length $key > 0
Truth table66%2/3
A and B
A= defined $keyB= length $key > 0
| |||||||||||||||||||||||||||||
| 51 | 1459 | $node_map{ $key } = $self->_create_instance( $parent, $class, $node ); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 6 | return \%node_map; | |||||||||||||||||||||||||||
| 55 | 6 | }; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 15 | Moose::Util::meta_attribute_alias('XPathObjectMap'); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 15 | ▶ | no Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 15 | 1; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||