| 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::XPathValue; | ||||||||||
| 5 | { | ||||||||||
| 6 | 15 | $XML::Rabbit::Trait::XPathValue::VERSION = '0.4.0'; | |||||||||
| 7 | } | ||||||||||
| 8 | 15 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 15 | with 'XML::Rabbit::Trait::XPath'; | |||||||||
| 11 | |||||||||||
| 12 | # ABSTRACT: Single value xpath extractor trait | ||||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | sub _build_default { | ||||||||||
| 16 | 22 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
_build_default: called CC=1 SCAR=0.0
| |||||||||||
| 17 | return sub { | ||||||||||
| 18 | 22 | ▶ | my ($parent) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||
| 19 | 22 | my $node = $self->_find_node( | |||||||||
| 20 | $parent, | ||||||||||
| 21 | $self->_resolve_xpath_query( $parent ), | ||||||||||
| 22 | ); | ||||||||||
| 23 | 22 | ▶ | return blessed($node) ? $node->to_literal . "" : ""; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 22 | }; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 15 | Moose::Util::meta_attribute_alias('XPathValue'); | |||||||||
| 28 | |||||||||||
| 29 | 15 | ▶ | no Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 15 | 1; | |||||||||
| 32 | |||||||||||
| 33 | __END__ | ||||||||||
| 34 | |||||||||||
| 35 | =pod | ||||||||||
| 36 | |||||||||||
| 37 | =encoding utf-8 | ||||||||||
| 38 | |||||||||||
| 39 | =head1 NAME | ||||||||||
| 40 | |||||||||||
| 41 | XML::Rabbit::Trait::XPathValue - Single value xpath extractor trait | ||||||||||
| 42 | |||||||||||
| 43 | =head1 VERSION | ||||||||||
| 44 | |||||||||||
| 45 | version 0.4.0 | ||||||||||
| 46 | |||||||||||
| 47 | =head1 SYNOPSIS | ||||||||||
| 48 | |||||||||||
| 49 | package MyXMLSyntaxNode; | ||||||||||
| 50 | use Moose; | ||||||||||
| 51 | with 'XML::Rabbit::Node'; | ||||||||||
| 52 | |||||||||||
| 53 | has title => ( | ||||||||||
| 54 | isa => 'Str', | ||||||||||
| 55 | traits => [qw(XPathValue)], | ||||||||||
| 56 | xpath_query => './@title', | ||||||||||
| 57 | ); | ||||||||||
| 58 | |||||||||||
| 59 | no Moose; | ||||||||||
| 60 | __PACKAGE__->meta->make_immutable(); | ||||||||||
| 61 | |||||||||||
| 62 | 1; | ||||||||||
| 63 | |||||||||||
| 64 | =head1 DESCRIPTION | ||||||||||
| 65 | |||||||||||
| 66 | This module provides the extraction of primitive values from an XML node based on an XPath query. | ||||||||||
| 67 | |||||||||||
| 68 | See L<XML::Rabbit> for a more complete example. | ||||||||||
| 69 | |||||||||||
| 70 | =head1 METHODS | ||||||||||
| 71 | |||||||||||
| 72 | =head2 _build_default | ||||||||||
| 73 | |||||||||||
| 74 | Returns a coderef that is run to build the default value of the parent attribute. Read Only. | ||||||||||
| 75 | |||||||||||
| 76 | =head1 AUTHOR | ||||||||||
| 77 | |||||||||||
| 78 | Robin Smidsrød <robin@smidsrod.no> | ||||||||||
| 79 | |||||||||||
| 80 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 81 | |||||||||||
| 82 | This software is copyright (c) 2013 by Robin Smidsrød. | ||||||||||
| 83 | |||||||||||
| 84 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 85 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 86 | |||||||||||
| 87 | =cut | ||||||||||