Created
August 7, 2009 18:20
-
-
Save robinsmidsrod/164070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package IMS::Include::Attribute::XPathValue; | |
use Moose::Role; | |
has 'xpath_query' => ( | |
is => 'ro', | |
isa => 'Str', | |
required => 1, | |
); | |
has '+lazy' => ( | |
default => 1, | |
); | |
has '+default' => ( | |
default => sub { | |
my ($attr) = @_; | |
return sub { | |
my ($self) = @_; | |
my $value = $self->xpc->findvalue( $attr->xpath_query, $self->node ); | |
return defined($value) ? $value : ""; | |
}; | |
} | |
); | |
package Moose::Meta::Attribute::Custom::Trait::XPathValue; | |
sub register_implementation { 'IMS::Include::Attribute::XPathValue' } | |
1; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment