Skip to content

Instantly share code, notes, and snippets.

@robinsmidsrod
Created August 7, 2009 18:20
Show Gist options
  • Save robinsmidsrod/164070 to your computer and use it in GitHub Desktop.
Save robinsmidsrod/164070 to your computer and use it in GitHub Desktop.
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